1
0
Fork 0
mirror of git://git.kernel.org/pub/scm/libs/libcap/libcap.git synced 2026-12-03 16:44:43 +00:00
No description
  • C 55.5%
  • Go 32%
  • Shell 6.4%
  • Makefile 5.5%
  • C++ 0.2%
  • Other 0.3%
Find a file
mustafa b361aa4ccc fix: make cap_set_flag fail on invalid capability values
cap_set_flag() skipped any entry of the values array that was negative
or >= __CAP_MAXBITS, logged it only in debug builds, and still
returned 0. A caller that computed a bad capability number and asked
to CAP_CLEAR it was told the bit had been cleared when nothing had
changed. Mixed arrays were applied partially and reported as success.

Validate every value before touching the set. If any value is out of
range, set errno to EINVAL, return -1 and leave the capability state
unchanged.

Also:
- reject a NULL values array with EINVAL instead of dereferencing it;
- drop the "no_values < __CAP_MAXBITS" limit. It rejected valid
  arrays of 64 or more entries (for example with repeated values),
  while out-of-range entries were the real hazard and are now
  checked individually.

All in-tree callers pass a single valid constant, so they are not
affected. Callers that relied on invalid values being silently
ignored will now see EINVAL.

Document the new failure mode in cap_clear(3).

Verified with a small program against the rebuilt library:
  CLEAR -1, CLEAR 64, SET 1000  -> -1, errno=EINVAL (was 0)
  {CAP_CHOWN, -5} SET           -> -1, CAP_CHOWN stays unset (was set)
  SET CAP_KILL                  -> 0, CAP_KILL set
  NULL array                    -> -1, errno=EINVAL
"make test" in libcap/ completes with no failures.

Signed-off-by: Mohammed Mustafa <mustafa@medios.digiscrypt.com>
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2026-11-27 08:13:33 -08:00
cap Fix cap.validatePA(). 2026-11-15 08:34:24 -08:00
contrib Make su signal flag signal-safe 2026-11-12 05:54:10 -08:00
doc fix: make cap_set_flag fail on invalid capability values 2026-11-27 08:13:33 -08:00
go Minor style adjustment for human readability. 2026-06-19 06:18:13 -07:00
goapps Up the release version to 2.78 2026-04-05 08:31:36 -07:00
kdebug Make the kdebug test use the terminal output. 2025-05-06 23:17:09 -07:00
libcap fix: make cap_set_flag fail on invalid capability values 2026-11-27 08:13:33 -08:00
pam_cap Drop linux/ headers for standard ones. 2025-03-02 10:25:00 -08:00
progs capsh: pass the live environ to execve() and cap_launch() 2026-11-23 08:36:53 -08:00
psx Cast getdents64() return as ssize_t and not the unsigned size_t. 2026-06-16 05:54:28 -07:00
tests Fix a test's link order to be -lpsx (with flags) before -lcap. 2026-04-24 20:57:45 -07:00
.gitignore Rewrite libpsx to work with native linux threads. 2024-10-25 22:58:46 -07:00
CHANGELOG Update the CHANGELOG file to point to current locations. 2020-06-02 19:45:10 -07:00
distcheck.sh Linux 5.7 supports CAP_PERFMON 2020-06-02 20:56:01 -07:00
gomods.sh Add a handy update script for the various go.mod files. 2021-05-24 11:50:15 -07:00
License Reviewed license information and adde SPDX ids. 2022-10-19 19:05:11 -07:00
Make.Rules Up the release version to 2.78 2026-04-05 08:31:36 -07:00
Makefile Tighten up the comments for the various signed tags moving forward. 2024-10-26 20:53:42 -07:00
pgp.keys.asc Add a more modern signing key. 2024-10-25 21:50:53 -07:00
README Fix typos. 2021-08-14 11:03:27 -07:00
template.c Prepare for 1.95 release. 2007-07-10 22:38:22 -07:00

This is a library for getting and setting POSIX.1e (formerly POSIX 6)
draft 15 capabilities.

Natively supported languages are C/C++ and Go.

This library would not have been possible without the help of 

    Aleph1, Roland Buresund and Andrew Main, Alexander Kjeldaas.

More information on capabilities in the Linux kernel, links to the
official git repository for libcap, release notes and how to report
bugs can be found at:

    http://sites.google.com/site/fullycapable/

The primary upstream git repository is this one:

    https://git.kernel.org/pub/scm/libs/libcap/libcap.git/

# BUILDING AND INSTALLATION

    $ make

       builds the library and the programs that are expected to work
       on your system. For example, if you have Linux-PAM installed,
       pam_cap is built. A golang installation is required to build
       the Go packages.

    $ make test

       runs all of the tests not requiring privilege

    $ make sudotest

       runs all of the tests including those that require privilege.

    $ sudo make install

       default installs the library libcap.XX.Y in /lib[64]/
       the binaries in /sbin/
       the header files in /usr/include
       the {libcap,libpsx}.pc files in /usr/lib[64]/pkgconfig
       the Go packages (if built) under /usr/share/gocode/src

For some example C programs look in the progs/ directory.
Specifically, capsh, getpcaps, setcap and getcap. There are some C
tests in the tests/ directory.

Go example programs are to be found in the goapps/ directory. There
are also some more complicated integration tests in the go/ directory.

There are also some oddball experimental things in the contrib/
directory, but they are mostly curiosities.

Cheers

Andrew G. Morgan <morgan@kernel.org>