53 Commits

Author SHA1 Message Date
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
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
c7dbcf0bc9 Up the release version to 2.71
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2024-10-25 22:17:54 -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
a47d86dfb9 Up the release version to 2.65
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-07-17 15:33:06 -07:00
Andrew G. Morgan
fc029cb517 Include LIBCAP_{MAJOR,MINOR} #define's in sys/capability.h
It looks like various distributions are fairly far behind HEAD for
their version of libcap. This way folk can work around a lack of
features in their code.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-04-10 14:49:26 -07:00
Andrew G. Morgan
e1bd9ac089 Trim includes.
I've upgraded one of my systems to Fedora 35 and I found trimming
the headers in this way made the three compilations of libcap, used
by `make distcheck`, work with standard Fedora 35 compiler packages.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2022-01-23 16:36:06 -08:00
Andrew G. Morgan
1fe7dbe984 Drop perl from the build requirements.
David Seifert at Gentoo made a request to not require perl for
the libcap build since their distribution wants to build it prior
to building perl and so requiring it requires they maintain some
extra patches.

We previously introduced the need for perl in response to some
apparent incompatibilities between various versions of sed:

https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=9494a1fab59ac0b6e4f0bfc536fa482c6d6490b6

However, it has been 13 years since that time so we're optimistic
those problems are no longer present for anyone and we've also
added a make variable abstraction in case some builder wants to
override their system default 'sed' as make BUILD_SED=... etc.

We've also done something similar with make uses of grep, egrep
and fgrep.

Finally, for make variable naming consistency, we've replaced use
of BUILD_GPERF with USE_GPERF. Since folk may be using BUILD_GPERF
in their package building scripts, we error out if it is set.
The expectation is that people will update their package defs.
(Eventually, we plan to reuse BUILD_GPERF as an alias for 'gperf'.)

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-12-04 10:18:50 -08:00
Andrew G. Morgan
5ef14d0742 Refactor top level Makefile to reduce redundant building
Make build a bit quicker for folk that don't want to run tests.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-09-04 14:05:11 -07:00
Andrew G. Morgan
6c38eb78d9 Avoid the build server failure.
I figured out that the key ingredient to reproducing this issue
was:

   make COPTS="-D_FORTIFY_SOURCE=2 -O1 -g" clean test

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-28 09:43:51 -07:00
Andrew G. Morgan
6dea1813f2 Support CC=clang again.
I didn't realize CC=clang used to work. Now it does again.
I've also added a test build for clang in distcheck.

This fixes:

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

Also, add a note about pam_cap.so building after debugging:

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

Finally, removed a redundant LDFLAGS link directory override.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-08-11 19:59:24 -07:00
Andrew G. Morgan
06ec53d0c9 Permit compilation with -std=c89.
Tested with

  make COPTS="-O2 -std=c89" clean all test sudotest

This addresses the issue reported by Byron Stanoszek:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-06-21 17:46:43 -07:00
Andrew G. Morgan
21922e27cd More info for how to coax go.dev into noticing module updates
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-05-28 13:31:58 -07:00
Andrew G. Morgan
78fded0ec5 Skip pam_cap.so build on musl compilation part of make distcheck.
My build setup does not support this target.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-05-24 12:04:47 -07:00
Andrew G. Morgan
91455fd109 Add a handy update script for the various go.mod files.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-05-24 11:50:15 -07:00
Andrew G. Morgan
b5dcf3aa87 Add some code to automatically exit the kernel test
I occasionally test libcap against a custom kernel using QEMU.
Now I have a simple exit binary for exiting with status.

From the top level, one can use:

  make ktest

However, for more control:

  cd kdebug
  make test

If you want to look around after the tests run:

  make shell

Exit the shell & QEMU with ctrl-D (or exit).

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-03-13 15:36:25 -08:00
Andrew G. Morgan
75a5a9e4dd Upgrade cap and psx Go modules to version 1.2.48
Go has its own notion of major version, and this commit raises
it from 0 to 1. That is, these modules should now be considered
stable.

The sources for the 1.2.48 and the 0.2.48 modules are otherwise
identical.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-02-04 22:19:16 -08:00
Andrew Delgadillo
9c740a5e26 libcap: Use $(MAKE) instead of make
Using naked make causes make to emit jobserver warning. So replace uses
of naked make with $(MAKE) to avoid these warnings.

