Manpage of CAPABILITIES
CAPABILITIESSection: Linux Programmer's Manual (7)
NAMEcapabilities - overview of Linux capabilities
DESCRIPTIONFor the purpose of performing permission checks, traditional UNIX implementations distinguish two categories of processes: privilegedprocesses (whose effective user ID is 0, referred to as superuser or root), and unprivilegedprocesses (whose effective UID is nonzero). 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 capabilities, which can be independently enabled and disabled. Capabilities are a per-thread attribute.
Capabilities listThe following list shows the capabilities implemented on Linux, and the operations or behaviors that each capability permits:
- 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_READ (since Linux 3.16)
- Allow reading the audit log via a multicast netlink socket.
- CAP_AUDIT_WRITE (since Linux 2.6.11)
- Write records to kernel auditing log.
- CAP_BLOCK_SUSPEND (since Linux 3.5)
- Employ features that can block system suspend (epoll(7) EPOLLWAKEUP, /proc/sys/wake_lock).
- Make arbitrary changes to file UIDs and GIDs (see chown(2)).
- Bypass file read, write, and execute permission checks. (DAC is an abbreviation of "discretionary access control".)
- Bypass permission checks on operations that normally require the filesystem UID of the process to match the UID of the file (e.g., chmod(2), utime(2)), excluding those operations covered by CAP_DAC_OVERRIDEand CAP_DAC_READ_SEARCH;
- set inode flags (see ioctl_iflags(2)) on arbitrary files;
- set Access Control Lists (ACLs) on arbitrary files;
- ignore directory sticky bit on file deletion;
- specify O_NOATIMEfor arbitrary files in open(2) and fcntl(2).
- Don't clear set-user-ID and set-group-ID mode bits when a file is modified;
- set the set-group-ID bit for a file whose GID does not match the filesystem or any of the supplementary GIDs of the calling process.
- Lock memory (mlock(2), mlockall(2), mmap(2), shmctl(2)).
- Bypass permission checks for operations on System V IPC objects.
- Bypass permission checks for sending signals (see kill(2)). This includes use of the ioctl(2) KDSIGACCEPToperation.
- CAP_LEASE (since Linux 2.4)
- Establish leases on arbitrary files (see fcntl(2)).
- Set the FS_APPEND_FLand FS_IMMUTABLE_FLinode flags (see ioctl_iflags(2)).
- CAP_MAC_ADMIN (since Linux 2.6.25)
- Allow MAC configuration or state changes. Implemented for the Smack Linux Security Module (LSM).
- CAP_MAC_OVERRIDE (since Linux 2.6.25)
- Override Mandatory Access Control (MAC). Implemented for the Smack LSM.
- CAP_MKNOD (since Linux 2.4)
- Create special files using mknod(2).
- Perform various network-related operations:
- interface configuration;
- administration of IP firewall, masquerading, and accounting;
- modify routing tables;
- bind to any address for transparent proxying;
- set type-of-service (TOS)
- clear driver statistics;
- set promiscuous mode;
- enabling multicasting;
- use setsockopt(2) to set the following socket options: SO_DEBUG, SO_MARK, SO_PRIORITY(for a priority outside the range 0 to 6), SO_RCVBUFFORCE, and SO_SNDBUFFORCE.
- Bind a socket to Internet domain privileged ports (port numbers less than 1024).
- (Unused) Make socket broadcasts, and listen to multicasts.
- Use RAW and PACKET sockets;
- bind to any address for transparent proxying.
- Make arbitrary manipulations of process GIDs and supplementary GID list;
- forge GID when passing socket credentials via UNIX domain sockets;
- write a group ID mapping in a user namespace (see user_namespaces(7)).
- CAP_SETFCAP (since Linux 2.6.24)
- Set file capabilities.
- If file capabilities are not supported: grant or remove any capability in the caller's permitted capability set to or from any other process. (This property of CAP_SETPCAPis not available when the kernel is configured to support file capabilities, since CAP_SETPCAPhas entirely different semantics for such kernels.)
- If file capabilities are supported: add any capability from the calling thread's bounding set to its inheritable set; drop capabilities from the bounding set (via prctl(2) PR_CAPBSET_DROP); make changes to the securebitsflags.
- Note: this capability is overloaded; see Notes to kernel developers, below.
- Perform a range of system administration operations including: quotactl(2), mount(2), umount(2), swapon(2), swapoff(2), sethostname(2), and setdomainname(2);
- perform privileged syslog(2) operations (since Linux 2.6.37, CAP_SYSLOGshould be used to permit such operations);
- perform VM86_REQUEST_IRQvm86(2) command;
- perform IPC_SETand IPC_RMIDoperations on arbitrary System V IPC objects;
- override RLIMIT_NPROCresource limit;
- perform operations on trustedand securityExtended Attributes (see xattr(7));
- use lookup_dcookie(2);
- use ioprio_set(2) to assign IOPRIO_CLASS_RTand (before Linux 2.6.25) IOPRIO_CLASS_IDLEI/O scheduling classes;
- forge PID when passing socket credentials via UNIX domain sockets;
- exceed /proc/sys/fs/file-max, the system-wide limit on the number of open files, in system calls that open files (e.g., accept(2), execve(2), open(2), pipe(2));
- employ CLONE_*flags that create new namespaces with clone(2) and unshare(2) (but, since Linux 3.8, creating user namespaces does not require any capability);
- call perf_event_open(2);
- access privileged perfevent information;
- call setns(2) (requires CAP_SYS_ADMINin the targetnamespace);
- call fanotify_init(2);
- call bpf(2);
- perform privileged KEYCTL_CHOWNand KEYCTL_SETPERMkeyctl(2) operations;
- use ptrace(2) PTRACE_SECCOMP_GET_FILTERto dump a tracees seccomp filters;
- perform madvise(2) MADV_HWPOISONoperation;
- employ the TIOCSTIioctl(2) to insert characters into the input queue of a terminal other than the caller's controlling terminal;
- employ the obsolete nfsservctl(2) system call;
- employ the obsolete bdflush(2) system call;
- perform various privileged block-device ioctl(2) operations;
- perform various privileged filesystem ioctl(2) operations;
- perform privileged ioctl(2) operations on the /dev/randomdevice (see random(4));
- install a seccomp(2) filter without first having to set the no_new_privsthread attribute;
- modify allow/deny rules for device control groups;
- employ the ptrace(2) PTRACE_SECCOMP_GET_FILTERoperation to dump tracee's seccomp filters;
- employ the ptrace(2) PTRACE_SETOPTIONSoperation to suspend the tracee's seccomp protections (i.e., the PTRACE_O_SUSPEND_SECCOMPflag).
- perform administrative operations on many device drivers.
- Use reboot(2) and kexec_load(2).
- Use chroot(2).
- Raise process nice value (nice(2), setpriority(2)) and change the nice value for arbitrary processes;
- set real-time scheduling policies for calling process, and set scheduling policies and priorities for arbitrary processes (sched_setscheduler(2), sched_setparam(2), shed_setattr(2));
- set CPU affinity for arbitrary processes (sched_setaffinity(2));
- set I/O scheduling class and priority for arbitrary processes (ioprio_set(2));
- apply migrate_pages(2) to arbitrary processes and allow processes to be migrated to arbitrary nodes;
- apply move_pages(2) to arbitrary processes;
- use the MPOL_MF_MOVE_ALLflag with mbind(2) and move_pages(2).
- Use acct(2).
- Perform I/O port operations (iopl(2) and ioperm(2));
- access /proc/kcore;
- employ the FIBMAPioctl(2) operation;
- open devices for accessing x86 model-specific registers (MSRs, see msr(4));
- update /proc/sys/vm/mmap_min_addr;
- create memory mappings at addresses below the value specified by /proc/sys/vm/mmap_min_addr;
- map files in /proc/bus/pci;
- open /dev/memand /dev/kmem;
- perform various SCSI device commands;
- perform certain operations on hpsa(4) and cciss(4) devices;
- perform a range of device-specific operations on other devices.
- Use reserved space on ext2 filesystems;
- make ioctl(2) calls controlling ext3 journaling;
- override disk quota limits;
- increase resource limits (see setrlimit(2));
- override RLIMIT_NPROCresource limit;
- override maximum number of consoles on console allocation;
- override maximum number of keymaps;
- allow more than 64hz interrupts from the real-time clock;
- raise msg_qbyteslimit for a System V message queue above the limit in /proc/sys/kernel/msgmnb(see msgop(2) and msgctl(2));
- allow the RLIMIT_NOFILEresource limit on the number of "in-flight" file descriptors to be bypassed when passing file descriptors to another process via a UNIX domain socket (see unix(7));
- override the /proc/sys/fs/pipe-size-maxlimit when setting the capacity of a pipe using the F_SETPIPE_SZfcntl(2) command.
- use F_SETPIPE_SZto increase the capacity of a pipe above the limit specified by /proc/sys/fs/pipe-max-size;
- override /proc/sys/fs/mqueue/queues_maxlimit when creating POSIX message queues (see mq_overview(7));
- employ the prctl(2) PR_SET_MMoperation;
- set /proc/[pid]/oom_score_adjto a value lower than the value last set by a process with CAP_SYS_RESOURCE.
- Set system clock (settimeofday(2), stime(2), adjtimex(2)); set real-time (hardware) clock.
- Use vhangup(2); employ various privileged ioctl(2) operations on virtual terminals.
- CAP_SYSLOG (since Linux 2.6.37)
- CAP_WAKE_ALARM (since Linux 3.0)
- Trigger something that will wake up the system (set CLOCK_REALTIME_ALARMand CLOCK_BOOTTIME_ALARMtimers).
Past and current implementationA full implementation of capabilities requires that:
- For all privileged operations, the kernel must check whether the thread has the required capability in its effective set.
- The kernel must provide system calls allowing a thread's capability sets to be changed and retrieved.
- The filesystem must support attaching capabilities to an executable file, so that a process gains those capabilities when the file is executed.
Notes to kernel developersWhen adding a new kernel feature that should be governed by a capability, consider the following points.
- The goal of capabilities is divide the power of superuser into pieces, such that if a program that has one or more capabilities is compromised, its power to do damage to the system would be less than the same program running with root privilege.
- You have the choice of either creating a new capability for your new feature, or associating the feature with one of the existing capabilities. In order to keep the set of capabilities to a manageable size, the latter option is preferable, unless there are compelling reasons to take the former option. (There is also a technical limit: the size of capability sets is currently limited to 64 bits.)
- To determine which existing capability might best be associated with your new feature, review the list of capabilities above in order to find a "silo" into which your new feature best fits. One approach to take is to determine if there are other features requiring capabilities that will always be use along with the new feature. If the new feature is useless without these other features, you should use the same capability as the other features.
- Don'tchoose CAP_SYS_ADMINif you can possibly avoid it! A vast proportion of existing capability checks are associated with this capability (see the partial list above). It can plausibly be called "the new root", since on the one hand, it confers a wide range of powers, and on the other hand, its broad scope means that this is the capability that is required by many privileged programs. Don't make the problem worse. The only new features that should be associated with CAP_SYS_ADMINare ones that closelymatch existing uses in that silo.
- If you have determined that it really is necessary to create a new capability for your feature, don't make or name it as a "single-use" capability. Thus, for example, the addition of the highly specific CAP_PACCTwas probably a mistake. Instead, try to identify and name your new capability as a broader silo into which other related future use cases might fit.
Thread capability setsEach thread has three capability sets containing zero or more of the above capabilities:
- This is a limiting superset for the effective capabilities that the thread may assume. It is also a limiting superset for the capabilities that may be added to the inheritable set by a thread that does not have the CAP_SETPCAPcapability in its effective set.
- If a thread drops a capability from its permitted set, it can never reacquire that capability (unless it execve(2)s either a set-user-ID-root program, or a program whose associated file capabilities grant that capability).
- This is a set of capabilities preserved across an execve(2). Inheritable capabilities remain inheritable when executing any program, and inheritable capabilities are added to the permitted set when executing a program that has the corresponding bits set in the file inheritable set.
- Because inheritable capabilities are not generally preserved across execve(2) when running as a non-root user, applications that wish to run helper programs with elevated capabilities should consider using ambient capabilities, described below.
- This is the set of capabilities used by the kernel to perform permission checks for the thread.
- Ambient (since Linux 4.3):
- This is a set of capabilities that are preserved across an execve(2) of a program that is not privileged. The ambient capability set obeys the invariant that no capability can ever be ambient if it is not both permitted and inheritable.
- The ambient capability set can be directly modified using prctl(2). Ambient capabilities are automatically lowered if either of the corresponding permitted or inheritable capabilities is lowered.
- Executing a program that changes UID or GID due to the set-user-ID or set-group-ID bits or executing a program that has any file capabilities set will clear the ambient set. Ambient capabilities are added to the permitted set and assigned to the effective set when execve(2) is called.
Using capset(2), a thread may manipulate its own capability sets (see below).
Since Linux 3.2, the file /proc/sys/kernel/cap_last_capexposes the numerical value of the highest capability supported by the running kernel; this can be used to determine the highest bit that may be set in a capability set.
File capabilitiesSince kernel 2.6.24, the kernel supports associating capability sets with an executable file using setcap(8). The file capability sets are stored in an extended attribute (see setxattr(2)) named security.capability. Writing to this extended attribute requires the CAP_SETFCAPcapability. The file capability sets, in conjunction with the capability sets of the thread, determine the capabilities of a thread after an execve(2).
The three file capability sets are:
- Permitted (formerly known as forced):
- These capabilities are automatically permitted to the thread, regardless of the thread's inheritable capabilities.
- Inheritable (formerly known as allowed):
- This set is ANDed with the thread's inheritable set to determine which inheritable capabilities are enabled in the permitted set of the thread after the execve(2).
- This is not a set, but rather just a single bit. If this bit is set, then during an execve(2) all of the new permitted capabilities for the thread are also raised in the effective set. If this bit is not set, then after an execve(2), none of the new permitted capabilities is in the new effective set.
- Enabling the file effective capability bit implies that any file permitted or inheritable capability that causes a thread to acquire the corresponding permitted capability during an execve(2) (see the transformation rules described below) will also acquire that capability in its effective set. Therefore, when assigning capabilities to a file (setcap(8), cap_set_file(3), cap_set_fd(3)), if we specify the effective flag as being enabled for any capability, then the effective flag must also be specified as enabled for all other capabilities for which the corresponding permitted or inheritable flags is enabled.
Transformation of capabilities during execve()
During an execve(2), the kernel calculates the new capabilities of the process using the following algorithm:
P'(ambient) = (file is privileged) ? 0 : P(ambient)
P'(permitted) = (P(inheritable) & F(inheritable)) |
(F(permitted) & cap_bset) | P'(ambient)
P'(effective) = F(effective) ? P'(permitted) : P'(ambient)
P'(inheritable) = P(inheritable) [i.e., unchanged]
A privileged file is one that has capabilities or has the set-user-ID or set-group-ID bit set.
Note: the capability transitions described above may notbe performed (i.e., file capabilities may be ignored) for the same reasons that the set-user-ID and set-group-ID bits are ignored; see execve(2).
Note: according to the rules above, if a process with nonzero user IDs performs an execve(2) then any capabilities that are present in its permitted and effective sets will be cleared. For the treatment of capabilities when a process with a user ID of zero performs an execve(2), see below under Capabilities and execution of programs by root.
Safety checking for capability-dumb binariesA capability-dumb binary is an application that has been marked to have file capabilities, but has not been converted to use the libcap(3) API to manipulate its capabilities. (In other words, this is a traditional set-user-ID-root program that has been switched to use file capabilities, but whose code has not been modified to understand capabilities.) For such applications, the effective capability bit is set on the file, so that the file permitted capabilities are automatically enabled in the process effective set when executing the file. The kernel recognizes a file which has the effective capability bit set as capability-dumb for the purpose of the check described here.
When executing a capability-dumb binary, the kernel checks if the process obtained all permitted capabilities that were specified in the file permitted set, after the capability transformations described above have been performed. (The typical reason why this might notoccur is that the capability bounding set masked out some of the capabilities in the file permitted set.) If the process did not obtain the full set of file permitted capabilities, then execve(2) fails with the error EPERM. This prevents possible security risks that could arise when a capability-dumb application is executed with less privilege that it needs. Note that, by definition, the application could not itself recognize this problem, since it does not employ the libcap(3) API.
Capabilities and execution of programs by rootIn order to provide an all-powerful rootusing capability sets, during an execve(2):
- If a set-user-ID-root program is being executed, or the real or effective 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, or the effective user ID of the process is 0 (root) then the file effective bit is defined to be one (enabled).
The upshot of the above rules, combined with the capabilities transformations described above, is as follows:
- When a process execve(2)s a set-user-ID-root program, or when a process with an effective UID of 0 execve(2)s a program, it gains all capabilities in its permitted and effective capability sets, except those masked out by the capability bounding set.
- When a process with a real UID of 0 execve(2)s a program, it gains all capabilities in its permitted capability set, except those masked out by the capability bounding set.
Set-user-ID-root programs that have file capabilitiesExecuting a program that is both set-user-ID root and has file capabilities will cause the process to gain just the capabilities granted by the program (i.e., not all capabilities, as would occur when executing a set-user-ID-root program that does not have any associated file capabilities). Note that one can assign empty capability sets to a program file, and thus it is possible to create a set-user-ID-root program that changes the effective and saved set-user-ID of the process that executes the program to 0, but confers no capabilities to that process.
Capability bounding setThe capability bounding set is a security mechanism that can be used to limit the capabilities that can be gained during an execve(2). The bounding set is used in the following ways:
- During an execve(2), the capability bounding set is ANDed with the file permitted capability set, and the result of this operation is assigned to the thread's permitted capability set. The capability bounding set thus places a limit on the permitted capabilities that may be granted by an executable file.
- (Since Linux 2.6.25) The capability bounding set acts as a limiting superset for the capabilities that a thread can add to its inheritable set using capset(2). This means that if a capability is not in the bounding set, then a thread can't add this capability to its inheritable set, even if it was in its permitted capabilities, and thereby cannot have this capability preserved in its permitted set when it execve(2)s a file that has the capability in its inheritable set.
Note that the bounding set masks the file permitted capabilities, but not the inherited capabilities. If a thread maintains a capability in its inherited set that is not in its bounding set, then it can still gain that capability in its permitted set by executing a file that has the capability in its inherited set.
Depending on the kernel version, the capability bounding set is either a system-wide attribute, or a per-process attribute.
Capability bounding set prior to Linux 2.6.25
In kernels before 2.6.25, the capability bounding set is a system-wide attribute that affects all threads on the system. The bounding set is accessible via the file /proc/sys/kernel/cap-bound. (Confusingly, this bit mask parameter is expressed as a signed decimal number in /proc/sys/kernel/cap-bound.)
Only the initprocess may set capabilities in the capability bounding set; other than that, the superuser (more precisely: programs with the CAP_SYS_MODULEcapability) may only clear capabilities from this set.
On a standard system the capability bounding set always masks out the CAP_SETPCAPcapability. To remove this restriction (dangerous!), modify the definition of CAP_INIT_EFF_SETin include/linux/capability.hand rebuild the kernel.
The system-wide capability bounding set feature was added to Linux starting with kernel version 2.2.11.
Capability bounding set from Linux 2.6.25 onward
From Linux 2.6.25, the capability bounding setis a per-thread attribute. (There is no longer a system-wide capability bounding set.)
A thread may remove capabilities from its capability bounding set using the prctl(2) PR_CAPBSET_DROPoperation, provided it has the CAP_SETPCAPcapability. Once a capability has been dropped from the bounding set, it cannot be restored to that set. A thread can determine if a capability is in its bounding set using the prctl(2) PR_CAPBSET_READoperation.
Removing capabilities from the bounding set is supported only if file capabilities are compiled into the kernel. In kernels before Linux 2.6.33, file capabilities were an optional feature configurable via the CONFIG_SECURITY_FILE_CAPABILITIESoption. Since Linux 2.6.33, the configuration option has been removed and file capabilities are always part of the kernel. When file capabilities are compiled into the kernel, the initprocess (the ancestor of all processes) begins with a full bounding set. If file capabilities are not compiled into the kernel, then initbegins with a full bounding set minus CAP_SETPCAP, because this capability has a different meaning when there are no file capabilities.
Removing a capability from the bounding set does not remove it from the thread's inherited set. However it does prevent the capability from being added back into the thread's inherited set in the future.
Effect of user ID changes on capabilitiesTo preserve the traditional semantics for transitions between 0 and nonzero 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 filesystem user IDs (using setuid(2), setresuid(2), or similar):
- If one or more of the real, effective or saved set user IDs was ly 0, and as a result of the UID changes all of these IDs have a nonzero value, then all capabilities are cleared from the permitted and effective capability sets.
- If the effective user ID is changed from 0 to nonzero, then all capabilities are cleared from the effective set.
- If the effective user ID is changed from nonzero to 0, then the permitted set is copied to the effective set.
- If the filesystem user ID is changed from 0 to nonzero (see setfsuid(2)), then the following capabilities are cleared from the effective set: CAP_CHOWN, CAP_DAC_OVERRIDE, CAP_DAC_READ_SEARCH, CAP_FOWNER, CAP_FSETID, CAP_LINUX_IMMUTABLE(since Linux 2.6.30), CAP_MAC_OVERRIDE, and CAP_MKNOD(since Linux 2.6.30). If the filesystem UID is changed from nonzero 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 nonzero values, it can do so using the prctl(2) PR_SET_KEEPCAPSoperation or the SECBIT_KEEP_CAPSsecurebits flag described below.
Programmatically adjusting capability setsA thread can retrieve and change its capability sets using the capget(2) and capset(2) system calls. However, the use of cap_get_proc(3) and cap_set_proc(3), both provided in the libcappackage, is preferred for this purpose. The following rules govern changes to the thread capability sets:
- If the caller does not have the CAP_SETPCAPcapability, the new inheritable set must be a subset of the combination of the existing inheritable and permitted sets.
- (Since Linux 2.6.25) The new inheritable set must be a subset of the combination of the existing inheritable set and the capability bounding set.
- The new permitted set must be a subset of the existing permitted set (i.e., it is not possible to acquire permitted capabilities that the thread does not currently have).
- The new effective set must be a subset of the new permitted set.
The securebits flags: establishing a capabilities-only environmentStarting with kernel 2.6.26, and with a kernel in which file capabilities are enabled, Linux implements a set of per-thread securebitsflags that can be used to disable special handling of capabilities for UID 0 (root). These flags are as follows:
- Setting this flag allows a thread that has one or more 0 UIDs to retain its capabilities when it switches all of its UIDs to a nonzero value. If this flag is not set, then such a UID switch causes the thread to lose all capabilities. This flag is always cleared on an execve(2). (This flag provides the same functionality as the older prctl(2) PR_SET_KEEPCAPSoperation.)
- Setting this flag stops the kernel from adjusting capability sets when the thread's effective and filesystem UIDs are switched between zero and nonzero values. (See the subsection Effect of user ID changes on capabilities.)
- If this bit is set, then the kernel does not grant capabilities when a set-user-ID-root program is executed, or when a process with an effective or real UID of 0 calls execve(2). (See the subsection Capabilities and execution of programs by root.)
- Setting this flag disallows raising ambient capabilities via the prctl(2) PR_CAP_AMBIENT_RAISEoperation.
Each of the above "base" flags has a companion "locked" flag. Setting any of the "locked" flags is irreversible, and has the effect of preventing further changes to the corresponding "base" flag. The locked flags are: SECBIT_KEEP_CAPS_LOCKED, SECBIT_NO_SETUID_FIXUP_LOCKED, SECBIT_NOROOT_LOCKED, and SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED.
The securebitsflags can be modified and retrieved using the prctl(2) PR_SET_SECUREBITSand PR_GET_SECUREBITSoperations. The CAP_SETPCAPcapability is required to modify the flags.
The securebitsflags are inherited by child processes. During an execve(2), all of the flags are preserved, except SECBIT_KEEP_CAPSwhich is always cleared.
An application can use the following call to lock itself, and all of its descendants, into an environment where the only way of gaining capabilities is by executing a program with associated file capabilities:
/* SECBIT_KEEP_CAPS off */
/* Setting/locking SECURE_NO_CAP_AMBIENT_RAISE
is not required */
Interaction with user namespacesFor a discussion of the interaction of capabilities and user namespaces, see user_namespaces(7).
NOTESFrom kernel 2.5.27 to kernel 2.6.26, capabilities were an optional kernel component, and could be enabled/disabled via the CONFIG_SECURITY_CAPABILITIESkernel configuration option.
The /proc/[pid]/task/TID/statusfile can be used to view the capability sets of a thread. The /proc/[pid]/statusfile shows the capability sets of a process's main thread. Before Linux 3.8, nonexistent capabilities were shown as being enabled (1) in these sets. Since Linux 3.8, all nonexistent capabilities (above CAP_LAST_CAP) are shown as disabled (0).
libcappackage provides a suite of routines for setting and
getting capabilities that is more comfortable and less likely
to change than the interface provided by
This package also provides the
It can be found at
Before kernel 2.6.24, and from kernel 2.6.24 to kernel 2.6.32 if file capabilities are not enabled, a thread with the CAP_SETPCAPcapability can manipulate the capabilities of threads other than itself. However, this is only theoretically possible, since no thread ever has CAP_SETPCAPin either of these cases:
- In the pre-2.6.25 implementation the system-wide capability bounding set, /proc/sys/kernel/cap-bound, always masks out this capability, and this can not be changed without modifying the kernel source and rebuilding.
- If file capabilities are disabled in the current implementation, then initstarts out with this capability removed from its per-process bounding set, and that bounding set is inherited by all other processes created on the system.
SEE ALSOcapsh(1), setpriv(1), prctl(2), setfsuid(2), cap_clear(3), cap_copy_ext(3), cap_from_text(3), cap_get_file(3), cap_get_proc(3), cap_init(3), capgetp(3), capsetp(3), libcap(3), proc(5), credentials(7), pthreads(7), user_namespaces(7), filecap(8), getcap(8), netcap(8), pscap(8), setcap(8)
include/linux/capability.hin the Linux kernel source tree
- Capabilities list
- Past and current implementation
- Notes to kernel developers
- Thread capability sets
- File capabilities
- Transformation of capabilities during execve()
- Safety checking for capability-dumb binaries
- Capabilities and execution of programs by root
- Set-user-ID-root programs that have file capabilities
- Capability bounding set
- Effect of user ID changes on capabilities
- Programmatically adjusting capability sets
- The securebits flags: establishing a capabilities-only environment
- Interaction with user namespaces
- CONFORMING TO
- SEE ALSO
This document was created by man2html, using the manual pages.
Time: 19:53:57 GMT, October 26, 2017 Click Here!