739 Commits

Author SHA1 Message Date
Andrew G. Morgan
def8fab2a3 Up the release version to 2.74
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
cap/v1.2.74 psx/v1.2.74 libcap-2.74 libcap-korg-2.74 v1.2.74 sig-libcap-2.74
2025-03-02 16:09:34 -08:00
Andrew G. Morgan
805a6d3b3f Trim the examples for the cap package.
Added a couple of examples for lesser used functions: cap.Import()
and (*cap.Set) Export().

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-02 15:59:14 -08:00
Andrew G. Morgan
7be690ed8c Improve weaver test to count zeros vs '-1' values.
This isn't fixing a known issue, but more preparing for a potential
PSX mechanism error.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-02 14:24:25 -08:00
Andrew G. Morgan
4b1d6d6332 Compile with -std=c89 option.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-02 11:46:52 -08:00
Andrew G. Morgan
20c22e64bf Be consistent about using SA_RESTORER.
Found this omission via CC=musl-gcc build test (in make distcheck).

Last(?) fix for:

    https://bugzilla.kernel.org/show_bug.cgi?id=219687

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-02 10:46:34 -08:00
Andrew G. Morgan
b5b2e011a7 Drop linux/ headers for standard ones.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-02 10:25:00 -08:00
Andrew G. Morgan
7a7982067e Churn test should work with or without cgo.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
psx/v1.2.74-rc6 cap/v1.2.74-rc6
2025-03-02 10:10:47 -08:00
Andrew G. Morgan
d510712a27 Clean up go documentation.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-03-02 10:02:45 -08:00
Andrew G. Morgan
dfb0fc263b Add riscv support for the psx mechanism.
This adds `__riscv` (curiously, gcc does not define `__riscv__`) psx
compilation support.

  https://bugzilla.kernel.org/show_bug.cgi?id=219687

Also, add explicit __x86_64__ compilation support. It was working
implicitly, but change to be consistent.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
cap/v1.2.74-rc5 psx/v1.2.74-rc5
2025-02-22 11:36:48 -08:00
Leo
cf8d9ad3ec Fix reliance on transitive include.
kill(2) is declared in signal.h, however previously this header was not
included. It happened to work on glibc, where sys/wait.h includes
signal.h, this is however not required behavior in the POSIX standard:

> Inclusion of the <sys/wait.h> header may also make visible all symbols
> from <signal.h> and <sys/resource.h>.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-02-19 19:19:59 -08:00
Andrew G. Morgan
47f119fff3 Fix error when expanding hash map.
The code was using `hval` when it should have used `mix`. I've removed
`hval` from the code now. This fixes this bug:

   https://bugzilla.kernel.org/show_bug.cgi?id=219752

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
cap/v1.2.74-rc4 psx/v1.2.74-rc4
2025-02-17 21:43:26 -08:00
Andrew G. Morgan
c32a4d372f Add s390x support for new PSX mechanism.
As per this bug report:

  https://bugzilla.kernel.org/show_bug.cgi?id=219687

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-02-17 21:42:20 -08:00
Andrew G. Morgan
fc336e9794 Add a test for bad group prefix.
The previous commit fixed a bug with the config parsing in pam_cap.
This is a test that we don't regress against that fix.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-02-16 20:17:08 -08:00
Tianjia Zhang
1ad42b66c3 pam_cap: Fix potential configuration parsing error
The current configuration parsing does not actually skip user names
that do not start with @, but instead treats the name as a group
name for further parsing, which can result in matching unexpected
capability sets and may trigger potential security issues.  Only
names starting with @ should be parsed as group names.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-02-16 20:12:47 -08:00
Andrew G. Morgan
9c46e11a46 Add PowerPC support for latest PSX implementation.
See:

  https://bugzilla.kernel.org/show_bug.cgi?id=219687

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
cap/v1.2.74-rc3 psx/v1.2.74-rc3
2025-02-16 16:20:55 -08:00
Andrew G. Morgan
aabdd103bb Mention CAP_MODE_HYBRID in man page.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
psx/v1.2.74-rc2 cap/v1.2.74-rc2
2025-02-16 10:26:58 -08:00
Tianjia Zhang
d7b41e480d doc: Fix typo of cap_cap_proc
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-02-16 10:21:31 -08:00
Andrew G. Morgan
5a9f9dde6c Add mips support for refactor of psx.
Mips bugfix:

   https://bugzilla.kernel.org/show_bug.cgi?id=219687

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2025-02-15 15:00:28 -08:00
Andrew G. Morgan
025f28ca4f Avoid thread churn deadlock with PSX rewrite.
This bug, reported by David Runge, identifies another regression
vs. libpsx-2.71:

   https://bugzilla.kernel.org/show_bug.cgi?id=219687