Signed-off-by: Andrew Delgadillo <adelg@google.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2021-02-02 18:22:34 -08:00
Andrew G. Morgan
2e86248a97 Be more complete when looking for stray files in the build tree
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-12-12 15:53:01 -08:00
Andrew G. Morgan
a614aa669d Fix tests:sudotest for DYNAMIC=yes testing
Actually, fix the libcap_launch_test.c itself since it wasn't correctly
failing with an error exit code before.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-10-18 13:48:09 -07:00
Andrew G. Morgan
79e421f6e0 Add a note about updating the Go module documentation
Document the manual step I need to do.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-09-06 17:11:38 -07:00
Andrew G. Morgan
dbeb06ba29 Up the release version to 2.43
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-08-15 11:17:55 -07:00
Andrew G. Morgan
2a892954b4 When doing a distclean validate that the tree is fully committed.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-08-05 19:54:52 -07:00
Andrew G. Morgan
973c34a216 Up the release version to 2.40
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-07-19 14:59:05 -07:00
Andrew G. Morgan
dc22ad68b9 Force an update of the go.mod files before building official release.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-07-13 19:28:51 -07:00
Andrew G. Morgan
dca9b22261 Rewrite libpsx thread shutdown path to support musl.
Addresses:

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

Removed the non-wrapping libpsx macro hacks. The API surface as such
becomes a little smaller and I now have confidence that wrapping
pthread_create using the linker options works with Go, gcc and musl
compilers. I feel it is stable enough to call good to delete the
workarounds.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-07-09 22:33:54 -07:00
Andrew G. Morgan
24aa318f9f It looks as if the module files need a libcap directory tag.
I initially made one, and now modules are building with that stale
value v0.2.37. All despite the fact the Go modules are at v0.2.38.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-07-07 20:00:46 -07:00
Andrew G Morgan
1fe9b31126 A final twist in the Go module support.
It turns out that the Go module abstraction needs a tag specific to
each sub-package, and can't share a generic one for libcap as a whole
for both Go modules. As such, replace the vX.Y.Z tag with two
package/vX.Y.Z tags.

Signed-off-by: Andrew G Morgan <morgan@kernel.org>
2020-07-03 20:36:43 -07:00
Andrew G. Morgan
ffa7df01d3 Refactored the psx package to build as a Go module.
Cleaned up the Go module redirection html file, now installed
at:

  https://kernel.org/pub/linux/libs/security/libcap/

Note, I've moved the C source for libpsx.a into the psx/
directory, but the libpsx.a file is still built in the libcap
subdirectory as before. I also symlinked the C include files from
the psx/ directory. This made the source compile in conjuction
with the "psx" Go package automatically. It also substantially
simplified the go/Makefile.

I feel pretty good about this next version from the perspective
of a viable "psx" build. Caveat the need for CGO_LDFLAGS_ALLOW
on the command line pre-go1.15. Hopefully, the psx package comment
is enough for folk to figure that detail out.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-07-03 15:40:58 -07:00
Andrew G. Morgan
876ac7186b Revamp the way we package cap and psx packages.
It has been requested that we make the "libcap/cap" package into
a module that plays better with the golang ecosystem. I was holding
off until there was a golang version that contained the
runtime.AllThreadsSyscall() support, but that appears to not have
made it to 1.15, so I'm using a development build tag dependency
in otherwise static sources for the "libcap/cap" package.

My intention is that the canonical import paths for these packages
will be:

   "git.kernel.org/libs/libcap/cap"
   "git.kernel.org/libs/libcap/psx"

That being said, I may have to move them if I can't get some
proxy to resolve these paths to the right git repo of kernel.org.

The is work in the direction of addressing:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-07-02 22:12:11 -07:00
Andrew G. Morgan
a3e844af89 First attempt at supporting the Go "psx" package as a module.
The intended import path for this module is:

   "git.kernel.org/libs/libcap/psx"

This is my first attempt at such module support, so it will
likely require some iteration.

This is work in the direction of addressing:

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

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-07-02 16:43:52 -07:00
Andrew G. Morgan
6b39555644 Linux 5.7 supports CAP_PERFMON
I should have checked before releasing 2.35. Sigh. Won't make that
mistake again.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-06-02 20:56:01 -07:00
Andrew G. Morgan
f1f62a748d Refactor the way we do the psx linkage in libcap.
Since we now have a serialized (linker trick) to initialize libcap
we can reliably compute the number of capabilities of the running
kernel in a race free way. Export the found number of capabilities
with the cap_max_bits() function. This is also what we now use in
both C and Go to define [all]=[eip]. In Go the equivalent function
is cap.MaxBits().

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2020-01-03 14:00:22 -08:00
Andrew G. Morgan
99c995b84e Add group, ambient and bound setting support to pam_cap.
Rewrote the pam_cap config file parsing to support:

  - @group syntax for identifying groups of users
  - ^cap_foo support for raising both inheritable and ambient caps
  - !cap_bar support for dropping bounding capabilities

Updated documentation for pre-existing libcap's ambient support.

