]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/capabilities.7
fanotify.7: Minor fixes after feedback from Matthew Bobrowski
[thirdparty/man-pages.git] / man7 / capabilities.7
CommitLineData
c11b1abf 1.\" Copyright (c) 2002 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
12.\"
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
10d76543
MK
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
fea681da
MK
20.\"
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" 6 Aug 2002 - Initial Creation
c11b1abf
MK
26.\" Modified 2003-05-23, Michael Kerrisk, <mtk.manpages@gmail.com>
27.\" Modified 2004-05-27, Michael Kerrisk, <mtk.manpages@gmail.com>
1c1e15ed 28.\" 2004-12-08, mtk Added O_NOATIME for CAP_FOWNER
5eaee3d9 29.\" 2005-08-16, mtk, Added CAP_AUDIT_CONTROL and CAP_AUDIT_WRITE
c8e68512
MK
30.\" 2008-07-15, Serge Hallyn <serue@us.bbm.com>
31.\" Document file capabilities, per-process capability
32.\" bounding set, changed semantics for CAP_SETPCAP,
33.\" and other changes in 2.6.2[45].
34.\" Add CAP_MAC_ADMIN, CAP_MAC_OVERRIDE, CAP_SETFCAP.
35.\" 2008-07-15, mtk
36.\" Add text describing circumstances in which CAP_SETPCAP
37.\" (theoretically) permits a thread to change the
38.\" capability sets of another thread.
39.\" Add section describing rules for programmatically
40.\" adjusting thread capability sets.
41.\" Describe rationale for capability bounding set.
42.\" Document "securebits" flags.
43.\" Add text noting that if we set the effective flag for one file
44.\" capability, then we must also set the effective flag for all
45.\" other capabilities where the permitted or inheritable bit is set.
bfb730f9 46.\" 2011-09-07, mtk/Serge hallyn: Add CAP_SYSLOG
5eaee3d9 47.\"
9ba01802 48.TH CAPABILITIES 7 2019-03-06 "Linux" "Linux Programmer's Manual"
fea681da
MK
49.SH NAME
50capabilities \- overview of Linux capabilities
51.SH DESCRIPTION
fea681da 52For the purpose of performing permission checks,
008f1ecc 53traditional UNIX implementations distinguish two categories of processes:
fea681da
MK
54.I privileged
55processes (whose effective user ID is 0, referred to as superuser or root),
56and
57.I unprivileged
c7094399 58processes (whose effective UID is nonzero).
fea681da
MK
59Privileged processes bypass all kernel permission checks,
60while unprivileged processes are subject to full permission
61checking based on the process's credentials
62(usually: effective UID, effective GID, and supplementary group list).
ade303d7 63.PP
c13182ef
MK
64Starting with kernel 2.2, Linux divides the privileges traditionally
65associated with superuser into distinct units, known as
fea681da 66.IR capabilities ,
3dfe7e0d 67which can be independently enabled and disabled.
cf7a13d4 68Capabilities are a per-thread attribute.
c8e68512 69.\"
c634028a 70.SS Capabilities list
c8e68512
MK
71The following list shows the capabilities implemented on Linux,
72and the operations or behaviors that each capability permits:
fea681da 73.TP
45286787 74.BR CAP_AUDIT_CONTROL " (since Linux 2.6.11)"
5eaee3d9
MK
75Enable and disable kernel auditing; change auditing filter rules;
76retrieve auditing status and filtering rules.
77.TP
c81cea2c
MK
78.BR CAP_AUDIT_READ " (since Linux 3.16)"
79.\" commit a29b694aa1739f9d76538e34ae25524f9c549d59
80.\" commit 3a101b8de0d39403b2c7e5c23fd0b005668acf48
81Allow reading the audit log via a multicast netlink socket.
82.TP
45286787 83.BR CAP_AUDIT_WRITE " (since Linux 2.6.11)"
c8e68512 84Write records to kernel auditing log.
dd61e8a8 85.\" FIXME Add FAN_ENABLE_AUDIT
5eaee3d9 86.TP
9339d749
MK
87.BR CAP_BLOCK_SUSPEND " (since Linux 3.5)"
88Employ features that can block system suspend
89.RB ( epoll (7)
90.BR EPOLLWAKEUP ,
91.IR /proc/sys/wake_lock ).
92.TP
fea681da 93.B CAP_CHOWN
c8e68512 94Make arbitrary changes to file UIDs and GIDs (see
fea681da
MK
95.BR chown (2)).
96.TP
97.B CAP_DAC_OVERRIDE
98Bypass file read, write, and execute permission checks.
c8e68512 99(DAC is an abbreviation of "discretionary access control".)
fea681da
MK
100.TP
101.B CAP_DAC_READ_SEARCH
a537062e
MK
102.PD 0
103.RS
104.IP * 2
fea681da 105Bypass file read permission checks and
a537062e
MK
106directory read and execute permission checks;
107.IP *
3bbab71a 108invoke
24ee13df
MK
109.BR open_by_handle_at (2);
110.IP *
111use the
112.BR linkat (2)
113.B AT_EMPTY_PATH
114flag to create a link to a file referred to by a file descriptor.
a537062e
MK
115.RE
116.PD
fea681da
MK
117.TP
118.B CAP_FOWNER
c8e68512
MK
119.PD 0
120.RS
121.IP * 2
fea681da 122Bypass permission checks on operations that normally
9ee4a2b6 123require the filesystem UID of the process to match the UID of
fea681da
MK
124the file (e.g.,
125.BR chmod (2),
126.BR utime (2)),
c8e68512 127excluding those operations covered by
fea681da
MK
128.B CAP_DAC_OVERRIDE
129and
130.BR CAP_DAC_READ_SEARCH ;
c8e68512 131.IP *
1dc9bca6
MK
132set inode flags (see
133.BR ioctl_iflags (2))
fea681da 134on arbitrary files;
c8e68512 135.IP *
fea681da 136set Access Control Lists (ACLs) on arbitrary files;
c8e68512 137.IP *
1c1e15ed 138ignore directory sticky bit on file deletion;
c8e68512 139.IP *
1c1e15ed
MK
140specify
141.B O_NOATIME
142for arbitrary files in
143.BR open (2)
144and
145.BR fcntl (2).
c8e68512
MK
146.RE
147.PD
fea681da
MK
148.TP
149.B CAP_FSETID
3bbab71a
MK
150.PD 0
151.RS
152.IP * 2
ed948c28 153Don't clear set-user-ID and set-group-ID mode
c8e68512 154bits when a file is modified;
3bbab71a 155.IP *
c8e68512 156set the set-group-ID bit for a file whose GID does not match
9ee4a2b6 157the filesystem or any of the supplementary GIDs of the calling process.
3bbab71a
MK
158.RE
159.PD
fea681da
MK
160.TP
161.B CAP_IPC_LOCK
bea08fec 162.\" FIXME . As at Linux 3.2, there are some strange uses of this capability
46c73a44 163.\" in other places; they probably should be replaced with something else.
c8e68512 164Lock memory
fea681da
MK
165.RB ( mlock (2),
166.BR mlockall (2),
167.BR mmap (2),
168.BR shmctl (2)).
169.TP
170.B CAP_IPC_OWNER
171Bypass permission checks for operations on System V IPC objects.
172.TP
173.B CAP_KILL
174Bypass permission checks for sending signals (see
175.BR kill (2)).
097585ed 176This includes use of the
c8e68512 177.BR ioctl (2)
097585ed 178.B KDSIGACCEPT
c8e68512 179operation.
bea08fec 180.\" FIXME . CAP_KILL also has an effect for threads + setting child
a7c1e564
MK
181.\" termination signal to other than SIGCHLD: without this
182.\" capability, the termination signal reverts to SIGCHLD
c13182ef 183.\" if the child does an exec(). What is the rationale
a7c1e564 184.\" for this?
fea681da 185.TP
c8e68512
MK
186.BR CAP_LEASE " (since Linux 2.4)"
187Establish leases on arbitrary files (see
fea681da
MK
188.BR fcntl (2)).
189.TP
190.B CAP_LINUX_IMMUTABLE
c8e68512
MK
191Set the
192.B FS_APPEND_FL
fea681da 193and
c8e68512 194.B FS_IMMUTABLE_FL
e7e006f2 195inode flags (see
1dc9bca6 196.BR ioctl_iflags (2)).
fea681da 197.TP
c8e68512 198.BR CAP_MAC_ADMIN " (since Linux 2.6.25)"
7f82d0b0 199Allow MAC configuration or state changes.
c8e68512
MK
200Implemented for the Smack Linux Security Module (LSM).
201.TP
202.BR CAP_MAC_OVERRIDE " (since Linux 2.6.25)"
7f82d0b0 203Override Mandatory Access Control (MAC).
c8e68512
MK
204Implemented for the Smack LSM.
205.TP
206.BR CAP_MKNOD " (since Linux 2.4)"
207Create special files using
fea681da
MK
208.BR mknod (2).
209.TP
210.B CAP_NET_ADMIN
e87268ec
MK
211Perform various network-related operations:
212.PD 0
213.RS
214.IP * 2
215interface configuration;
216.IP *
12fe8fd3 217administration of IP firewall, masquerading, and accounting;
e87268ec
MK
218.IP *
219modify routing tables;
220.IP *
221bind to any address for transparent proxying;
222.IP *
223set type-of-service (TOS)
224.IP *
225clear driver statistics;
226.IP *
227set promiscuous mode;
228.IP *
229enabling multicasting;
230.IP *
231use
232.BR setsockopt (2)
233to set the following socket options:
234.BR SO_DEBUG ,
235.BR SO_MARK ,
236.BR SO_PRIORITY
237(for a priority outside the range 0 to 6),
238.BR SO_RCVBUFFORCE ,
239and
240.BR SO_SNDBUFFORCE .
241.RE
242.PD
fea681da
MK
243.TP
244.B CAP_NET_BIND_SERVICE
6eb334b2 245Bind a socket to Internet domain privileged ports
fea681da
MK
246(port numbers less than 1024).
247.TP
248.B CAP_NET_BROADCAST
c8e68512 249(Unused) Make socket broadcasts, and listen to multicasts.
fd39ef0c
MK
250.\" FIXME Since Linux 4.2, there are use cases for netlink sockets
251.\" commit 59324cf35aba5336b611074028777838a963d03b
fea681da
MK
252.TP
253.B CAP_NET_RAW
93e9e2d6
MK
254.PD 0
255.RS
256.IP * 2
dd55b8a1 257Use RAW and PACKET sockets;
93e9e2d6
MK
258.IP *
259bind to any address for transparent proxying.
260.RE
261.PD
fea681da
MK
262.\" Also various IP options and setsockopt(SO_BINDTODEVICE)
263.TP
264.B CAP_SETGID
3bbab71a
MK
265.RS
266.PD 0
267.IP * 2
c8e68512 268Make arbitrary manipulations of process GIDs and supplementary GID list;
3bbab71a 269.IP *
5bea231d 270forge GID when passing socket credentials via UNIX domain sockets;
3bbab71a 271.IP *
5bea231d 272write a group ID mapping in a user namespace (see
f58fb24f 273.BR user_namespaces (7)).
3bbab71a
MK
274.PD
275.RE
fea681da 276.TP
c8e68512 277.BR CAP_SETFCAP " (since Linux 2.6.24)"
b8cee784 278Set arbitrary capabilities on a file.
c8e68512
MK
279.TP
280.B CAP_SETPCAP
e62172cb 281If file capabilities are supported (i.e., since Linux 2.6.24):
c8e68512
MK
282add any capability from the calling thread's bounding set
283to its inheritable set;
284drop capabilities from the bounding set (via
285.BR prctl (2)
286.BR PR_CAPBSET_DROP );
287make changes to the
288.I securebits
289flags.
e62172cb
MK
290.IP
291If file capabilities are not supported (i.e., kernels before Linux 2.6.24):
292grant or remove any capability in the
293caller's permitted capability set to or from any other process.
294(This property of
295.B CAP_SETPCAP
296is not available when the kernel is configured to support
297file capabilities, since
298.B CAP_SETPCAP
299has entirely different semantics for such kernels.)
fea681da
MK
300.TP
301.B CAP_SETUID
3bbab71a
MK
302.RS
303.PD 0
304.IP * 2
c8e68512 305Make arbitrary manipulations of process UIDs
fea681da
MK
306.RB ( setuid (2),
307.BR setreuid (2),
308.BR setresuid (2),
309.BR setfsuid (2));
3bbab71a 310.IP *
a7d96776 311forge UID when passing socket credentials via UNIX domain sockets;
3bbab71a 312.IP *
5bea231d 313write a user ID mapping in a user namespace (see
f58fb24f 314.BR user_namespaces (7)).
3bbab71a
MK
315.PD
316.RE
777f5a9e 317.\" FIXME CAP_SETUID also an effect in exec(); document this.
fea681da
MK
318.TP
319.B CAP_SYS_ADMIN
fa50d3d4
MK
320.IR Note :
321this capability is overloaded; see
322.IR "Notes to kernel developers" ,
323below.
ade303d7 324.IP
c8e68512
MK
325.PD 0
326.RS
327.IP * 2
328Perform a range of system administration operations including:
fea681da
MK
329.BR quotactl (2),
330.BR mount (2),
331.BR umount (2),
1368e847
MK
332.BR swapon (2),
333.BR swapoff (2),
fea681da 334.BR sethostname (2),
f169a862 335and
c8e68512
MK
336.BR setdomainname (2);
337.IP *
bfb730f9
MK
338perform privileged
339.BR syslog (2)
340operations (since Linux 2.6.37,
341.BR CAP_SYSLOG
342should be used to permit such operations);
343.IP *
c8e68512 344perform
c11e3891
MK
345.B VM86_REQUEST_IRQ
346.BR vm86 (2)
347command;
348.IP *
349perform
fea681da
MK
350.B IPC_SET
351and
352.B IPC_RMID
353operations on arbitrary System V IPC objects;
c8e68512 354.IP *
1a3b63f7
MK
355override
356.B RLIMIT_NPROC
357resource limit;
358.IP *
fea681da
MK
359perform operations on
360.I trusted
361and
362.I security
363Extended Attributes (see
89fabe2e 364.BR xattr (7));
c8e68512
MK
365.IP *
366use
08baa0af 367.BR lookup_dcookie (2);
c8e68512 368.IP *
a1f926b8
MK
369use
370.BR ioprio_set (2)
371to assign
372.B IOPRIO_CLASS_RT
83ee9237 373and (before Linux 2.6.25)
237aa7c5 374.B IOPRIO_CLASS_IDLE
a1f926b8 375I/O scheduling classes;
c8e68512 376.IP *
f5ac5bbf 377forge PID when passing socket credentials via UNIX domain sockets;
c8e68512 378.IP *
fea681da 379exceed
3dfe7e0d
MK
380.IR /proc/sys/fs/file-max ,
381the system-wide limit on the number of open files,
382in system calls that open files (e.g.,
fea681da
MK
383.BR accept (2),
384.BR execve (2),
385.BR open (2),
f169a862 386.BR pipe (2));
c8e68512 387.IP *
c13182ef 388employ
0f807eea
MK
389.B CLONE_*
390flags that create new namespaces with
a7c1e564
MK
391.BR clone (2)
392and
c67d3814
MK
393.BR unshare (2)
394(but, since Linux 3.8,
395creating user namespaces does not require any capability);
c8e68512 396.IP *
e4698850 397call
0f322ccc
MK
398.BR perf_event_open (2);
399.IP *
0f322ccc
MK
400access privileged
401.I perf
402event information;
2bfe6656
MK
403.IP *
404call
c3b49118
MK
405.BR setns (2)
406(requires
407.B CAP_SYS_ADMIN
408in the
409.I target
410namespace);
e4698850 411.IP *
0f807eea
MK
412call
413.BR fanotify_init (2);
414.IP *
0563f204
MK
415call
416.BR bpf (2);
417.IP *
2cf45b0d 418perform privileged
a7c1e564
MK
419.B KEYCTL_CHOWN
420and
421.B KEYCTL_SETPERM
422.BR keyctl (2)
e64e6056
MK
423operations;
424.IP *
425perform
426.BR madvise (2)
427.B MADV_HWPOISON
0f807eea
MK
428operation;
429.IP *
430employ the
431.B TIOCSTI
432.BR ioctl (2)
433to insert characters into the input queue of a terminal other than
838ad419 434the caller's controlling terminal;
0f807eea 435.IP *
0f807eea 436employ the obsolete
51c5c662 437.BR nfsservctl (2)
c42221c4
MK
438system call;
439.IP *
440employ the obsolete
0f807eea
MK
441.BR bdflush (2)
442system call;
443.IP *
444perform various privileged block-device
445.BR ioctl (2)
446operations;
447.IP *
9ee4a2b6 448perform various privileged filesystem
0f807eea
MK
449.BR ioctl (2)
450operations;
451.IP *
fdf41f57
MK
452perform privileged
453.BR ioctl (2)
454operations on the
455.IR /dev/random
456device (see
457.BR random (4));
458.IP *
c6ddae52
MK
459install a
460.BR seccomp (2)
461filter without first having to set the
462.I no_new_privs
463thread attribute;
464.IP *
968b27aa
MK
465modify allow/deny rules for device control groups;
466.IP *
467employ the
468.BR ptrace (2)
469.B PTRACE_SECCOMP_GET_FILTER
470operation to dump tracee's seccomp filters;
471.IP *
472employ the
473.BR ptrace (2)
474.B PTRACE_SETOPTIONS
475operation to suspend the tracee's seccomp protections (i.e., the
476.B PTRACE_O_SUSPEND_SECCOMP
115c1eb4 477flag);
c6ddae52 478.IP *
0f807eea 479perform administrative operations on many device drivers.
c8e68512
MK
480.RE
481.PD
fea681da
MK
482.TP
483.B CAP_SYS_BOOT
c8e68512 484Use
08baa0af
MK
485.BR reboot (2)
486and
487.BR kexec_load (2).
fea681da
MK
488.TP
489.B CAP_SYS_CHROOT
4312e0cb
MK
490.RS
491.PD 0
492.IP * 2
c8e68512 493Use
4312e0cb
MK
494.BR chroot (2);
495.IP *
496change mount namespaces using
497.BR setns (2).
498.PD
499.RE
fea681da
MK
500.TP
501.B CAP_SYS_MODULE
3bbab71a
MK
502.RS
503.PD 0
504.IP * 2
c8e68512
MK
505Load and unload kernel modules
506(see
fea681da
MK
507.BR init_module (2)
508and
c8e68512 509.BR delete_module (2));
3bbab71a 510.IP *
c8e68512
MK
511in kernels before 2.6.25:
512drop capabilities from the system-wide capability bounding set.
3bbab71a
MK
513.PD
514.RE
fea681da
MK
515.TP
516.B CAP_SYS_NICE
c8e68512
MK
517.PD 0
518.RS
519.IP * 2
520Raise process nice value
fea681da
MK
521.RB ( nice (2),
522.BR setpriority (2))
c8e68512
MK
523and change the nice value for arbitrary processes;
524.IP *
525set real-time scheduling policies for calling process,
526and set scheduling policies and priorities for arbitrary processes
fea681da 527.RB ( sched_setscheduler (2),
f96787ab 528.BR sched_setparam (2),
0d59d0c8 529.BR sched_setattr (2));
c8e68512 530.IP *
fea681da 531set CPU affinity for arbitrary processes
c13182ef 532.RB ( sched_setaffinity (2));
c8e68512 533.IP *
a1f926b8 534set I/O scheduling class and priority for arbitrary processes
c13182ef 535.RB ( ioprio_set (2));
c8e68512
MK
536.IP *
537apply
a1f926b8 538.BR migrate_pages (2)
c8e68512 539to arbitrary processes and allow processes
a1f926b8 540to be migrated to arbitrary nodes;
c13182ef 541.\" FIXME CAP_SYS_NICE also has the following effect for
a1f926b8
MK
542.\" migrate_pages(2):
543.\" do_migrate_pages(mm, &old, &new,
544.\" capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
1a0fbe37 545.\"
bea08fec 546.\" Document this.
c8e68512
MK
547.IP *
548apply
a7c1e564 549.BR move_pages (2)
c8e68512
MK
550to arbitrary processes;
551.IP *
4d62f7b6
MK
552use the
553.B MPOL_MF_MOVE_ALL
c13182ef 554flag with
a7c1e564 555.BR mbind (2)
c13182ef 556and
a7c1e564 557.BR move_pages (2).
c8e68512
MK
558.RE
559.PD
fea681da
MK
560.TP
561.B CAP_SYS_PACCT
c8e68512 562Use
fea681da
MK
563.BR acct (2).
564.TP
565.B CAP_SYS_PTRACE
eb64a9cb
MK
566.PD 0
567.RS
de6a5c05 568.IP * 2
c8e68512 569Trace arbitrary processes using
cbd7b9bf 570.BR ptrace (2);
eb64a9cb 571.IP *
cbd7b9bf
MK
572apply
573.BR get_robust_list (2)
38b6e5b0 574to arbitrary processes;
eb64a9cb 575.IP *
b8f84ce2
MK
576transfer data to or from the memory of arbitrary processes using
577.BR process_vm_readv (2)
578and
3bbab71a 579.BR process_vm_writev (2);
b8f84ce2 580.IP *
38b6e5b0
MK
581inspect processes using
582.BR kcmp (2).
eb64a9cb
MK
583.RE
584.PD
fea681da
MK
585.TP
586.B CAP_SYS_RAWIO
4637c8cb
MK
587.PD 0
588.RS
589.IP * 2
c8e68512 590Perform I/O port operations
fea681da
MK
591.RB ( iopl (2)
592and
593.BR ioperm (2));
4637c8cb 594.IP *
fea681da 595access
474e1f9d 596.IR /proc/kcore ;
4637c8cb 597.IP *
474e1f9d
MK
598employ the
599.B FIBMAP
600.BR ioctl (2)
4637c8cb
MK
601operation;
602.IP *
603open devices for accessing x86 model-specific registers (MSRs, see
3bbab71a 604.BR msr (4));
4637c8cb
MK
605.IP *
606update
607.IR /proc/sys/vm/mmap_min_addr ;
608.IP *
609create memory mappings at addresses below the value specified by
610.IR /proc/sys/vm/mmap_min_addr ;
611.IP *
50b2aa27 612map files in
cef53f3e 613.IR /proc/bus/pci ;
4637c8cb
MK
614.IP *
615open
616.IR /dev/mem
617and
618.IR /dev/kmem ;
619.IP *
620perform various SCSI device commands;
621.IP *
622perform certain operations on
623.BR hpsa (4)
624and
625.BR cciss (4)
626devices;
627.IP *
628perform a range of device-specific operations on other devices.
629.RE
630.PD
fea681da
MK
631.TP
632.B CAP_SYS_RESOURCE
c8e68512
MK
633.PD 0
634.RS
635.IP * 2
9ee4a2b6 636Use reserved space on ext2 filesystems;
c8e68512
MK
637.IP *
638make
fea681da
MK
639.BR ioctl (2)
640calls controlling ext3 journaling;
c8e68512
MK
641.IP *
642override disk quota limits;
643.IP *
644increase resource limits (see
fea681da 645.BR setrlimit (2));
c8e68512
MK
646.IP *
647override
fea681da 648.B RLIMIT_NPROC
c8e68512
MK
649resource limit;
650.IP *
aa66392d
MK
651override maximum number of consoles on console allocation;
652.IP *
653override maximum number of keymaps;
654.IP *
655allow more than 64hz interrupts from the real-time clock;
656.IP *
c8e68512 657raise
fea681da 658.I msg_qbytes
c8e68512 659limit for a System V message queue above the limit in
0daa9e92 660.I /proc/sys/kernel/msgmnb
fea681da
MK
661(see
662.BR msgop (2)
663and
ad7b0f91
MK
664.BR msgctl (2));
665.IP *
7509f758
MK
666allow the
667.B RLIMIT_NOFILE
668resource limit on the number of "in-flight" file descriptors
669to be bypassed when passing file descriptors to another process
670via a UNIX domain socket (see
671.BR unix (7));
672.IP *
ad7b0f91
MK
673override the
674.I /proc/sys/fs/pipe-size-max
675limit when setting the capacity of a pipe using the
676.B F_SETPIPE_SZ
677.BR fcntl (2)
678command.
46883521
MK
679.IP *
680use
681.BR F_SETPIPE_SZ
682to increase the capacity of a pipe above the limit specified by
b39a2012
MK
683.IR /proc/sys/fs/pipe-max-size ;
684.IP *
685override
686.I /proc/sys/fs/mqueue/queues_max
687limit when creating POSIX message queues (see
ecc1f45b
MK
688.BR mq_overview (7));
689.IP *
3bbab71a 690employ the
ecc1f45b
MK
691.BR prctl (2)
692.B PR_SET_MM
8ddcc591 693operation;
41f00272 694.IP *
8ddcc591 695set
750653a8 696.IR /proc/[pid]/oom_score_adj
8ddcc591
MK
697to a value lower than the value last set by a process with
698.BR CAP_SYS_RESOURCE .
c8e68512
MK
699.RE
700.PD
fea681da
MK
701.TP
702.B CAP_SYS_TIME
c8e68512 703Set system clock
fea681da
MK
704.RB ( settimeofday (2),
705.BR stime (2),
706.BR adjtimex (2));
c8e68512 707set real-time (hardware) clock.
fea681da
MK
708.TP
709.B CAP_SYS_TTY_CONFIG
c8e68512 710Use
749ac769
MK
711.BR vhangup (2);
712employ various privileged
713.BR ioctl (2)
714operations on virtual terminals.
bfb730f9
MK
715.TP
716.BR CAP_SYSLOG " (since Linux 2.6.37)"
5f94327c
MK
717.RS
718.PD 0
de6a5c05 719.IP * 2
bfb730f9
MK
720Perform privileged
721.BR syslog (2)
722operations.
723See
724.BR syslog (2)
725for information on which operations require privilege.
10fe5485
MK
726.IP *
727View kernel addresses exposed via
728.I /proc
729and other interfaces when
730.IR /proc/sys/kernel/kptr_restrict
731has the value 1.
4eaa04c5 732(See the discussion of the
10fe5485
MK
733.I kptr_restrict
734in
735.BR proc (5).)
5f94327c
MK
736.PD
737.RE
d6b08708
MK
738.TP
739.BR CAP_WAKE_ALARM " (since Linux 3.0)"
740Trigger something that will wake up the system (set
741.B CLOCK_REALTIME_ALARM
742and
743.B CLOCK_BOOTTIME_ALARM
744timers).
c8e68512 745.\"
c634028a 746.SS Past and current implementation
c8e68512
MK
747A full implementation of capabilities requires that:
748.IP 1. 3
749For all privileged operations,
750the kernel must check whether the thread has the required
751capability in its effective set.
752.IP 2.
137d81b5 753The kernel must provide system calls allowing a thread's capability sets to
c8e68512
MK
754be changed and retrieved.
755.IP 3.
9ee4a2b6 756The filesystem must support attaching capabilities to an executable file,
c8e68512
MK
757so that a process gains those capabilities when the file is executed.
758.PP
759Before kernel 2.6.24, only the first two of these requirements are met;
760since kernel 2.6.24, all three requirements are met.
761.\"
8de5616f
MK
762.SS Notes to kernel developers
763When adding a new kernel feature that should be governed by a capability,
764consider the following points.
765.IP * 3
ddb624a9
MK
766The goal of capabilities is divide the power of superuser into pieces,
767such that if a program that has one or more capabilities is compromised,
768its power to do damage to the system would be less than the same program
769running with root privilege.
8de5616f
MK
770.IP *
771You have the choice of either creating a new capability for your new feature,
772or associating the feature with one of the existing capabilities.
ddb624a9 773In order to keep the set of capabilities to a manageable size,
8de5616f
MK
774the latter option is preferable,
775unless there are compelling reasons to take the former option.
ddb624a9
MK
776(There is also a technical limit:
777the size of capability sets is currently limited to 64 bits.)
8de5616f
MK
778.IP *
779To determine which existing capability might best be associated
780with your new feature, review the list of capabilities above in order
781to find a "silo" into which your new feature best fits.
ddb624a9 782One approach to take is to determine if there are other features
9f92e4e1 783requiring capabilities that will always be used along with the new feature.
ddb624a9
MK
784If the new feature is useless without these other features,
785you should use the same capability as the other features.
8de5616f
MK
786.IP *
787.IR Don't
788choose
789.B CAP_SYS_ADMIN
790if you can possibly avoid it!
791A vast proportion of existing capability checks are associated
6e9219f7
MK
792with this capability (see the partial list above).
793It can plausibly be called "the new root",
794since on the one hand, it confers a wide range of powers,
795and on the other hand,
796its broad scope means that this is the capability
797that is required by many privileged programs.
8de5616f
MK
798Don't make the problem worse.
799The only new features that should be associated with
800.B CAP_SYS_ADMIN
801are ones that
802.I closely
803match existing uses in that silo.
804.IP *
805If you have determined that it really is necessary to create
806a new capability for your feature,
ddb624a9 807don't make or name it as a "single-use" capability.
8de5616f 808Thus, for example, the addition of the highly specific
42dfc34c 809.BR CAP_SYS_PACCT
8de5616f
MK
810was probably a mistake.
811Instead, try to identify and name your new capability as a broader
812silo into which other related future use cases might fit.
813.\"
c634028a 814.SS Thread capability sets
1db1d36d 815Each thread has the following capability sets containing zero or more
fea681da
MK
816of the above capabilities:
817.TP
c2b279af 818.IR Permitted
c8e68512
MK
819This is a limiting superset for the effective
820capabilities that the thread may assume.
821It is also a limiting superset for the capabilities that
822may be added to the inheritable set by a thread that does not have the
823.B CAP_SETPCAP
824capability in its effective set.
ade303d7 825.IP
cf7a13d4 826If a thread drops a capability from its permitted set,
3b777aff 827it can never reacquire that capability (unless it
c930827f 828.BR execve (2)s
c8e68512
MK
829either a set-user-ID-root program, or
830a program whose associated file capabilities grant that capability).
fea681da 831.TP
c2b279af 832.IR Inheritable
c8e68512 833This is a set of capabilities preserved across an
fea681da 834.BR execve (2).
6260f4cd
AL
835Inheritable capabilities remain inheritable when executing any program,
836and inheritable capabilities are added to the permitted set when executing
837a program that has the corresponding bits set in the file inheritable set.
838.IP
839Because inheritable capabilities are not generally preserved across
840.BR execve (2)
841when running as a non-root user, applications that wish to run helper
e574dcd0
MK
842programs with elevated capabilities should consider using
843ambient capabilities, described below.
c8e68512 844.TP
c2b279af 845.IR Effective
c8e68512
MK
846This is the set of capabilities used by the kernel to
847perform permission checks for the thread.
6260f4cd 848.TP
36de80b9
MK
849.IR Bounding " (per-thread since Linux 2.6.25)"
850The capability bounding set is a mechanism that can be used
851to limit the capabilities that are gained during
852.BR execve (2).
853.IP
854Since Linux 2.6.25, this is a per-thread capability set.
855In older kernels, the capability bounding set was a system wide attribute
856shared by all threads on the system.
857.IP
858.IP
859For more details on the capability bounding set, see below.
860.TP
c2b279af 861.IR Ambient " (since Linux 4.3)"
e574dcd0 862.\" commit 58319057b7847667f0c9585b9de0e8932b0fdb08
6260f4cd
AL
863This is a set of capabilities that are preserved across an
864.BR execve (2)
3375bef1 865of a program that is not privileged.
e574dcd0
MK
866The ambient capability set obeys the invariant that no capability
867can ever be ambient if it is not both permitted and inheritable.
ade303d7 868.IP
3375bef1
MK
869The ambient capability set can be directly modified using
870.BR prctl (2).
871Ambient capabilities are automatically lowered if either of
872the corresponding permitted or inheritable capabilities is lowered.
ade303d7 873.IP
3375bef1
MK
874Executing a program that changes UID or GID due to the
875set-user-ID or set-group-ID bits or executing a program that has
876any file capabilities set will clear the ambient set.
877Ambient capabilities are added to the permitted set and
878assigned to the effective set when
6260f4cd 879.BR execve (2)
e574dcd0 880is called.
5367a9ab
MK
881If ambient capabilities cause a process's permitted and effective
882capabilities to increase during an
883.BR execve (2),
884this does not trigger the secure-execution mode described in
885.BR ld.so (8).
fea681da 886.PP
fea681da
MK
887A child created via
888.BR fork (2)
889inherits copies of its parent's capability sets.
3dfe7e0d 890See below for a discussion of the treatment of capabilities during
c930827f 891.BR execve (2).
fea681da
MK
892.PP
893Using
894.BR capset (2),
c8e68512 895a thread may manipulate its own capability sets (see below).
afae50e4
MK
896.PP
897Since Linux 3.2, the file
898.I /proc/sys/kernel/cap_last_cap
a60b1f03 899.\" commit 73efc0394e148d0e15583e13712637831f926720
afae50e4
MK
900exposes the numerical value of the highest capability
901supported by the running kernel;
902this can be used to determine the highest bit
903that may be set in a capability set.
c8e68512 904.\"
c634028a 905.SS File capabilities
c8e68512
MK
906Since kernel 2.6.24, the kernel supports
907associating capability sets with an executable file using
908.BR setcap (8).
909The file capability sets are stored in an extended attribute (see
6a65cff8
MK
910.BR setxattr (2)
911and
912.BR xattr (7))
c8e68512
MK
913named
914.IR "security.capability" .
915Writing to this extended attribute requires the
916.BR CAP_SETFCAP
fea681da 917capability.
c8e68512 918The file capability sets,
cf7a13d4 919in conjunction with the capability sets of the thread,
c8e68512 920determine the capabilities of a thread after an
c930827f 921.BR execve (2).
ade303d7 922.PP
c8e68512 923The three file capability sets are:
fea681da 924.TP
3dfe7e0d 925.IR Permitted " (formerly known as " forced ):
c8e68512 926These capabilities are automatically permitted to the thread,
cf7a13d4 927regardless of the thread's inheritable capabilities.
fea681da 928.TP
c8e68512
MK
929.IR Inheritable " (formerly known as " allowed ):
930This set is ANDed with the thread's inheritable set to determine which
931inheritable capabilities are enabled in the permitted set of
932the thread after the
933.BR execve (2).
934.TP
fea681da 935.IR Effective :
c8e68512
MK
936This is not a set, but rather just a single bit.
937If this bit is set, then during an
938.BR execve (2)
939all of the new permitted capabilities for the thread are
940also raised in the effective set.
941If this bit is not set, then after an
942.BR execve (2),
943none of the new permitted capabilities is in the new effective set.
ade303d7 944.IP
c8e68512 945Enabling the file effective capability bit implies
2914a14d 946that any file permitted or inheritable capability that causes a
c8e68512
MK
947thread to acquire the corresponding permitted capability during an
948.BR execve (2)
e33a08e1 949(see the transformation rules described below) will also acquire that
c8e68512
MK
950capability in its effective set.
951Therefore, when assigning capabilities to a file
952.RB ( setcap (8),
953.BR cap_set_file (3),
954.BR cap_set_fd (3)),
955if we specify the effective flag as being enabled for any capability,
956then the effective flag must also be specified as enabled
957for all other capabilities for which the corresponding permitted or
958inheritable flags is enabled.
959.\"
c281d050 960.SS File capability extended attribute versioning
b6848704
MK
961To allow extensibility,
962the kernel supports a scheme to encode a version number inside the
963.I security.capability
964extended attribute that is used to implement file capabilities.
965These version numbers are internal to the implementation,
966and not directly visible to user-space applications.
967To date, the following versions are supported:
968.TP
969.BR VFS_CAP_REVISION_1
970This was the original file capability implementation,
971which supported 32-bit masks for file capabilities.
972.TP
973.BR VFS_CAP_REVISION_2 " (since Linux 2.6.25)"
974.\" commit e338d263a76af78fe8f38a72131188b58fceb591
975This version allows for file capability masks that are 64 bits in size,
976and was necessary as the number of supported capabilities grew beyond 32.
977The kernel transparently continues to support the execution of files
978that have 32-bit version 1 capability masks,
979but when adding capabilities to files that did not previously
980have capabilities, or modifying the capabilities of existing files,
bcaa30c9
MK
981it automatically uses the version 2 scheme
982(or possibly the version 3 scheme, as described below).
b6848704
MK
983.TP
984.BR VFS_CAP_REVISION_3 " (since Linux 4.14)"
985.\" commit 8db6c34f1dbc8e06aa016a9b829b06902c3e1340
bcaa30c9 986Version 3 file capabilities are provided
12dce731 987to support namespaced file capabilities (described below).
bcaa30c9 988.IP
b6848704 989As with version 2 file capabilities,
bcaa30c9
MK
990version 3 capability masks are 64 bits in size.
991But in addition, the root user ID of namespace is encoded in the
b6848704
MK
992.I security.capability
993extended attribute.
7da0c87a
MK
994(A namespace's root user ID is the value that user ID 0
995inside that namespace maps to in the initial user namespace.)
7b45f4b2 996.IP
bcaa30c9
MK
997Version 3 file capabilities are designed to coexist
998with version 2 capabilities;
999that is, on a modern Linux system,
1000there may be some files with version 2 capabilities
1001while others have version 3 capabilities.
1002.PP
1003Before Linux 4.14,
c281d050
MK
1004the only kind of file capability extended attribute
1005that could be attached to a file was a
bcaa30c9 1006.B VFS_CAP_REVISION_2
c281d050 1007attribute.
bcaa30c9 1008Since Linux 4.14,
9b2c207a 1009the version of the
bcaa30c9 1010.I security.capability
9b2c207a
MK
1011extended attribute that is attached to a file
1012depends on the circumstances in which the attribute was created.
bcaa30c9 1013.PP
7b45f4b2 1014Starting with Linux 4.14, a
7b45f4b2
MK
1015.I security.capability
1016extended attribute is automatically created as (or converted to)
bcaa30c9
MK
1017a version 3
1018.RB ( VFS_CAP_REVISION_3 )
1019attribute if both of the following are true:
7b45f4b2 1020.IP (1) 4
ffea2c14 1021The thread writing the attribute resides in a noninitial user namespace.
7b45f4b2
MK
1022(More precisely: the thread resides in a user namespace other
1023than the one from which the underlying filesystem was mounted.)
1024.IP (2)
1025The thread has the
1026.BR CAP_SETFCAP
1027capability over the file inode,
1028meaning that (a) the thread has the
1029.B CAP_SETFCAP
1030capability in its own user namespace;
1031and (b) the UID and GID of the file inode have mappings in
1032the writer's user namespace.
bcaa30c9 1033.PP
7b45f4b2
MK
1034When a
1035.BR VFS_CAP_REVISION_3
1036.I security.capability
1037extended attribute is created, the root user ID of the creating thread's
1038user namespace is saved in the extended attribute.
bcaa30c9 1039.PP
2c77e8de 1040By contrast, creating or modifying a
7b45f4b2
MK
1041.I security.capability
1042extended attribute from a privileged
1043.RB ( CAP_SETFCAP )
1044thread that resides in the
90ef0f7b 1045namespace where the underlying filesystem was mounted
7b45f4b2 1046(this normally means the initial user namespace)
2c77e8de 1047automatically results in the creation of a version 2
bcaa30c9 1048.RB ( VFS_CAP_REVISION_2 )
7b45f4b2 1049attribute.
bcaa30c9 1050.PP
2c77e8de
MK
1051Note that the creation of a version 3
1052.I security.capability
1053extended attribute is automatic.
1054That is to say, when a user-space application writes
1055.RB ( setxattr (2))
1056a
1057.I security.capability
1058attribute in the version 2 format,
1059the kernel will automatically create a version 3 attribute
1060if the attribute is created in the circumstances described above.
1061Correspondingly, when a version 3
1062.I security.capability
1063attribute is retrieved
1064.RB ( getxattr (2))
1065by a process that resides inside a user namespace that was created by the
1066root user ID (or a descendant of that user namespace),
1067the returned attribute is (automatically)
1068simplified to appear as a version 2 attribute
1069(i.e., the returned value is the size of a version 2 attribute and does
1070not include the root user ID).
1071These automatic translations mean that no changes are required to
1072user-space tools (e.g.,
1073.BR setcap (1)
1074and
1075.BR getcap (1))
1076in order for those tools to be used to create and retrieve version 3
1077.I security.capability
1078attributes.
1079.PP
bcaa30c9
MK
1080Note that a file can have either a version 2 or a version 3
1081.I security.capability
1082extended attribute associated with it, but not both:
1083creation or modification of the
1084.I security.capability
1085extended attribute will automatically modify the version
1086according to the circumstances in which the extended attribute is
1087created or modified.
b6848704 1088.\"
c634028a 1089.SS Transformation of capabilities during execve()
fea681da 1090.PP
c13182ef 1091During an
c930827f 1092.BR execve (2),
1e321034 1093the kernel calculates the new capabilities of
fea681da 1094the process using the following algorithm:
ade303d7 1095.PP
088a639b 1096.in +4n
b8302363 1097.EX
f04f131f 1098P'(ambient) = (file is privileged) ? 0 : P(ambient)
6260f4cd 1099
f04f131f 1100P'(permitted) = (P(inheritable) & F(inheritable)) |
2e87ced3 1101 (F(permitted) & P(bounding)) | P'(ambient)
fea681da 1102
f04f131f 1103P'(effective) = F(effective) ? P'(permitted) : P'(ambient)
fea681da 1104
5bdccabd 1105P'(inheritable) = P(inheritable) [i.e., unchanged]
2e87ced3
MK
1106
1107P'(bounding) = P(bounding) [i.e., unchanged]
b8302363 1108.EE
088a639b 1109.in
ade303d7 1110.PP
fea681da 1111where:
c8e68512 1112.RS 4
2e87ced3 1113.IP P() 6
c13182ef 1114denotes the value of a thread capability set before the
c930827f 1115.BR execve (2)
2e87ced3 1116.IP P'()
8295fc02 1117denotes the value of a thread capability set after the
c930827f 1118.BR execve (2)
2e87ced3 1119.IP F()
fea681da 1120denotes a file capability set
c8e68512 1121.RE
3375bef1 1122.PP
ddc1ad30
MK
1123Note the following details relating to the above capability
1124transformation rules:
1125.IP * 3
1126The ambient capability set is present only since Linux 4.3.
1127When determining the transformation of the ambient set during
1128.BR execve (2),
1129a privileged file is one that has capabilities or
3375bef1 1130has the set-user-ID or set-group-ID bit set.
ddc1ad30
MK
1131.IP *
1132Prior to Linux 2.6.25,
1133the bounding set was a system-wide attribute shared by all threads.
1134That system-wide value was employed to calculate the new permitted set during
1135.BR execve (2)
1136in the same manner as shown above for
1137.IR P(bounding) .
ade303d7 1138.PP
56cc88cb 1139.IR Note :
1a9ed17c
MK
1140during the capability transitions described above,
1141file capabilities may be ignored (treated as empty) for the same reasons
56cc88cb
MK
1142that the set-user-ID and set-group-ID bits are ignored; see
1143.BR execve (2).
1a9ed17c 1144File capabilities are similarly ignored if the kernel was booted with the
f6acfeb8 1145.I no_file_caps
1a9ed17c 1146option.
ade303d7 1147.PP
e3ed67ed
MK
1148.IR Note :
1149according to the rules above,
1150if a process with nonzero user IDs performs an
1151.BR execve (2)
1152then any capabilities that are present in
1153its permitted and effective sets will be cleared.
1154For the treatment of capabilities when a process with a
1155user ID of zero performs an
1156.BR execve (2),
1157see below under
1158.IR "Capabilities and execution of programs by root" .
c8e68512 1159.\"
e0e57837 1160.SS Safety checking for capability-dumb binaries
4a866754 1161A capability-dumb binary is an application that has been
e0e57837
MK
1162marked to have file capabilities, but has not been converted to use the
1163.BR libcap (3)
1164API to manipulate its capabilities.
1165(In other words, this is a traditional set-user-ID-root program
1166that has been switched to use file capabilities,
1167but whose code has not been modified to understand capabilities.)
2c767761 1168For such applications,
e0e57837
MK
1169the effective capability bit is set on the file,
1170so that the file permitted capabilities are automatically
1171enabled in the process effective set when executing the file.
1172The kernel recognizes a file which has the effective capability bit set
1173as capability-dumb for the purpose of the check described here.
ade303d7 1174.PP
e0e57837
MK
1175When executing a capability-dumb binary,
1176the kernel checks if the process obtained all permitted capabilities
1177that were specified in the file permitted set,
1178after the capability transformations described above have been performed.
1179(The typical reason why this might
1180.I not
1181occur is that the capability bounding set masked out some
1182of the capabilities in the file permitted set.)
1183If the process did not obtain the full set of
1184file permitted capabilities, then
1185.BR execve (2)
1186fails with the error
1187.BR EPERM .
1188This prevents possible security risks that could arise when
1189a capability-dumb application is executed with less privilege that it needs.
1190Note that, by definition,
1191the application could not itself recognize this problem,
1192since it does not employ the
1193.BR libcap (3)
1194API.
1195.\"
c8e68512 1196.SS Capabilities and execution of programs by root
33d0916f
MK
1197.\" See cap_bprm_set_creds(), bprm_caps_from_vfs_cap() and
1198.\" handle_privileged_root() in security/commoncap.c (Linux 5.0 source)
bc1950ac 1199In order to mirror traditional UNIX semantics,
33d0916f
MK
1200the kernel performs special treatment of file capabilities when
1201a process with UID 0 (root) executes a program and
1202when a set-user-ID-root program is executed.
bc1950ac 1203.PP
33d0916f
MK
1204After having performed any changes to the process effective ID that
1205were triggered by the set-user-ID mode bit of the binary\(eme.g.,
1206switching the effective user ID to 0 (root) because
1207a set-user-ID-root program was executed\(emthe
1208kernel calculates the file capability sets as follows:
c8e68512 1209.IP 1. 3
bc1950ac 1210If the real or effective user ID of the process is 0 (root),
33d0916f
MK
1211then the file inheritable and permitted sets are ignored;
1212instead they are notionally considered to be all ones
c8e68512 1213(i.e., all capabilities enabled).
33d0916f
MK
1214(There is one exception to this behavior, described below in
1215.IR "Set-user-ID-root programs that have file capabilities" .)
c8e68512 1216.IP 2.
bc1950ac
MK
1217If the effective user ID of the process is 0 (root) or
1218the file effective bit is in fact enabled,
33d0916f 1219then the file effective bit is notionally defined to be one (enabled).
3dfe7e0d 1220.PP
33d0916f
MK
1221These notional values for the file's capability sets are then used
1222as described above to calculate the transformation of the process's
1223capabilities during
1224.BR execve (2).
bc1950ac 1225.PP
33d0916f 1226Thus, when a process with nonzero UIDs
c930827f 1227.BR execve (2)s
33d0916f
MK
1228a set-user-ID-root program that does not have capabilities attached,
1229or when a process whose real and effective UIDs are zero
ab8aa2e4 1230.BR execve (2)s
33d0916f
MK
1231a program, the calculation of the process's new
1232permitted capabilities simplifies to:
1233.PP
1234.in +4n
1235.EX
1236P'(permitted) = P(inheritable) | P(bounding)
1237
1238P'(effective) = P'(permitted)
1239.EE
1240.in
1241.PP
1242Consequently, the process gains all capabilities in its permitted and
1243effective capability sets,
ab8aa2e4 1244except those masked out by the capability bounding set.
33d0916f
MK
1245(In the calculation of P'(permitted),
1246the P'(ambient) term can be simplified away because it is by
1247definition a proper subset of P(inheritable).)
ab8aa2e4 1248.PP
33d0916f
MK
1249The special treatments of user ID 0 (root) described in this subsection
1250can be disabled using the securebits mechanism described below.
1251.\"
0603dda3
MK
1252.\"
1253.SS Set-user-ID-root programs that have file capabilities
33d0916f
MK
1254There is one exception to the behavior described under
1255.IR "Capabilities and execution of programs by root" .
1256If (a) the binary that is being executed has capabilities attached and
1257(b) the real user ID of the process is
1258.I not
12590 (root) and
1260(c) the effective user ID of the process
1261.I is
12620 (root), then the file capability bits are honored
1263(i.e., they are not notionally considered to be all ones).
1264The usual way in which this situation can arise is when executing
1265a set-UID-root program that also has file capabilities.
1266When such a program is executed,
1267the process gains just the capabilities granted by the program
0603dda3
MK
1268(i.e., not all capabilities,
1269as would occur when executing a set-user-ID-root program
1270that does not have any associated file capabilities).
bc1950ac 1271.PP
c199053b
MK
1272Note that one can assign empty capability sets to a program file,
1273and thus it is possible to create a set-user-ID-root program that
1274changes the effective and saved set-user-ID of the process
1275that executes the program to 0,
1276but confers no capabilities to that process.
0603dda3 1277.\"
c8e68512
MK
1278.SS Capability bounding set
1279The capability bounding set is a security mechanism that can be used
1280to limit the capabilities that can be gained during an
1281.BR execve (2).
1282The bounding set is used in the following ways:
1283.IP * 2
1284During an
1285.BR execve (2),
1286the capability bounding set is ANDed with the file permitted
1287capability set, and the result of this operation is assigned to the
1288thread's permitted capability set.
1289The capability bounding set thus places a limit on the permitted
1290capabilities that may be granted by an executable file.
1291.IP *
1292(Since Linux 2.6.25)
1293The capability bounding set acts as a limiting superset for
1294the capabilities that a thread can add to its inheritable set using
1295.BR capset (2).