A regression of the LWP threading support reintroduced an old bug
in the libpsx-2.72 rewrite, specifically this bug:

   https://github.com/golang/go/issues/42494

This present change includes x86_64, i386 and arm* (32-bit and 64-bit)
support. I've tested each of these with debian OSes, some running via QEMU.
Before releasing 2.74, I plan to extend the testing to all of the targets
supported by Debian (see https://wiki.debian.org/DebianInstaller/Qemu).

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
psx/v1.2.74-rc1
2025-02-01 08:49:27 -08:00
Andrew G. Morgan
2dda39e0e3 The go.dev site is unable to render this example.
As a workaround for the golang bug: 70630, specifically comment
70630#issuecomment-2513491664 provide an alias for the package.
Perhaps, at some point, that bug or the one it is duped into will
be fixed, and we can remove this workaround.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-12-26 19:26:54 -08:00
Andrew G. Morgan
6ef6a9d1e4 Up the release version to 2.73
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
cap/v1.2.73 libcap-2.73 v1.2.73 psx/v1.2.73 libcap-korg-2.73 sig-libcap-2.73
2024-12-01 20:18:58 -08:00
Andrew G. Morgan
f6d4cb050c _GNU_SOURCE #define needed in psx.c to build -std=c99.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-28 09:36:27 -08:00
Andrew G. Morgan
a9a34483d8 Slightly briefer cap example.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-27 17:44:55 -08:00
Andrew G. Morgan
4726b0da33 Use go vet as part of testing the go/ packages.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-22 18:37:19 -08:00
Andrew G. Morgan
69671a4972 gettid() is sporadically defined over various libc's.
Use an alias #define for this system call.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-22 18:37:19 -08:00
Andrew G. Morgan
a1859fdc9e Fix setcap after last commit broke it.
Embarrassed. Overlooked test failure.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-22 18:36:30 -08:00
Andrew G. Morgan
80d7d006b9 Tidy up help message, and sort option processing of setcap.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-18 21:21:47 -08:00
Andrew G. Morgan
a044d8b496 Address some static analysis observations.
These were reported by Carlos Rodriguez-Fernandez with respect
to some analysis performed on the Fedora libcap-2.71 package.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-15 07:26:42 -08:00
Xi Ruoyao
304089b078 psx: use getdents64 instead of getdents
On relatively new architectures (for example ARM64, RISC-V, and
LoongArch), the kernel does not have a getdents syscall.  Use getdents64
instead to fix the build on them.

The getdents64 syscall was added in Linux 2.4 and I don't think we
should still support older kernels today.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-11 21:10:04 -08:00
Andrew G. Morgan
d35e7651b4 Third attempt to make a runnable example in the cap package docs.
Still trying to coax some go.dev documentation into providing runnable
examples. Iterating with a single simple one.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-10 20:02:36 -08:00
Andrew G. Morgan
1a02e34cc4 Up the release version to 2.72
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
psx/v1.2.72 libcap-korg-2.72 libcap-2.72 cap/v1.2.72 v1.2.72 sig-libcap-2.72
2024-11-10 15:26:15 -08:00
Andrew G. Morgan
f001ee7343 Go, prior to 1.16.x, had an issue with interrupts and exiting threads.
How this is relevant to the PSX code (since its 2.72 refactor) is the
subject of:

   https://bugzilla.kernel.org/show_bug.cgi?id=219478

Since we've decided to not fully support earlier versions of Go by
working around this bug any longer, modify the test to not test for
this bug.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-10 00:09:33 -08:00
Andrew G. Morgan
b017fcff26 Eliminating -wrap use.
This addresses the following bug:

   https://bugzilla.kernel.org/show_bug.cgi?id=219456

insofar as it eliminates the need for -wrap=pthread_create
linkage. Mostly, code that uses -lpsx functions can simply
link with -lpsx now. However, for legacy reasons the library
still works when linked wrapped or with the new content of
the libpsx.pc file:

   -Wl,--no-as-needed -Wl,--whole-archive -lpsx -Wl,--no-whole-archive -Wl,--as-needed -lpthread

These last options are required for getting -lcap to act at a
consistent process level and not a thread level.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-09 23:19:18 -08:00
Andrew G. Morgan
1474f5b96e Stop claiming to support pre-go1.16 releases.
The refactoring of libpsx to operate at a LWP level and not
the pthread level has caused an old Go issue to reappear.
Details:

   https://bugzilla.kernel.org/show_bug.cgi?id=219478

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-09 15:43:26 -08:00
Andrew G. Morgan
31ed2fef38 Factor out the ((weak)) psx_load_syscalls() function.
Trying to find a path for not needing linker wrapping.
This feels like a step in the right direction, but doesn't
allow removal of the -wrap linkage yet.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-08 19:33:25 -08:00
Andrew G. Morgan
c5a06aea03 First step in eliminating libpsx "--wrap"ing linkage.
The refactored libpsx code does not operate at the pthread
abstraction. We still need the --wrap linkage to force
libpsx to be linked into the binary if the binary makes
no explicit calls to libpsx functions. But we should no
longer need it in cases where the code calls psx_syscall[36]().

This is a step towards addressing:

   https://bugzilla.kernel.org/show_bug.cgi?id=219456

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-11-05 06:45:29 -08:00
Andrew G. Morgan
0ec5b2686d Address psx compilation warning from clang.
Remove potential for unaligned read. Also tidy up some not needed
header includes.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-27 07:51:39 -07:00
Andrew G. Morgan
12ff38be49 Tighten up the comments for the various signed tags moving forward.
These may seem excessive, but:

- 3 are for Go module version naming automation
- 1 is for kernel.org automation purposes
- 1 is for legacy consistency tagging
- 1 moving forward "official" tagging (packagers can use this one)

I've back-signed all of the libcap-2.xy releases with the "official" key:

$ gpg --fingerprint 0D23D34C577B08C4082CFD76430C5CFF993116B1
pub   ed25519 2024-10-26 [SC]
      0D23 D34C 577B 08C4 082C  FD76 430C 5CFF 9931 16B1
uid           [ultimate] Andrew G. Morgan (2024+ libcap signing key) <morgan@kernel.org>
sub   cv25519 2024-10-26 [E]

Since the legacy tag uses a no longer considered secure technology,
I'll likely stop using it around libcap-2.75 when the new key has
gained more history and trust.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-26 20:53:42 -07:00
Andrew G. Morgan
3f109e422a Second attempt to make a runnable example in the cap package.
Trying to coax some go.dev documentation into providing runnable
examples. Starting with a single simple one.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-26 20:08:44 -07:00
Andrew G. Morgan
766527f2b9 Make make run_b219174 dependencies work.
Omitted a dependency before. Now, this works:

$ make distclean
$ cd tests
$ make run_b219174

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-26 09:03:40 -07:00
Andrew G. Morgan
794b185b6a Shuffle the GPG key choices to favor the most modern key.
Starting with libcap-2.71 the following key is considered
the load bearing one on tags sig-libcap-2.xy:

   0D23D34C577B08C4082CFD76430C5CFF993116B1

We'll back tag all of the libcap-2.* releases with the
corresponding signed tag.

Further, starting with libcap-2.72, we'll transition all of
the Go package tags (*v1.2.xy) to be signed with this key.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-26 07:46:45 -07:00
Andrew G. Morgan
db256cd8f6 Add a test case for using libpsx with C++.
This demonstrates libpsx-2.72+ is now compatibile with the
std::thread variety of C++ threading under Linux.

This completes support for:

   https://bugzilla.kernel.org/show_bug.cgi?id=218607

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-25 23:00:11 -07:00
Andrew G. Morgan
12e163ac21 Rewrite libpsx to work with native linux threads.
This is more general than just working with -lpthread threads,
and addresses the following bug reports:

  https://bugzilla.kernel.org/show_bug.cgi?id=219174
  https://bugzilla.kernel.org/show_bug.cgi?id=218607
  https://bugzilla.kernel.org/show_bug.cgi?id=217476

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-25 22:58:46 -07:00
Andrew G. Morgan
c7dbcf0bc9 Up the release version to 2.71
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
cap/v1.2.71 psx/v1.2.71 sig-libcap-2.71 v1.2.71 libcap-korg-2.71 libcap-2.71
2024-10-25 22:17:54 -07:00
Andrew G. Morgan
67b8bf1476 Tidy up some white space (tab -> space)
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-25 22:01:07 -07:00
Andrew G. Morgan
d510135f8d Add a more modern signing key.
This addresses the request in:

    https://bugzilla.kernel.org/show_bug.cgi?id=218860

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-25 21:50:53 -07:00
Andrew G. Morgan
c73ae0df31 c89 compilation test fix.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-24 21:28:22 -07:00
Andrew G. Morgan
9e4b652f48 Lessen the situations where cap.SETPCAP is required for IAB setting.
Discussion and explanation of what is up here is in:

   https://bugzilla.kernel.org/show_bug.cgi?id=219169

This gets the Go cap package to parity with the recent changes to
libcap. This change will be live in cap/v1.2.71.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-19 16:37:56 -07:00
Andrew G. Morgan
676971a20a Document current behavior of cap_iab_set_proc()
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-09-22 11:11:44 -07:00
Andrew G. Morgan
30892a5d5b Add a test example.
First attempt to get the docs on go.dev to have ready to run examples.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-09-22 11:10:05 -07:00