This pam_cap feature upgrade was done in collaboration with
Knut Omang and Christoph Lameter.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2019-12-22 08:08:48 -08:00
Andrew G. Morgan
dada271ca4 Break out test into two parts: test or sudotest.
The latter will invoke tests with sudo. Not all builds
can support this, but we do need a convenient way
to test this stuff...

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2019-12-15 10:52:55 -08:00
Andrew G. Morgan
2b5f5635be Restructure the make files into build vs. test
Also install the Go packages if built.

Remove a default behavior of installing an inheritable bit on setcap.
I'm getting alarmed that some distributions are setting the inheritable
set to full for all users. So, I don't want to provide a vector for
a trivial exploit, and hope they are not reinventing this:

https://sites.google.com/site/fullycapable/Home/thesendmailcapabilitiesissue

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2019-12-13 17:30:23 -08:00
Andrew G. Morgan
e9f55d90e4 Implement a helper library for POSIX semantics syscalls.
Since Linux kernel supported threads are not POSIX threads
and the glibc pthread library only supports POSIX semantics
for 9 system calls, to fully support the POSIX semantics for
a process sharing its security state across all of its
threads, we've created libpsx.

This commit also includes a threading test in tests/ for
this new psx_syscall() abstraction - one that transparently
mirrors calling POSIX-needing semantics syscalls over
all running threads.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2019-12-05 21:14:47 -08:00
Andrew G. Morgan
0615d99637 A Go (golang) implementation of libcap: import "libcap/cap".
The API for this "libcap/cap" package is very similar to libcap.
I've included a substantial interoperability test that validate
libcap(c) and libcap/cap(go) have import/export text and binary
format compatibility.

My motivation for implementing a standalone Go package was for a
cross-compilation issue I ran into (Go is much more friendly for
cross-compilation by default, unless you need to use cgo).

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2019-05-19 14:57:20 -07:00
Andrew G. Morgan
83dc034b3d Tidy up the tarball and release make rules.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2018-09-15 14:53:13 -07:00
Andrew G. Morgan
8030da1b54 Add a convenient make top level 'test' target
The test does things with privilege on the current system, so it
invokes sudo to run.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2018-09-09 12:33:15 -07:00
Andrew G. Morgan
dce069b617 Add something to run libcap's quicktest tests against development kernel.
The kdebug directory requires qemu to run and expects the kernel
to be compiled with the running architecture. My setup has the kernel
sources as a peer to the libcap directory so kdebug assumes that too.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2016-02-06 19:42:27 -08:00
Andrew G Morgan
762008b183 Upload to kernel.org is of the tar file with accompanying signature.
I used to sign the .gz files with my old DSA key, but now will only be
signing the raw tar files with my kernel.org upload key.

Signed-off-by: Andrew G Morgan <morgan@kernel.org>
2013-12-27 10:19:22 -08:00
Andrew G Morgan
3a788dd053 Adjustments to point to kernel.org locations.
Also include a copy of the public key I have to use to upload binaries
to kernel.org. Moving forward, I plan to sign release tags with both keys.

Signed-off-by: Andrew G Morgan <morgan@kernel.org>
2013-12-27 10:04:50 -08:00
Andrew G Morgan
8e9c717745 Explore using this key to upload to kernel.org
Signed-off-by: Andrew G Morgan <morgan@kernel.org>
2013-12-27 09:08:53 -08:00
Andrew G Morgan
614111b3dc Prepare for a release tag.
Signed-off-by: Andrew G Morgan <morgan@kernel.org>
2013-12-24 11:37:35 -08:00
Andrew G. Morgan
a613b0086f This is release 2.22.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2011-07-24 19:24:16 -07:00
Andrew G. Morgan
953e7f1d9c Some makefile cleanups.
All the good parts of this change are Mike Frysinger's
<vapier@gentoo.org> work. Everything that is broken, is due to my
mangling of it.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2008-06-02 22:02:01 -07:00
Andrew G. Morgan
e64aa18f6d Make pam_cap compilation conditional.
Default is for make to guess if the user wants the module or not
user can override with

    make PAM_CAP={yes|no}

Thanks to Chris Freidhoff for the suggestion and a first stab at a patch.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2008-01-17 19:31:45 -08:00
Andrew Morgan
cd45c57c35 Build with a pam_cap module.
Note, I've been confused about the capset/capget system calls.
It would seem that the current way(TM) is to get the raw API
from libc.
2007-08-13 23:34:41 -07:00
Andrew Morgan
4ede6982a4 Cleanup output; and permit setcap e value to be superset of ip.
This means one can say:

   setcap "all=e cap_net_raw=p" ping

which is equivalent to

   setcap "cap_net_raw=ep" ping
2007-08-13 23:33:40 -07:00