719 Commits

Author SHA1 Message Date
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
Andrew G. Morgan
7d571d1336 Suppress use of -Bsymbolic-functions which otherwise breaks libpsx
Credit to Stas Sergeev for unraveling this and reporting it:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-08-17 09:36:33 -07:00
Pierre-Clément Tosi
651d99fdf0 libcap: Use all $(xFLAGS) when building 'empty'
Pass the flags as they might be needed by $(CC) to properly compile or
link an executable (e.g. --sysroot).

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-08-17 08:50:55 -07:00
Andrew G. Morgan
bbcfccdcc4 Setting ambient bits does not require CAP_SETPCAP.
Limit the conditions where we raise CAP_SETPCAP to set an IAB value.
There are some situations where that capability is needed, but they
are by no means a requirement for all IAB value setting.

Credit for discovering this goes to Christopher Head and reporting
it in:

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

Update the man pages to better reflect use of Amibient bit setting.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-08-16 20:20:12 -07:00
Andrew G. Morgan
dc3b42a261 Work around a longstanding problem with glibc/fedora with segfaulting
https://sourceware.org/bugzilla/show_bug.cgi?id=26729

We can't rely on getpw/grid() functions working from static compiled binaries.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-06-22 12:28:19 -07:00
Andrew G. Morgan
d24490223f Document program exit for inconsistent system call behavior.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-06-21 07:10:53 -07:00
Andrew G. Morgan
8fe536b53f Up the release version to 2.70
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
sig-libcap-2.70 psx/v1.2.70 cap/v1.2.70 v1.2.70 libcap-korg-2.70 libcap-2.70
2024-05-18 21:43:17 -07:00
Andrew G. Morgan
13b9ee57f9 Tidy up some of the automated formatting.
doc/mkmd.sh also has some dependencies on the format of the man
pages, so make that work again.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-04-05 19:00:59 -07:00
Carlos Rodriguez-Fernandez
56ee609f67 doc: document the use of * to refer to all users
Signed-off-by: Carlos Rodriguez-Fernandez <carlosrodrifernandez@gmail.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-04-05 18:16:48 -07:00
Carlos Rodriguez-Fernandez
caab6200d2 doc: document pam_cap and its conf
Signed-off-by: Carlos Rodriguez-Fernandez <carlosrodrifernandez@gmail.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-04-03 18:08:22 -07:00
Andrew G. Morgan
e79c7f06e1 Reformat doc text for web.go
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-02-18 07:24:19 -08:00
Jakub Wilk
17c5e89521 getpcaps: fix program name in help message
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-01-29 07:19:36 -08:00
Jakub Wilk
011eb766ce Fix reference formatting in the captree man page.
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-01-12 12:34:40 -08:00
Andrew G. Morgan
ee20d385ef Stop using _pam_overwrite() in pam_cap.c.
It looks like the Linux-PAM folk have deprecated this macro. Compiler optimization
is hard to account for: apparently this explicit deletion is no longer
guaranteed to work. This function was marked deprecated in v1.5.3 of Linux-PAM.

I've replaced its use with memset(). I'm not convinced that that will be honored
either, but remain hopeful and prefer to leave the code explicit in its intent
without a deprecation warning messing up the build log. Should some compiler
optimize it away and it leads to an exploit of some sort, it can be revealed as
a compilation bug.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-12-22 06:37:02 -08:00
Andrew G. Morgan
6585135806 Restore c89 compaitbility for C source files.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-08-13 13:56:29 -07:00
Andrew G. Morgan
4ffb54079c Add a check for a capabability of all spaces.
Address user report of confusing behavior by adding a check to setcap
for a "<space...>" capability not meaning "-r".

Another suggestion from

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-06-24 22:47:45 -07:00
Andrew G. Morgan
ac8d461a2c Make it harder to set invalid capabilities on files.
This change introduces the setcap -f argument to allow setting
of nonsense capabilities on files. But the default is to fail
when attempting to set such invalid capabilities.

This commit addresses:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-06-24 22:24:00 -07:00
Andrew G. Morgan
8785077d6c Tidy up the overview example for the "cap" package.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-24 06:55:47 -07:00
Andrew G. Morgan
8bed80f9b5 Up the release version to 2.69
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
sig-libcap-2.69 libcap-korg-2.69 cap/v1.2.69 psx/v1.2.69 v1.2.69 libcap-2.69
2023-05-14 19:10:04 -07:00
Andrew G. Morgan
6baf268986 Ignore the content of a capability.conf file if it is world-writable.
Other than the case of /dev/null, there is no situation in which pam_cap.so
should act on world writable config files.

There are legitimate local administration choices for the file being owned
by non-root users, and similarly writable by a group of trusted users. So,
we do not require any specific ownership for the file and do not check for
writable access based on owner of group membership.

Credit for finding this bug in pam_cap.so goes to X41 D-Sec GmbH
(https://x41-dsec.de/) who performed a security audit of the libcap
source code in April of 2023. The audit was sponsored by the Open
Source Technology Improvement Fund (https://ostif.org/).

Audit ref: LCAP-CR-23-101

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-09 18:56:14 -07:00
Andrew G. Morgan
917c8b5d34 There was a small memory leak in pam_cap.so when libpam returned an error.
The function pam_set_data() takes ownership of a memory pointer if
the call succeeds, but does not take that ownership if the function
fails. Previously, the failure caused no deferred capability setting and
a return code PAM_IGNORE. It continues to do that in this case, but no
longer leaks the allocated iab memory.

This bug was introduced with deferred IAB capability setting support in
libcap-2.58.

Credit for finding this bug in pam_cap.so goes to X41 D-Sec GmbH
(https://x41-dsec.de/) who performed a security audit of the libcap
source code in April of 2023. The audit was sponsored by the Open
Source Technology Improvement Fund (https://ostif.org/).

Audit ref: LCAP-CR-23-100

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-09 18:56:00 -07:00