Section: Linux Programmer's Manual (7)
Return to Main Contents
capabilities - overview of Linux capabilities
For the purpose of performing permission checks,
traditional Unix implementations distinguish two categories of processes:
processes (whose effective user ID is 0, referred to as superuser or root),
processes (whose effective UID is non-zero).
Privileged processes bypass all kernel permission checks,
while unprivileged processes are subject to full permission
checking based on the process's credentials
(usually: effective UID, effective GID, and supplementary group list).
Starting with kernel 2.2, Linux divides the privileges traditionally
associated with superuser into distinct units, known as
which can be independently enabled and disabled.
Capabilities are a per-thread attribute.
As at Linux 2.6.14, the following capabilities are implemented:
- CAP_AUDIT_CONTROL (since Linux 2.6.11)
Enable and disable kernel auditing; change auditing filter rules;
retrieve auditing status and filtering rules.
- CAP_AUDIT_WRITE (since Linux 2.6.11)
Allow records to be written to kernel auditing log.
Allow arbitrary changes to file UIDs and GIDs (see
Bypass file read, write, and execute permission checks.
(DAC = "discretionary access control".)
Bypass file read permission checks and
directory read and execute permission checks.
Bypass permission checks on operations that normally
require the file system UID of the process to match the UID of
the file (e.g.,
excluding those operations covered by the
set extended file attributes (see
on arbitrary files;
set Access Control Lists (ACLs) on arbitrary files;
ignore directory sticky bit on file deletion;
for arbitrary files in
Don't clear set-user-ID and set-group-ID bits when a file is modified;
permit setting of the set-group-ID bit for a file whose GID does not match
the file system or any of the supplementary GIDs of the calling process.
Permit memory locking
Bypass permission checks for operations on System V IPC objects.
Bypass permission checks for sending signals (see
This includes use of the KDSIGACCEPT ioctl.
(Linux 2.4 onwards) Allow file leases to be established on
arbitrary files (see
Allow setting of the
extended file attributes (see
(Linux 2.4 onwards)
Allow creation of special files using
Allow various network-related operations
(e.g., setting privileged socket options,
enabling multicasting, interface configuration,
modifying routing tables).
Allow binding to Internet domain reserved socket ports
(port numbers less than 1024).
(Unused) Allow socket broadcasting, and listening multicasts.
Permit use of RAW and PACKET sockets.
Allow arbitrary manipulations of process GIDs and supplementary GID list;
allow forged GID when passing socket credentials via Unix domain sockets.
Grant or remove any capability in the caller's
permitted capability set to or from any other process.
Allow arbitrary manipulations of process UIDs
allow forged UID when passing socket credentials via Unix domain sockets.
Permit a range of system administration operations including:
operations on arbitrary System V IPC objects;
perform operations on
Extended Attributes (see
I/O scheduling classes;
allow forged UID when passing socket credentials;
the system-wide limit on the number of open files,
in system calls that open files (e.g.,
without this capability these system calls will fail with the error
if this limit is encountered);
Permit calls to
Permit calls to
Allow loading and unloading of kernel modules;
allow modifications to capability bounding set (see
Allow raising process nice value
and changing of the nice value for arbitrary processes;
allow setting of real-time scheduling policies for calling process,
and setting scheduling policies and priorities for arbitrary processes
set CPU affinity for arbitrary processes
set I/O scheduling class and priority for arbitrary processes
to be applied to arbitrary processes and allow processes
to be migrated to arbitrary nodes;
to be applied to arbitrary processes;
Permit calls to
Allow arbitrary processes to be traced using
Permit I/O port operations
Permit: use of reserved space on ext2 file systems;
calls controlling ext3 journaling;
disk quota limits to be overridden;
resource limits to be increased (see
resource limit to be overridden;
limit for a message queue to be
raised above the limit in
Allow modification of system clock
allow modification of real-time (hardware) clock
Permit calls to
Each thread has three capability sets containing zero or more
of the above capabilities:
the capabilities used by the kernel to
perform permission checks for the thread.
the capabilities that the thread may assume
(i.e., a limiting superset for the effective and inheritable sets).
If a thread drops a capability from its permitted set,
it can never re-acquire that capability (unless it
a set-user-ID-root program).
the capabilities preserved across an
A child created via
inherits copies of its parent's capability sets.
See below for a discussion of the treatment of capabilities during
a thread may manipulate its own capability sets, or, if it has the
capability, those of a thread in another process.
Capability bounding set
When a program is execed, the permitted and effective capabilities
are ANDed with the current value of the so-called
capability bounding set,
defined in the file
This parameter can be used to place a system-wide limit on the
capabilities granted to all subsequently executed programs.
(Confusingly, this bit mask parameter is expressed as a
signed decimal number in
process may set bits in the capability bounding set;
other than that, the superuser may only clear bits in this set.
On a standard system the capability bounding set always masks out the
To remove this restriction (dangerous!), modify the definition of
and rebuild the kernel.
The capability bounding set feature was added to Linux starting with
kernel version 2.2.11.
Current and Future Implementation
A full implementation of capabilities requires:
that the kernel provide
system calls allowing a thread's capability sets to
be changed and retrieved.
file system support for attaching capabilities to an executable file,
so that a process gains those capabilities when the file is execed.
As at Linux 2.6.14, only the first two of these requirements are met.
Eventually, it should be possible to associate three
capability sets with an executable file, which,
in conjunction with the capability sets of the thread,
will determine the capabilities of a thread after an
- Inheritable (formerly known as allowed):
this set is ANDed with the thread's inheritable set to determine which
inheritable capabilities are permitted to the thread after the
- Permitted (formerly known as forced):
the capabilities automatically permitted to the thread,
regardless of the thread's inheritable capabilities.
those capabilities in the thread's new permitted set are
also to be set in the new effective set.
(F(effective) would normally be either all zeroes or all ones.)
In the meantime, since the current implementation does not
support file capability sets, during an
All three file capability sets are initially assumed to be cleared.
If a set-user-ID-root program is being execed,
or the real user ID of the process is 0 (root)
then the file inheritable and permitted sets are defined to be all ones
(i.e., all capabilities enabled).
If a set-user-ID-root program is being executed,
then the file effective set is defined to be all ones.
Transformation of Capabilities During exec()
the kernel calculates the new capabilities of
the process using the following algorithm:
P'(permitted) = (P(inheritable) & F(inheritable)) |
(F(permitted) & cap_bset)
P'(effective) = P'(permitted) & F(effective)
P'(inheritable) = P(inheritable) [i.e., unchanged]
denotes the value of a thread capability set before the
denotes the value of a capability set after the
denotes a file capability set
is the value of the capability bounding set.
In the current implementation, the upshot of this algorithm is that
when a process
a set-user-ID-root program, or when a process with an effective UID of 0
it gains all capabilities in its permitted and effective capability sets,
except those masked out by the capability bounding set (i.e.,
This provides semantics that are the same as those provided by
traditional Unix systems.
Effect of User ID Changes on Capabilities
To preserve the traditional semantics for transitions between
0 and non-zero user IDs,
the kernel makes the following changes to a thread's capability
sets on changes to the thread's real, effective, saved set,
and file system user IDs (using
If one or more of the real, effective or saved set user IDs
was previously 0, and as a result of the UID changes all of these IDs
have a non-zero value,
then all capabilities are cleared from the permitted and effective
If the effective user ID is changed from 0 to non-zero,
then all capabilities are cleared from the effective set.
If the effective user ID is changed from non-zero to 0,
then the permitted set is copied to the effective set.
If the file system user ID is changed from 0 to non-zero (see
then the following capabilities are cleared from the effective set:
If the file system UID is changed from non-zero to 0,
then any of these capabilities that are enabled in the permitted set
are enabled in the effective set.
If a thread that has a 0 value for one or more of its user IDs wants
to prevent its permitted capability set being cleared when it resets
all of its user IDs to non-zero values, it can do so using the
package provides a suite of routines for setting and
getting capabilities that is more comfortable and less likely
to change than the interface provided by
No standards govern capabilities, but the Linux capability implementation
is based on the withdrawn POSIX.1e draft standard.
There is as yet no file system support allowing capabilities to be
associated with executable files.
- Capabilities List
- Capability Sets
- Capability bounding set
- Current and Future Implementation
- Transformation of Capabilities During exec()
- Effect of User ID Changes on Capabilities
- CONFORMING TO
- SEE ALSO
linux.jgfs.net manual pages