709 Commits

Author SHA1 Message Date
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
Andrew G. Morgan
422bec25ae Large strings can confuse libcap's internal strdup code.
Avoid something subtle with really long strings: 1073741823 should
be enough for anybody. This is an improved fix over something attempted
in libcap-2.55 to address some static analysis findings.

Reviewing the library, cap_proc_root() and cap_launcher_set_chroot()
are the only two calls where the library is potentially exposed to a
user controlled string input.

Credit for finding this bug in libcap goes to Richard Weinberger of
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-02 (CVE-2023-2603)

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-09 18:49:46 -07:00
Andrew G. Morgan
bc6b36682f Correct the check of pthread_create()'s return value.
This function returns a positive number (errno) on error, so the code
wasn't previously freeing some memory in this situation.

Discussion:

  https://stackoverflow.com/a/3581020/14760867

Credit for finding this bug in libpsx goes to David Gstir of
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-01 (CVE-2023-2602)

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-05-09 18:48:18 -07:00
Andrew G. Morgan
819f941bce Partially revive fully static binaries.
It looks like I broke the kdebug target build when I dropped fully
static building of capsh and friends. Discovered this, looking at
answering:

https://unix.stackexchange.com/questions/741532/launch-process-with-limited-capabilities-on-minimal-busybox-based-system

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-04-22 15:38:29 -07:00
Emanuele Torre
a4089305d9 Improve style in man page function prototypes
Use  type *id  everywhere instead of using  type * id  and  type* id
in some places. Also remove superflous spaces after commas, and closing
parentheses.

While doing this, I also fixed a C syntax mistake in an example in
cap_launch.3

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-04-10 17:23:58 -07:00
Andrew G. Morgan
3c7dda330b Up the release version to 2.68
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
sig-libcap-2.68 cap/v1.2.68 libcap-korg-2.68 psx/v1.2.68 v1.2.68 libcap-2.68
2023-03-25 17:03:17 -07:00
Andrew G. Morgan
3a93d8edcf Undo hiding the wrapped function call in libpsx.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-25 16:55:20 -07:00
Andrew G. Morgan
5496a0e385 Tidy up some text explaining cap.NamedCaps.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-19 20:18:44 -07:00
Andrew G. Morgan
8c435a6fec Some formatting fixes for the libpsx man page.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-18 18:02:44 -07:00
Andrew G. Morgan
9c084eceb2 Replace the README with a README.md
Also include the `go mod tidy` detail.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-03-11 18:11:47 -08:00
Andrew G. Morgan
e32563557b Recognize the new man page links.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2023-02-19 19:57:41 -08:00