2007-09-20 06:52:22 +00:00
|
|
|
.\" Copyright (c) 2002 by Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
intro.1, _exit.2, access.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, close.2, connect.2, delete_module.2, dup.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, fork.2, fstatat.2, fsync.2, futimesat.2, get_robust_list.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getpagesize.2, getpid.2, getresuid.2, getrlimit.2, getrusage.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, idle.2, init_module.2, intro.2, iopl.2, kcmp.2, kexec_load.2, kill.2, link.2, linkat.2, llseek.2, lookup_dcookie.2, madvise.2, mincore.2, mkdirat.2, mknodat.2, mmap.2, mmap2.2, mount.2, mprotect.2, mq_getsetattr.2, msgctl.2, msgget.2, msgop.2, msync.2, nice.2, open.2, openat.2, pause.2, perfmonctl.2, personality.2, pipe.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, quotactl.2, read.2, readahead.2, readdir.2, readlinkat.2, readv.2, reboot.2, recvmmsg.2, remap_file_pages.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, select.2, select_tut.2, semctl.2, semget.2, semop.2, sendmmsg.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setresuid.2, setuid.2, setup.2, sgetmask.2, shmctl.2, shmget.2, shmop.2, sigaction.2, sigaltstack.2, signal.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, splice.2, stat.2, statfs.2, stime.2, subpage_prot.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, syscalls.2, sysctl.2, sysfs.2, syslog.2, tee.2, time.2, timer_create.2, timer_delete.2, timer_getoverrun.2, timer_settime.2, times.2, tkill.2, umask.2, umount.2, uname.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, abort.3, abs.3, acos.3, acosh.3, adjtime.3, aio_init.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, byteorder.3, bzero.3, catgets.3, catopen.3, cbrt.3, ceil.3, clearenv.3, clock.3, clock_getcpuclockid.3, closedir.3, confstr.3, copysign.3, cos.3, cosh.3, ctermid.3, ctime.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, end.3, endian.3, erf.3, erfc.3, ether_aton.3, euidaccess.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fcloseall.3, fexecve.3, ffs.3, fgetgrent.3, fgetpwent.3, finite.3, flockfile.3, floor.3, fmod.3, fnmatch.3, fopencookie.3, fpathconf.3, fpurge.3, frexp.3, fseeko.3, ftok.3, futimes.3, gcvt.3, get_nprocs_conf.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getifaddrs.3, getipnodebyname.3, getline.3, getlogin.3, getmntent.3, getnetent.3, getnetent_r.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwnam.3, getrpcent_r.3, gets.3, getservent.3, getservent_r.3, getumask.3, getusershell.3, getutmp.3, getw.3, glob.3, gnu_get_libc_version.3, gsignal.3, hypot.3, if_nameindex.3, if_nametoindex.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, j0.3, ldexp.3, localeconv.3, log.3, log10.3, log1p.3, log2.3, logb.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, mallinfo.3, malloc.3, malloc_get_state.3, malloc_info.3, malloc_stats.3, malloc_trim.3, malloc_usable_size.3, mallopt.3, matherr.3, mcheck.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, on_exit.3, opendir.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, profil.3, psignal.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_detach.3, pthread_equal.3, pthread_exit.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_join.3, pthread_kill.3, pthread_kill_other_threads_np.3, pthread_self.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_setschedprio.3, pthread_sigmask.3, pthread_sigqueue.3, pthread_testcancel.3, pthread_tryjoin_np.3, pthread_yield.3, putenv.3, putpwent.3, puts.3, qecvt.3, qsort.3, raise.3, rand.3, random.3, random_r.3, re_comp.3, readdir.3, realpath.3, regex.3, remainder.3, remove.3, resolver.3, rewinddir.3, rint.3, round.3, scalb.3, scalbln.3, scandir.3, sched_getcpu.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setenv.3, setlocale.3, setlogmask.3, shm_open.3, siginterrupt.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sigwait.3, sin.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdio_ext.3, stpcpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfry.3, strftime.3, string.3, strlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, trunc.3, tsearch.3, ttyslot.3, tzset.3, ulimit.3, undocumented.3, unlocked_stdio.3, usleep.3, y0.3, cpuid.4, full.4, initrd.4, mouse.4, msr.4, sd.4, st.4, acct.5, core.5, services.5, slabinfo.5, aio.7, capabilities.7, credentials.7, feature_test_macros.7, hier.7, inotify.7, libc.7, locale.7, man-pages.7, man.7, math_error.7, mq_overview.7, numa.7, path_resolution.7, pipe.7, pthreads.7, pty.7, rtld-audit.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, suffixes.7, svipc.7, termio.7, time.7, udplite.7, units.7, uri.7, sln.8: s/LICENSE_START(verbatim)/LICENSE_START(VERBATIM)/
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-03-10 09:29:01 +00:00
|
|
|
.\" %%%LICENSE_START(VERBATIM)
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
|
|
|
.\"
|
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
2008-03-18 14:47:54 +00:00
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
intro.1, _exit.2, access.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, close.2, connect.2, delete_module.2, dup.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, fork.2, fstatat.2, fsync.2, futimesat.2, get_robust_list.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getpagesize.2, getpid.2, getresuid.2, getrlimit.2, getrusage.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, idle.2, init_module.2, intro.2, iopl.2, kcmp.2, kexec_load.2, kill.2, link.2, linkat.2, llseek.2, lookup_dcookie.2, madvise.2, mincore.2, mkdirat.2, mknodat.2, mmap.2, mmap2.2, mount.2, mprotect.2, mq_getsetattr.2, msgctl.2, msgget.2, msgop.2, msync.2, nice.2, open.2, openat.2, pause.2, perfmonctl.2, personality.2, pipe.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, quotactl.2, read.2, readahead.2, readdir.2, readlinkat.2, readv.2, reboot.2, recvmmsg.2, remap_file_pages.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, select.2, select_tut.2, semctl.2, semget.2, semop.2, sendmmsg.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setresuid.2, setuid.2, setup.2, sgetmask.2, shmctl.2, shmget.2, shmop.2, sigaction.2, sigaltstack.2, signal.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, splice.2, stat.2, statfs.2, stime.2, subpage_prot.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, syscalls.2, sysctl.2, sysfs.2, syslog.2, tee.2, time.2, timer_create.2, timer_delete.2, timer_getoverrun.2, timer_settime.2, times.2, tkill.2, umask.2, umount.2, uname.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, abort.3, abs.3, acos.3, acosh.3, adjtime.3, aio_init.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, byteorder.3, bzero.3, catgets.3, catopen.3, cbrt.3, ceil.3, clearenv.3, clock.3, clock_getcpuclockid.3, closedir.3, confstr.3, copysign.3, cos.3, cosh.3, ctermid.3, ctime.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, end.3, endian.3, erf.3, erfc.3, ether_aton.3, euidaccess.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fcloseall.3, fexecve.3, ffs.3, fgetgrent.3, fgetpwent.3, finite.3, flockfile.3, floor.3, fmod.3, fnmatch.3, fopencookie.3, fpathconf.3, fpurge.3, frexp.3, fseeko.3, ftok.3, futimes.3, gcvt.3, get_nprocs_conf.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getifaddrs.3, getipnodebyname.3, getline.3, getlogin.3, getmntent.3, getnetent.3, getnetent_r.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwnam.3, getrpcent_r.3, gets.3, getservent.3, getservent_r.3, getumask.3, getusershell.3, getutmp.3, getw.3, glob.3, gnu_get_libc_version.3, gsignal.3, hypot.3, if_nameindex.3, if_nametoindex.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, j0.3, ldexp.3, localeconv.3, log.3, log10.3, log1p.3, log2.3, logb.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, mallinfo.3, malloc.3, malloc_get_state.3, malloc_info.3, malloc_stats.3, malloc_trim.3, malloc_usable_size.3, mallopt.3, matherr.3, mcheck.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, on_exit.3, opendir.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, profil.3, psignal.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_detach.3, pthread_equal.3, pthread_exit.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_join.3, pthread_kill.3, pthread_kill_other_threads_np.3, pthread_self.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_setschedprio.3, pthread_sigmask.3, pthread_sigqueue.3, pthread_testcancel.3, pthread_tryjoin_np.3, pthread_yield.3, putenv.3, putpwent.3, puts.3, qecvt.3, qsort.3, raise.3, rand.3, random.3, random_r.3, re_comp.3, readdir.3, realpath.3, regex.3, remainder.3, remove.3, resolver.3, rewinddir.3, rint.3, round.3, scalb.3, scalbln.3, scandir.3, sched_getcpu.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setenv.3, setlocale.3, setlogmask.3, shm_open.3, siginterrupt.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sigwait.3, sin.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdio_ext.3, stpcpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfry.3, strftime.3, string.3, strlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, trunc.3, tsearch.3, ttyslot.3, tzset.3, ulimit.3, undocumented.3, unlocked_stdio.3, usleep.3, y0.3, cpuid.4, full.4, initrd.4, mouse.4, msr.4, sd.4, st.4, acct.5, core.5, services.5, slabinfo.5, aio.7, capabilities.7, credentials.7, feature_test_macros.7, hier.7, inotify.7, libc.7, locale.7, man-pages.7, man.7, math_error.7, mq_overview.7, numa.7, path_resolution.7, pipe.7, pthreads.7, pty.7, rtld-audit.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, suffixes.7, svipc.7, termio.7, time.7, udplite.7, units.7, uri.7, sln.8: Global fix: Add LICENSE_START(verbatim)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-03-10 09:28:40 +00:00
|
|
|
.\" %%%LICENSE_END
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
|
|
|
.\" 6 Aug 2002 - Initial Creation
|
2007-09-20 06:52:22 +00:00
|
|
|
.\" Modified 2003-05-23, Michael Kerrisk, <mtk.manpages@gmail.com>
|
|
|
|
.\" Modified 2004-05-27, Michael Kerrisk, <mtk.manpages@gmail.com>
|
2004-12-08 16:41:10 +00:00
|
|
|
.\" 2004-12-08, mtk Added O_NOATIME for CAP_FOWNER
|
2005-08-16 12:32:03 +00:00
|
|
|
.\" 2005-08-16, mtk, Added CAP_AUDIT_CONTROL and CAP_AUDIT_WRITE
|
2008-07-09 12:11:50 +00:00
|
|
|
.\" 2008-07-15, Serge Hallyn <serue@us.bbm.com>
|
|
|
|
.\" Document file capabilities, per-process capability
|
|
|
|
.\" bounding set, changed semantics for CAP_SETPCAP,
|
|
|
|
.\" and other changes in 2.6.2[45].
|
|
|
|
.\" Add CAP_MAC_ADMIN, CAP_MAC_OVERRIDE, CAP_SETFCAP.
|
|
|
|
.\" 2008-07-15, mtk
|
|
|
|
.\" Add text describing circumstances in which CAP_SETPCAP
|
|
|
|
.\" (theoretically) permits a thread to change the
|
|
|
|
.\" capability sets of another thread.
|
|
|
|
.\" Add section describing rules for programmatically
|
|
|
|
.\" adjusting thread capability sets.
|
|
|
|
.\" Describe rationale for capability bounding set.
|
|
|
|
.\" Document "securebits" flags.
|
|
|
|
.\" Add text noting that if we set the effective flag for one file
|
|
|
|
.\" capability, then we must also set the effective flag for all
|
|
|
|
.\" other capabilities where the permitted or inheritable bit is set.
|
2011-09-08 01:37:09 +00:00
|
|
|
.\" 2011-09-07, mtk/Serge hallyn: Add CAP_SYSLOG
|
2005-08-16 12:32:03 +00:00
|
|
|
.\"
|
intro.1, clock_getres.2, execve.2, fcntl.2, iopl.2, lseek.2, mknod.2, mmap.2, mount.2, mq_getsetattr.2, pidfd_open.2, prctl.2, setns.2, sgetmask.2, sigaction.2, stat.2, statx.2, sync.2, syscalls.2, syslog.2, timerfd_create.2, umask.2, a64l.3, aio_init.3, atoi.3, dladdr.3, fread.3, getpt.3, isfdtype.3, malloc_stats.3, malloc_trim.3, mkfifo.3, mq_close.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, posix_memalign.3, posix_openpt.3, pthread_atfork.3, pthread_rwlockattr_setkind_np.3, regex.3, scanf.3, sem_close.3, sem_destroy.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sigset.3, sigvec.3, strftime.3, termios.3, console_codes.4, dsp56k.4, fd.4, lp.4, mouse.4, pts.4, sk98lin.4, dir_colors.5, proc.5, resolv.conf.5, termcap.5, utmp.5, aio.7, armscii-8.7, arp.7, capabilities.7, cgroups.7, charsets.7, cp1251.7, cp1252.7, environ.7, glob.7, inode.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, keyrings.7, koi8-r.7, koi8-u.7, mailaddr.7, man-pages.7, netdevice.7, operator.7, persistent-keyring.7, process-keyring.7, pthreads.7, pty.7, raw.7, regex.7, session-keyring.7, shm_overview.7, signal.7, socket.7, suffixes.7, thread-keyring.7, unicode.7, units.7, uri.7, user-keyring.7, user-session-keyring.7, iconvconfig.8, ld.so.8, zic.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-08-13 08:01:14 +00:00
|
|
|
.TH CAPABILITIES 7 2020-08-13 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
capabilities \- overview of Linux capabilities
|
|
|
|
.SH DESCRIPTION
|
|
|
|
For the purpose of performing permission checks,
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
traditional UNIX implementations distinguish two categories of processes:
|
2004-11-03 13:51:07 +00:00
|
|
|
.I privileged
|
|
|
|
processes (whose effective user ID is 0, referred to as superuser or root),
|
|
|
|
and
|
|
|
|
.I unprivileged
|
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt.2, gettimeofday.2, intro.2, ioctl_list.2, ioperm.2, mlock.2, pivot_root.2, poll.2, prctl.2, ptrace.2, sched_setscheduler.2, select_tut.2, semget.2, sigaltstack.2, signalfd.2, sysctl.2, timer_settime.2, timerfd_create.2, wait.2, CPU_SET.3, argz_add.3, assert_perror.3, atexit.3, backtrace.3, bcmp.3, clearenv.3, ctime.3, dl_iterate_phdr.3, dlopen.3, ecvt.3, errno.3, error.3, ether_aton.3, exit.3, fenv.3, ferror.3, finite.3, flockfile.3, fnmatch.3, fpathconf.3, fpclassify.3, ftime.3, ftok.3, ftw.3, fwide.3, getaddrinfo.3, gethostbyname.3, getlogin.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getrpcent.3, getservent.3, glob.3, hsearch.3, inet.3, isalpha.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, longjmp.3, lsearch.3, malloc.3, matherr.3, mblen.3, mbsinit.3, mbtowc.3, on_exit.3, printf.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_equal.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, ptsname.3, putenv.3, putgrent.3, raise.3, rcmd.3, regex.3, rexec.3, rpc.3, rpmatch.3, rtnetlink.3, scandir.3, sem_init.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, signbit.3, stdio_ext.3, strtod.3, strtol.3, strtoul.3, system.3, termios.3, timeradd.3, tzset.3, ualarm.3, wctomb.3, xdr.3, st.4, tty_ioctl.4, core.5, elf.5, proc.5, bootparam.7, capabilities.7, icmp.7, ip.7, ipv6.7, math_error.7, mdoc.samples.7, mq_overview.7, pthreads.7, raw.7, regex.7, socket.7, tcp.7, tzselect.8: Global fix: s/non-zero/nonzero/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:40:55 +00:00
|
|
|
processes (whose effective UID is nonzero).
|
2004-11-03 13:51:07 +00:00
|
|
|
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).
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2007-04-12 22:42:49 +00:00
|
|
|
Starting with kernel 2.2, Linux divides the privileges traditionally
|
|
|
|
associated with superuser into distinct units, known as
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR capabilities ,
|
2005-10-28 17:41:30 +00:00
|
|
|
which can be independently enabled and disabled.
|
2006-05-02 00:36:39 +00:00
|
|
|
Capabilities are a per-thread attribute.
|
2008-07-09 12:11:50 +00:00
|
|
|
.\"
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS Capabilities list
|
2008-07-09 12:11:50 +00:00
|
|
|
The following list shows the capabilities implemented on Linux,
|
|
|
|
and the operations or behaviors that each capability permits:
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2005-08-16 15:14:36 +00:00
|
|
|
.BR CAP_AUDIT_CONTROL " (since Linux 2.6.11)"
|
2005-08-16 12:32:03 +00:00
|
|
|
Enable and disable kernel auditing; change auditing filter rules;
|
|
|
|
retrieve auditing status and filtering rules.
|
|
|
|
.TP
|
2014-06-16 10:09:13 +00:00
|
|
|
.BR CAP_AUDIT_READ " (since Linux 3.16)"
|
|
|
|
.\" commit a29b694aa1739f9d76538e34ae25524f9c549d59
|
|
|
|
.\" commit 3a101b8de0d39403b2c7e5c23fd0b005668acf48
|
|
|
|
Allow reading the audit log via a multicast netlink socket.
|
|
|
|
.TP
|
2005-08-16 15:14:36 +00:00
|
|
|
.BR CAP_AUDIT_WRITE " (since Linux 2.6.11)"
|
2008-07-09 12:11:50 +00:00
|
|
|
Write records to kernel auditing log.
|
2019-02-15 09:07:04 +00:00
|
|
|
.\" FIXME Add FAN_ENABLE_AUDIT
|
2005-08-16 12:32:03 +00:00
|
|
|
.TP
|
2012-07-16 05:55:30 +00:00
|
|
|
.BR CAP_BLOCK_SUSPEND " (since Linux 3.5)"
|
|
|
|
Employ features that can block system suspend
|
|
|
|
.RB ( epoll (7)
|
|
|
|
.BR EPOLLWAKEUP ,
|
|
|
|
.IR /proc/sys/wake_lock ).
|
|
|
|
.TP
|
2020-06-12 10:15:02 +00:00
|
|
|
.BR CAP_BPF " (since Linux 5.8)"
|
|
|
|
Employ privileged BPF operations; see
|
|
|
|
.BR bpf (2)
|
|
|
|
and
|
intro.1, localedef.1, memusage.1, memusagestat.1, bpf.2, execve.2, fork.2, keyctl.2, request_key.2, sigaction.2, signal.2, socket.2, dlopen.3, getauxval.3, gnu_get_libc_version.3, pthread_atfork.3, sem_post.3, setjmp.3, strftime.3, veth.4, locale.5, nscd.conf.5, resolv.conf.5, address_families.7, armscii-8.7, ascii.7, capabilities.7, cgroups.7, charsets.7, cp1251.7, cp1252.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, keyrings.7, koi8-r.7, koi8-u.7, libc.7, locale.7, man.7, network_namespaces.7, persistent-keyring.7, session-keyring.7, signal.7, unicode.7, uri.7, user-keyring.7, user-session-keyring.7: ffix: replace - with real\-
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-07-06 12:28:51 +00:00
|
|
|
.BR bpf\-helpers (7).
|
2020-06-12 10:15:02 +00:00
|
|
|
.IP
|
|
|
|
This capability was added in Linux 5.8 to separate out
|
|
|
|
BPF functionality from the overloaded
|
|
|
|
.BR CAP_SYS_ADMIN
|
|
|
|
capability.
|
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B CAP_CHOWN
|
2008-07-09 12:11:50 +00:00
|
|
|
Make arbitrary changes to file UIDs and GIDs (see
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR chown (2)).
|
|
|
|
.TP
|
|
|
|
.B CAP_DAC_OVERRIDE
|
|
|
|
Bypass file read, write, and execute permission checks.
|
2008-07-09 12:11:50 +00:00
|
|
|
(DAC is an abbreviation of "discretionary access control".)
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_DAC_READ_SEARCH
|
2013-02-20 13:13:01 +00:00
|
|
|
.PD 0
|
|
|
|
.RS
|
|
|
|
.IP * 2
|
2004-11-03 13:51:07 +00:00
|
|
|
Bypass file read permission checks and
|
2013-02-20 13:13:01 +00:00
|
|
|
directory read and execute permission checks;
|
|
|
|
.IP *
|
2016-10-18 07:50:16 +00:00
|
|
|
invoke
|
2016-12-16 08:10:40 +00:00
|
|
|
.BR open_by_handle_at (2);
|
|
|
|
.IP *
|
|
|
|
use the
|
|
|
|
.BR linkat (2)
|
|
|
|
.B AT_EMPTY_PATH
|
|
|
|
flag to create a link to a file referred to by a file descriptor.
|
2013-02-20 13:13:01 +00:00
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_FOWNER
|
2008-07-09 12:11:50 +00:00
|
|
|
.PD 0
|
|
|
|
.RS
|
|
|
|
.IP * 2
|
2004-11-03 13:51:07 +00:00
|
|
|
Bypass permission checks on operations that normally
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
require the filesystem UID of the process to match the UID of
|
2004-11-03 13:51:07 +00:00
|
|
|
the file (e.g.,
|
|
|
|
.BR chmod (2),
|
|
|
|
.BR utime (2)),
|
2008-07-09 12:11:50 +00:00
|
|
|
excluding those operations covered by
|
2004-11-03 13:51:07 +00:00
|
|
|
.B CAP_DAC_OVERRIDE
|
|
|
|
and
|
|
|
|
.BR CAP_DAC_READ_SEARCH ;
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2017-01-18 05:41:19 +00:00
|
|
|
set inode flags (see
|
|
|
|
.BR ioctl_iflags (2))
|
2004-11-03 13:51:07 +00:00
|
|
|
on arbitrary files;
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2004-11-03 13:51:07 +00:00
|
|
|
set Access Control Lists (ACLs) on arbitrary files;
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2004-12-08 16:41:10 +00:00
|
|
|
ignore directory sticky bit on file deletion;
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2019-07-01 07:48:11 +00:00
|
|
|
modify
|
|
|
|
.I user
|
|
|
|
extended attributes on sticky directory owned by any user;
|
|
|
|
.IP *
|
2004-12-08 16:41:10 +00:00
|
|
|
specify
|
|
|
|
.B O_NOATIME
|
|
|
|
for arbitrary files in
|
|
|
|
.BR open (2)
|
|
|
|
and
|
|
|
|
.BR fcntl (2).
|
2008-07-09 12:11:50 +00:00
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_FSETID
|
2016-10-18 07:50:16 +00:00
|
|
|
.PD 0
|
|
|
|
.RS
|
|
|
|
.IP * 2
|
2015-04-21 11:18:15 +00:00
|
|
|
Don't clear set-user-ID and set-group-ID mode
|
2008-07-09 12:11:50 +00:00
|
|
|
bits when a file is modified;
|
2016-10-18 07:50:16 +00:00
|
|
|
.IP *
|
2008-07-09 12:11:50 +00:00
|
|
|
set the set-group-ID bit for a file whose GID does not match
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
the filesystem or any of the supplementary GIDs of the calling process.
|
2016-10-18 07:50:16 +00:00
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_IPC_LOCK
|
adjtimex.2, bind.2, cacheflush.2, clone.2, fallocate.2, fanotify_init.2, fanotify_mark.2, flock.2, futex.2, getdents.2, getpriority.2, getrlimit.2, gettid.2, gettimeofday.2, ioprio_set.2, kexec_load.2, migrate_pages.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, msgop.2, nfsservctl.2, perf_event_open.2, pread.2, ptrace.2, recvmmsg.2, rename.2, restart_syscall.2, sched_setattr.2, send.2, shmop.2, shutdown.2, sigaction.2, signalfd.2, syscalls.2, timer_create.2, timerfd_create.2, tkill.2, vmsplice.2, wait.2, aio_init.3, confstr.3, exit.3, fmemopen.3, fopen.3, getaddrinfo.3, getauxval.3, getspnam.3, isalpha.3, isatty.3, mallinfo.3, malloc.3, mallopt.3, psignal.3, pthread_attr_setinheritsched.3, qecvt.3, queue.3, rtnetlink.3, strerror.3, strftime.3, toupper.3, towlower.3, towupper.3, initrd.4, locale.5, proc.5, bootparam.7, capabilities.7, ddp.7, fanotify.7, icmp.7, inotify.7, ip.7, ipv6.7, netdevice.7, netlink.7, path_resolution.7, rtld-audit.7, rtnetlink.7, sched.7, signal.7, socket.7, svipc.7, tcp.7, unix.7, ld.so.8: srcfix: Update FIXMEs
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-08-21 21:47:44 +00:00
|
|
|
.\" FIXME . As at Linux 3.2, there are some strange uses of this capability
|
2012-03-03 08:35:09 +00:00
|
|
|
.\" in other places; they probably should be replaced with something else.
|
2008-07-09 12:11:50 +00:00
|
|
|
Lock memory
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB ( mlock (2),
|
|
|
|
.BR mlockall (2),
|
|
|
|
.BR mmap (2),
|
|
|
|
.BR shmctl (2)).
|
|
|
|
.TP
|
|
|
|
.B CAP_IPC_OWNER
|
|
|
|
Bypass permission checks for operations on System V IPC objects.
|
|
|
|
.TP
|
|
|
|
.B CAP_KILL
|
|
|
|
Bypass permission checks for sending signals (see
|
|
|
|
.BR kill (2)).
|
2007-06-22 20:40:07 +00:00
|
|
|
This includes use of the
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR ioctl (2)
|
2007-06-22 20:40:07 +00:00
|
|
|
.B KDSIGACCEPT
|
2008-07-09 12:11:50 +00:00
|
|
|
operation.
|
adjtimex.2, bind.2, cacheflush.2, clone.2, fallocate.2, fanotify_init.2, fanotify_mark.2, flock.2, futex.2, getdents.2, getpriority.2, getrlimit.2, gettid.2, gettimeofday.2, ioprio_set.2, kexec_load.2, migrate_pages.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, msgop.2, nfsservctl.2, perf_event_open.2, pread.2, ptrace.2, recvmmsg.2, rename.2, restart_syscall.2, sched_setattr.2, send.2, shmop.2, shutdown.2, sigaction.2, signalfd.2, syscalls.2, timer_create.2, timerfd_create.2, tkill.2, vmsplice.2, wait.2, aio_init.3, confstr.3, exit.3, fmemopen.3, fopen.3, getaddrinfo.3, getauxval.3, getspnam.3, isalpha.3, isatty.3, mallinfo.3, malloc.3, mallopt.3, psignal.3, pthread_attr_setinheritsched.3, qecvt.3, queue.3, rtnetlink.3, strerror.3, strftime.3, toupper.3, towlower.3, towupper.3, initrd.4, locale.5, proc.5, bootparam.7, capabilities.7, ddp.7, fanotify.7, icmp.7, inotify.7, ip.7, ipv6.7, netdevice.7, netlink.7, path_resolution.7, rtld-audit.7, rtnetlink.7, sched.7, signal.7, socket.7, svipc.7, tcp.7, unix.7, ld.so.8: srcfix: Update FIXMEs
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-08-21 21:47:44 +00:00
|
|
|
.\" FIXME . CAP_KILL also has an effect for threads + setting child
|
2006-07-31 12:52:31 +00:00
|
|
|
.\" termination signal to other than SIGCHLD: without this
|
|
|
|
.\" capability, the termination signal reverts to SIGCHLD
|
2007-04-12 22:42:49 +00:00
|
|
|
.\" if the child does an exec(). What is the rationale
|
2006-07-31 12:52:31 +00:00
|
|
|
.\" for this?
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR CAP_LEASE " (since Linux 2.4)"
|
|
|
|
Establish leases on arbitrary files (see
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR fcntl (2)).
|
|
|
|
.TP
|
|
|
|
.B CAP_LINUX_IMMUTABLE
|
2008-07-09 12:11:50 +00:00
|
|
|
Set the
|
|
|
|
.B FS_APPEND_FL
|
2004-11-03 13:51:07 +00:00
|
|
|
and
|
2008-07-09 12:11:50 +00:00
|
|
|
.B FS_IMMUTABLE_FL
|
2014-11-12 21:32:40 +00:00
|
|
|
inode flags (see
|
2017-01-18 05:41:19 +00:00
|
|
|
.BR ioctl_iflags (2)).
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR CAP_MAC_ADMIN " (since Linux 2.6.25)"
|
2017-07-05 08:53:17 +00:00
|
|
|
Allow MAC configuration or state changes.
|
2008-07-09 12:11:50 +00:00
|
|
|
Implemented for the Smack Linux Security Module (LSM).
|
|
|
|
.TP
|
|
|
|
.BR CAP_MAC_OVERRIDE " (since Linux 2.6.25)"
|
2017-07-05 08:53:17 +00:00
|
|
|
Override Mandatory Access Control (MAC).
|
2008-07-09 12:11:50 +00:00
|
|
|
Implemented for the Smack LSM.
|
|
|
|
.TP
|
|
|
|
.BR CAP_MKNOD " (since Linux 2.4)"
|
|
|
|
Create special files using
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR mknod (2).
|
|
|
|
.TP
|
|
|
|
.B CAP_NET_ADMIN
|
2012-03-04 23:05:30 +00:00
|
|
|
Perform various network-related operations:
|
|
|
|
.PD 0
|
|
|
|
.RS
|
|
|
|
.IP * 2
|
|
|
|
interface configuration;
|
|
|
|
.IP *
|
2013-03-17 07:08:34 +00:00
|
|
|
administration of IP firewall, masquerading, and accounting;
|
2012-03-04 23:05:30 +00:00
|
|
|
.IP *
|
|
|
|
modify routing tables;
|
|
|
|
.IP *
|
|
|
|
bind to any address for transparent proxying;
|
|
|
|
.IP *
|
2020-04-19 19:20:09 +00:00
|
|
|
set type-of-service (TOS);
|
2012-03-04 23:05:30 +00:00
|
|
|
.IP *
|
|
|
|
clear driver statistics;
|
|
|
|
.IP *
|
|
|
|
set promiscuous mode;
|
|
|
|
.IP *
|
|
|
|
enabling multicasting;
|
|
|
|
.IP *
|
|
|
|
use
|
|
|
|
.BR setsockopt (2)
|
|
|
|
to set the following socket options:
|
|
|
|
.BR SO_DEBUG ,
|
|
|
|
.BR SO_MARK ,
|
|
|
|
.BR SO_PRIORITY
|
|
|
|
(for a priority outside the range 0 to 6),
|
|
|
|
.BR SO_RCVBUFFORCE ,
|
|
|
|
and
|
|
|
|
.BR SO_SNDBUFFORCE .
|
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_NET_BIND_SERVICE
|
2008-12-04 11:37:25 +00:00
|
|
|
Bind a socket to Internet domain privileged ports
|
2004-11-03 13:51:07 +00:00
|
|
|
(port numbers less than 1024).
|
|
|
|
.TP
|
|
|
|
.B CAP_NET_BROADCAST
|
2008-07-09 12:11:50 +00:00
|
|
|
(Unused) Make socket broadcasts, and listen to multicasts.
|
2017-11-07 20:18:30 +00:00
|
|
|
.\" FIXME Since Linux 4.2, there are use cases for netlink sockets
|
|
|
|
.\" commit 59324cf35aba5336b611074028777838a963d03b
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_NET_RAW
|
2012-03-04 23:12:05 +00:00
|
|
|
.PD 0
|
|
|
|
.RS
|
|
|
|
.IP * 2
|
2016-12-16 08:19:01 +00:00
|
|
|
Use RAW and PACKET sockets;
|
2012-03-04 23:12:05 +00:00
|
|
|
.IP *
|
|
|
|
bind to any address for transparent proxying.
|
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Also various IP options and setsockopt(SO_BINDTODEVICE)
|
|
|
|
.TP
|
2020-06-12 09:50:57 +00:00
|
|
|
.BR CAP_PERFMON " (since Linux 5.8)"
|
|
|
|
Employ various performance-monitoring mechanisms, including:
|
|
|
|
.PD 0
|
|
|
|
.RS
|
2020-08-22 20:23:15 +00:00
|
|
|
.IP * 2
|
2020-06-12 09:50:57 +00:00
|
|
|
call
|
|
|
|
.BR perf_event_open (2);
|
|
|
|
.IP *
|
|
|
|
employ various BPF operations that have performance implications.
|
|
|
|
.RE
|
|
|
|
.PD
|
|
|
|
.IP
|
|
|
|
This capability was added in Linux 5.8 to separate out
|
|
|
|
performance monitoring functionality from the overloaded
|
|
|
|
.BR CAP_SYS_ADMIN
|
|
|
|
capability.
|
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B CAP_SETGID
|
2016-10-18 07:50:16 +00:00
|
|
|
.RS
|
|
|
|
.PD 0
|
|
|
|
.IP * 2
|
2008-07-09 12:11:50 +00:00
|
|
|
Make arbitrary manipulations of process GIDs and supplementary GID list;
|
2016-10-18 07:50:16 +00:00
|
|
|
.IP *
|
2013-02-25 17:39:13 +00:00
|
|
|
forge GID when passing socket credentials via UNIX domain sockets;
|
2016-10-18 07:50:16 +00:00
|
|
|
.IP *
|
2013-02-25 17:39:13 +00:00
|
|
|
write a group ID mapping in a user namespace (see
|
2013-02-27 06:40:40 +00:00
|
|
|
.BR user_namespaces (7)).
|
2016-10-18 07:50:16 +00:00
|
|
|
.PD
|
|
|
|
.RE
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR CAP_SETFCAP " (since Linux 2.6.24)"
|
2017-12-14 20:59:45 +00:00
|
|
|
Set arbitrary capabilities on a file.
|
2008-07-09 12:11:50 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SETPCAP
|
2017-12-05 14:33:56 +00:00
|
|
|
If file capabilities are supported (i.e., since Linux 2.6.24):
|
2008-07-09 12:11:50 +00:00
|
|
|
add any capability from the calling thread's bounding set
|
|
|
|
to its inheritable set;
|
|
|
|
drop capabilities from the bounding set (via
|
|
|
|
.BR prctl (2)
|
|
|
|
.BR PR_CAPBSET_DROP );
|
|
|
|
make changes to the
|
|
|
|
.I securebits
|
|
|
|
flags.
|
2017-12-05 14:33:56 +00:00
|
|
|
.IP
|
|
|
|
If file capabilities are not supported (i.e., kernels before Linux 2.6.24):
|
|
|
|
grant or remove any capability in the
|
|
|
|
caller's permitted capability set to or from any other process.
|
|
|
|
(This property of
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
is not available when the kernel is configured to support
|
|
|
|
file capabilities, since
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
has entirely different semantics for such kernels.)
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SETUID
|
2016-10-18 07:50:16 +00:00
|
|
|
.RS
|
|
|
|
.PD 0
|
|
|
|
.IP * 2
|
2008-07-09 12:11:50 +00:00
|
|
|
Make arbitrary manipulations of process UIDs
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB ( setuid (2),
|
|
|
|
.BR setreuid (2),
|
|
|
|
.BR setresuid (2),
|
|
|
|
.BR setfsuid (2));
|
2016-10-18 07:50:16 +00:00
|
|
|
.IP *
|
2013-02-25 17:39:42 +00:00
|
|
|
forge UID when passing socket credentials via UNIX domain sockets;
|
2016-10-18 07:50:16 +00:00
|
|
|
.IP *
|
2013-02-25 17:39:13 +00:00
|
|
|
write a user ID mapping in a user namespace (see
|
2013-02-27 06:40:40 +00:00
|
|
|
.BR user_namespaces (7)).
|
2016-10-18 07:50:16 +00:00
|
|
|
.PD
|
|
|
|
.RE
|
2006-03-20 04:46:28 +00:00
|
|
|
.\" FIXME CAP_SETUID also an effect in exec(); document this.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_ADMIN
|
2016-12-20 08:29:56 +00:00
|
|
|
.IR Note :
|
|
|
|
this capability is overloaded; see
|
|
|
|
.IR "Notes to kernel developers" ,
|
|
|
|
below.
|
2017-08-12 21:25:45 +00:00
|
|
|
.IP
|
2008-07-09 12:11:50 +00:00
|
|
|
.PD 0
|
|
|
|
.RS
|
|
|
|
.IP * 2
|
|
|
|
Perform a range of system administration operations including:
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR quotactl (2),
|
|
|
|
.BR mount (2),
|
|
|
|
.BR umount (2),
|
2019-07-28 07:39:28 +00:00
|
|
|
.BR pivot_root (2),
|
2007-12-10 15:03:27 +00:00
|
|
|
.BR swapon (2),
|
|
|
|
.BR swapoff (2),
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR sethostname (2),
|
2008-11-28 14:57:56 +00:00
|
|
|
and
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR setdomainname (2);
|
|
|
|
.IP *
|
2011-09-08 01:37:09 +00:00
|
|
|
perform privileged
|
|
|
|
.BR syslog (2)
|
|
|
|
operations (since Linux 2.6.37,
|
|
|
|
.BR CAP_SYSLOG
|
|
|
|
should be used to permit such operations);
|
|
|
|
.IP *
|
2008-07-09 12:11:50 +00:00
|
|
|
perform
|
2012-03-05 00:25:10 +00:00
|
|
|
.B VM86_REQUEST_IRQ
|
|
|
|
.BR vm86 (2)
|
|
|
|
command;
|
|
|
|
.IP *
|
|
|
|
perform
|
2004-11-03 13:51:07 +00:00
|
|
|
.B IPC_SET
|
|
|
|
and
|
|
|
|
.B IPC_RMID
|
|
|
|
operations on arbitrary System V IPC objects;
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2014-05-14 04:06:39 +00:00
|
|
|
override
|
|
|
|
.B RLIMIT_NPROC
|
|
|
|
resource limit;
|
|
|
|
.IP *
|
2004-11-03 13:51:07 +00:00
|
|
|
perform operations on
|
|
|
|
.I trusted
|
|
|
|
and
|
|
|
|
.I security
|
2020-04-19 14:42:00 +00:00
|
|
|
extended attributes (see
|
2015-04-22 12:40:38 +00:00
|
|
|
.BR xattr (7));
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
|
|
|
use
|
2006-03-15 11:13:30 +00:00
|
|
|
.BR lookup_dcookie (2);
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2006-05-09 11:42:37 +00:00
|
|
|
use
|
|
|
|
.BR ioprio_set (2)
|
|
|
|
to assign
|
|
|
|
.B IOPRIO_CLASS_RT
|
2008-07-08 10:16:26 +00:00
|
|
|
and (before Linux 2.6.25)
|
2006-08-08 16:35:21 +00:00
|
|
|
.B IOPRIO_CLASS_IDLE
|
2006-05-09 11:42:37 +00:00
|
|
|
I/O scheduling classes;
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2015-01-16 07:15:05 +00:00
|
|
|
forge PID when passing socket credentials via UNIX domain sockets;
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2004-11-03 13:51:07 +00:00
|
|
|
exceed
|
2005-10-28 17:41:30 +00:00
|
|
|
.IR /proc/sys/fs/file-max ,
|
|
|
|
the system-wide limit on the number of open files,
|
|
|
|
in system calls that open files (e.g.,
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR accept (2),
|
|
|
|
.BR execve (2),
|
|
|
|
.BR open (2),
|
2008-11-28 14:57:56 +00:00
|
|
|
.BR pipe (2));
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2007-04-12 22:42:49 +00:00
|
|
|
employ
|
2012-03-01 18:27:40 +00:00
|
|
|
.B CLONE_*
|
|
|
|
flags that create new namespaces with
|
2006-07-31 12:52:31 +00:00
|
|
|
.BR clone (2)
|
|
|
|
and
|
2013-01-06 21:26:52 +00:00
|
|
|
.BR unshare (2)
|
|
|
|
(but, since Linux 3.8,
|
|
|
|
creating user namespaces does not require any capability);
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2020-06-12 09:50:57 +00:00
|
|
|
employ various performance monitoring mechanisms (as for
|
|
|
|
.BR CAP_PERFMON );
|
2012-03-05 00:26:03 +00:00
|
|
|
.IP *
|
|
|
|
access privileged
|
|
|
|
.I perf
|
|
|
|
event information;
|
2012-03-06 18:35:22 +00:00
|
|
|
.IP *
|
|
|
|
call
|
2013-03-07 08:52:01 +00:00
|
|
|
.BR setns (2)
|
|
|
|
(requires
|
|
|
|
.B CAP_SYS_ADMIN
|
|
|
|
in the
|
|
|
|
.I target
|
|
|
|
namespace);
|
2011-09-09 00:34:18 +00:00
|
|
|
.IP *
|
2012-03-01 18:27:40 +00:00
|
|
|
call
|
|
|
|
.BR fanotify_init (2);
|
|
|
|
.IP *
|
2020-06-24 10:01:06 +00:00
|
|
|
perform various BPF operations;
|
2020-06-12 10:15:02 +00:00
|
|
|
see
|
|
|
|
.BR CAP_BPF ;
|
2015-05-26 13:07:20 +00:00
|
|
|
.IP *
|
2016-10-19 08:53:38 +00:00
|
|
|
perform privileged
|
2006-07-31 12:52:31 +00:00
|
|
|
.B KEYCTL_CHOWN
|
|
|
|
and
|
|
|
|
.B KEYCTL_SETPERM
|
|
|
|
.BR keyctl (2)
|
2010-06-19 04:07:06 +00:00
|
|
|
operations;
|
|
|
|
.IP *
|
|
|
|
perform
|
|
|
|
.BR madvise (2)
|
|
|
|
.B MADV_HWPOISON
|
2012-03-01 18:27:40 +00:00
|
|
|
operation;
|
|
|
|
.IP *
|
|
|
|
employ the
|
|
|
|
.B TIOCSTI
|
|
|
|
.BR ioctl (2)
|
|
|
|
to insert characters into the input queue of a terminal other than
|
2014-05-13 13:56:39 +00:00
|
|
|
the caller's controlling terminal;
|
2012-03-01 18:27:40 +00:00
|
|
|
.IP *
|
|
|
|
employ the obsolete
|
2012-05-07 21:16:44 +00:00
|
|
|
.BR nfsservctl (2)
|
2012-03-05 00:11:39 +00:00
|
|
|
system call;
|
|
|
|
.IP *
|
|
|
|
employ the obsolete
|
2012-03-01 18:27:40 +00:00
|
|
|
.BR bdflush (2)
|
|
|
|
system call;
|
|
|
|
.IP *
|
|
|
|
perform various privileged block-device
|
|
|
|
.BR ioctl (2)
|
|
|
|
operations;
|
|
|
|
.IP *
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
perform various privileged filesystem
|
2012-03-01 18:27:40 +00:00
|
|
|
.BR ioctl (2)
|
|
|
|
operations;
|
|
|
|
.IP *
|
2016-11-09 13:51:17 +00:00
|
|
|
perform privileged
|
|
|
|
.BR ioctl (2)
|
|
|
|
operations on the
|
|
|
|
.IR /dev/random
|
|
|
|
device (see
|
|
|
|
.BR random (4));
|
|
|
|
.IP *
|
2016-12-15 18:17:26 +00:00
|
|
|
install a
|
|
|
|
.BR seccomp (2)
|
|
|
|
filter without first having to set the
|
|
|
|
.I no_new_privs
|
|
|
|
thread attribute;
|
|
|
|
.IP *
|
2016-12-15 19:53:50 +00:00
|
|
|
modify allow/deny rules for device control groups;
|
|
|
|
.IP *
|
|
|
|
employ the
|
|
|
|
.BR ptrace (2)
|
|
|
|
.B PTRACE_SECCOMP_GET_FILTER
|
|
|
|
operation to dump tracee's seccomp filters;
|
|
|
|
.IP *
|
|
|
|
employ the
|
|
|
|
.BR ptrace (2)
|
|
|
|
.B PTRACE_SETOPTIONS
|
|
|
|
operation to suspend the tracee's seccomp protections (i.e., the
|
|
|
|
.B PTRACE_O_SUSPEND_SECCOMP
|
2018-04-19 09:18:31 +00:00
|
|
|
flag);
|
2016-12-15 18:17:26 +00:00
|
|
|
.IP *
|
2012-03-01 18:27:40 +00:00
|
|
|
perform administrative operations on many device drivers.
|
2019-08-02 11:55:47 +00:00
|
|
|
.IP *
|
|
|
|
Modify autogroup nice values by writing to
|
2019-08-26 07:22:58 +00:00
|
|
|
.IR /proc/[pid]/autogroup
|
2019-08-02 11:55:47 +00:00
|
|
|
(see
|
|
|
|
.BR sched (7)).
|
2008-07-09 12:11:50 +00:00
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_BOOT
|
2008-07-09 12:11:50 +00:00
|
|
|
Use
|
2006-03-15 11:13:30 +00:00
|
|
|
.BR reboot (2)
|
|
|
|
and
|
|
|
|
.BR kexec_load (2).
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_CHROOT
|
2019-02-15 09:16:36 +00:00
|
|
|
.RS
|
|
|
|
.PD 0
|
|
|
|
.IP * 2
|
2008-07-09 12:11:50 +00:00
|
|
|
Use
|
2019-02-15 09:16:36 +00:00
|
|
|
.BR chroot (2);
|
|
|
|
.IP *
|
|
|
|
change mount namespaces using
|
|
|
|
.BR setns (2).
|
|
|
|
.PD
|
|
|
|
.RE
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_MODULE
|
2016-10-18 07:50:16 +00:00
|
|
|
.RS
|
|
|
|
.PD 0
|
|
|
|
.IP * 2
|
2008-07-09 12:11:50 +00:00
|
|
|
Load and unload kernel modules
|
|
|
|
(see
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR init_module (2)
|
|
|
|
and
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR delete_module (2));
|
2016-10-18 07:50:16 +00:00
|
|
|
.IP *
|
2008-07-09 12:11:50 +00:00
|
|
|
in kernels before 2.6.25:
|
|
|
|
drop capabilities from the system-wide capability bounding set.
|
2016-10-18 07:50:16 +00:00
|
|
|
.PD
|
|
|
|
.RE
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_NICE
|
2008-07-09 12:11:50 +00:00
|
|
|
.PD 0
|
|
|
|
.RS
|
|
|
|
.IP * 2
|
2020-06-24 11:43:06 +00:00
|
|
|
Lower the process nice value
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB ( nice (2),
|
|
|
|
.BR setpriority (2))
|
2008-07-09 12:11:50 +00:00
|
|
|
and change the nice value for arbitrary processes;
|
|
|
|
.IP *
|
|
|
|
set real-time scheduling policies for calling process,
|
|
|
|
and set scheduling policies and priorities for arbitrary processes
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB ( sched_setscheduler (2),
|
2014-05-14 04:53:58 +00:00
|
|
|
.BR sched_setparam (2),
|
2018-08-03 14:04:45 +00:00
|
|
|
.BR sched_setattr (2));
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2004-11-03 13:51:07 +00:00
|
|
|
set CPU affinity for arbitrary processes
|
2007-04-12 22:42:49 +00:00
|
|
|
.RB ( sched_setaffinity (2));
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2006-05-09 11:42:37 +00:00
|
|
|
set I/O scheduling class and priority for arbitrary processes
|
2007-04-12 22:42:49 +00:00
|
|
|
.RB ( ioprio_set (2));
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
|
|
|
apply
|
2006-05-09 11:42:37 +00:00
|
|
|
.BR migrate_pages (2)
|
2008-07-09 12:11:50 +00:00
|
|
|
to arbitrary processes and allow processes
|
2006-05-09 11:42:37 +00:00
|
|
|
to be migrated to arbitrary nodes;
|
2007-04-12 22:42:49 +00:00
|
|
|
.\" FIXME CAP_SYS_NICE also has the following effect for
|
2006-05-09 11:42:37 +00:00
|
|
|
.\" migrate_pages(2):
|
|
|
|
.\" do_migrate_pages(mm, &old, &new,
|
|
|
|
.\" capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
|
2016-10-29 10:44:58 +00:00
|
|
|
.\"
|
adjtimex.2, bind.2, cacheflush.2, clone.2, fallocate.2, fanotify_init.2, fanotify_mark.2, flock.2, futex.2, getdents.2, getpriority.2, getrlimit.2, gettid.2, gettimeofday.2, ioprio_set.2, kexec_load.2, migrate_pages.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, msgop.2, nfsservctl.2, perf_event_open.2, pread.2, ptrace.2, recvmmsg.2, rename.2, restart_syscall.2, sched_setattr.2, send.2, shmop.2, shutdown.2, sigaction.2, signalfd.2, syscalls.2, timer_create.2, timerfd_create.2, tkill.2, vmsplice.2, wait.2, aio_init.3, confstr.3, exit.3, fmemopen.3, fopen.3, getaddrinfo.3, getauxval.3, getspnam.3, isalpha.3, isatty.3, mallinfo.3, malloc.3, mallopt.3, psignal.3, pthread_attr_setinheritsched.3, qecvt.3, queue.3, rtnetlink.3, strerror.3, strftime.3, toupper.3, towlower.3, towupper.3, initrd.4, locale.5, proc.5, bootparam.7, capabilities.7, ddp.7, fanotify.7, icmp.7, inotify.7, ip.7, ipv6.7, netdevice.7, netlink.7, path_resolution.7, rtld-audit.7, rtnetlink.7, sched.7, signal.7, socket.7, svipc.7, tcp.7, unix.7, ld.so.8: srcfix: Update FIXMEs
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-08-21 21:47:44 +00:00
|
|
|
.\" Document this.
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
|
|
|
apply
|
2006-07-31 12:52:31 +00:00
|
|
|
.BR move_pages (2)
|
2008-07-09 12:11:50 +00:00
|
|
|
to arbitrary processes;
|
|
|
|
.IP *
|
2006-03-22 06:27:40 +00:00
|
|
|
use the
|
|
|
|
.B MPOL_MF_MOVE_ALL
|
2007-04-12 22:42:49 +00:00
|
|
|
flag with
|
2006-07-31 12:52:31 +00:00
|
|
|
.BR mbind (2)
|
2007-04-12 22:42:49 +00:00
|
|
|
and
|
2006-07-31 12:52:31 +00:00
|
|
|
.BR move_pages (2).
|
2008-07-09 12:11:50 +00:00
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_PACCT
|
2008-07-09 12:11:50 +00:00
|
|
|
Use
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR acct (2).
|
|
|
|
.TP
|
|
|
|
.B CAP_SYS_PTRACE
|
2014-05-14 04:15:23 +00:00
|
|
|
.PD 0
|
|
|
|
.RS
|
2016-10-18 07:22:50 +00:00
|
|
|
.IP * 2
|
2008-07-09 12:11:50 +00:00
|
|
|
Trace arbitrary processes using
|
2010-06-17 00:34:48 +00:00
|
|
|
.BR ptrace (2);
|
2014-05-14 04:15:23 +00:00
|
|
|
.IP *
|
2010-06-17 00:34:48 +00:00
|
|
|
apply
|
|
|
|
.BR get_robust_list (2)
|
2012-12-18 20:04:52 +00:00
|
|
|
to arbitrary processes;
|
2014-05-14 04:15:23 +00:00
|
|
|
.IP *
|
2014-05-14 04:19:22 +00:00
|
|
|
transfer data to or from the memory of arbitrary processes using
|
|
|
|
.BR process_vm_readv (2)
|
|
|
|
and
|
2016-10-18 07:50:16 +00:00
|
|
|
.BR process_vm_writev (2);
|
2014-05-14 04:19:22 +00:00
|
|
|
.IP *
|
2012-12-18 20:04:52 +00:00
|
|
|
inspect processes using
|
|
|
|
.BR kcmp (2).
|
2014-05-14 04:15:23 +00:00
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_RAWIO
|
2013-03-10 12:05:00 +00:00
|
|
|
.PD 0
|
|
|
|
.RS
|
|
|
|
.IP * 2
|
2008-07-09 12:11:50 +00:00
|
|
|
Perform I/O port operations
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB ( iopl (2)
|
|
|
|
and
|
|
|
|
.BR ioperm (2));
|
2013-03-10 12:05:00 +00:00
|
|
|
.IP *
|
2004-11-03 13:51:07 +00:00
|
|
|
access
|
2012-03-03 08:24:13 +00:00
|
|
|
.IR /proc/kcore ;
|
2013-03-10 12:05:00 +00:00
|
|
|
.IP *
|
2012-03-03 08:24:13 +00:00
|
|
|
employ the
|
|
|
|
.B FIBMAP
|
|
|
|
.BR ioctl (2)
|
2013-03-10 12:05:00 +00:00
|
|
|
operation;
|
|
|
|
.IP *
|
|
|
|
open devices for accessing x86 model-specific registers (MSRs, see
|
2016-10-18 07:50:16 +00:00
|
|
|
.BR msr (4));
|
2013-03-10 12:05:00 +00:00
|
|
|
.IP *
|
|
|
|
update
|
|
|
|
.IR /proc/sys/vm/mmap_min_addr ;
|
|
|
|
.IP *
|
|
|
|
create memory mappings at addresses below the value specified by
|
|
|
|
.IR /proc/sys/vm/mmap_min_addr ;
|
|
|
|
.IP *
|
2013-03-15 07:17:23 +00:00
|
|
|
map files in
|
2013-03-17 07:06:29 +00:00
|
|
|
.IR /proc/bus/pci ;
|
2013-03-10 12:05:00 +00:00
|
|
|
.IP *
|
|
|
|
open
|
|
|
|
.IR /dev/mem
|
|
|
|
and
|
|
|
|
.IR /dev/kmem ;
|
|
|
|
.IP *
|
|
|
|
perform various SCSI device commands;
|
|
|
|
.IP *
|
|
|
|
perform certain operations on
|
|
|
|
.BR hpsa (4)
|
|
|
|
and
|
|
|
|
.BR cciss (4)
|
|
|
|
devices;
|
|
|
|
.IP *
|
|
|
|
perform a range of device-specific operations on other devices.
|
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_RESOURCE
|
2008-07-09 12:11:50 +00:00
|
|
|
.PD 0
|
|
|
|
.RS
|
|
|
|
.IP * 2
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
Use reserved space on ext2 filesystems;
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
|
|
|
make
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR ioctl (2)
|
|
|
|
calls controlling ext3 journaling;
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
|
|
|
override disk quota limits;
|
|
|
|
.IP *
|
|
|
|
increase resource limits (see
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR setrlimit (2));
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
|
|
|
override
|
2004-11-03 13:51:07 +00:00
|
|
|
.B RLIMIT_NPROC
|
2008-07-09 12:11:50 +00:00
|
|
|
resource limit;
|
|
|
|
.IP *
|
2012-03-05 01:03:02 +00:00
|
|
|
override maximum number of consoles on console allocation;
|
|
|
|
.IP *
|
|
|
|
override maximum number of keymaps;
|
|
|
|
.IP *
|
|
|
|
allow more than 64hz interrupts from the real-time clock;
|
|
|
|
.IP *
|
2008-07-09 12:11:50 +00:00
|
|
|
raise
|
2004-11-03 13:51:07 +00:00
|
|
|
.I msg_qbytes
|
2008-07-09 12:11:50 +00:00
|
|
|
limit for a System V message queue above the limit in
|
2007-09-20 16:26:31 +00:00
|
|
|
.I /proc/sys/kernel/msgmnb
|
2004-11-03 13:51:07 +00:00
|
|
|
(see
|
|
|
|
.BR msgop (2)
|
|
|
|
and
|
2012-03-03 08:55:09 +00:00
|
|
|
.BR msgctl (2));
|
|
|
|
.IP *
|
2016-12-16 11:29:08 +00:00
|
|
|
allow the
|
|
|
|
.B RLIMIT_NOFILE
|
|
|
|
resource 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
|
|
|
|
.BR unix (7));
|
|
|
|
.IP *
|
2012-03-03 08:55:09 +00:00
|
|
|
override the
|
|
|
|
.I /proc/sys/fs/pipe-size-max
|
|
|
|
limit when setting the capacity of a pipe using the
|
|
|
|
.B F_SETPIPE_SZ
|
|
|
|
.BR fcntl (2)
|
2020-04-19 19:20:09 +00:00
|
|
|
command;
|
2010-06-16 22:15:39 +00:00
|
|
|
.IP *
|
|
|
|
use
|
|
|
|
.BR F_SETPIPE_SZ
|
|
|
|
to increase the capacity of a pipe above the limit specified by
|
2012-03-03 09:04:09 +00:00
|
|
|
.IR /proc/sys/fs/pipe-max-size ;
|
|
|
|
.IP *
|
|
|
|
override
|
2020-07-08 19:29:35 +00:00
|
|
|
.I /proc/sys/fs/mqueue/queues_max,
|
|
|
|
.I /proc/sys/fs/mqueue/msg_max,
|
|
|
|
and
|
|
|
|
.I /proc/sys/fs/mqueue/msgsize_max
|
2020-07-17 08:11:54 +00:00
|
|
|
limits when creating POSIX message queues (see
|
2012-04-15 00:56:14 +00:00
|
|
|
.BR mq_overview (7));
|
|
|
|
.IP *
|
2016-10-18 07:50:16 +00:00
|
|
|
employ the
|
2012-04-15 00:56:14 +00:00
|
|
|
.BR prctl (2)
|
|
|
|
.B PR_SET_MM
|
2013-03-10 12:05:00 +00:00
|
|
|
operation;
|
2013-03-17 07:07:32 +00:00
|
|
|
.IP *
|
2013-03-10 12:05:00 +00:00
|
|
|
set
|
getrusage.2, madvise.2, memfd_create.2, mlock.2, mount.2, getauxval.3, core.5, capabilities.7, pid_namespaces.7, symlink.7, user_namespaces.7: Consistently use /proc/[pid] (not /proc/PID)
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-10-07 20:42:07 +00:00
|
|
|
.IR /proc/[pid]/oom_score_adj
|
2013-03-10 12:05:00 +00:00
|
|
|
to a value lower than the value last set by a process with
|
|
|
|
.BR CAP_SYS_RESOURCE .
|
2008-07-09 12:11:50 +00:00
|
|
|
.RE
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_TIME
|
2008-07-09 12:11:50 +00:00
|
|
|
Set system clock
|
2004-11-03 13:51:07 +00:00
|
|
|
.RB ( settimeofday (2),
|
|
|
|
.BR stime (2),
|
|
|
|
.BR adjtimex (2));
|
2008-07-09 12:11:50 +00:00
|
|
|
set real-time (hardware) clock.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B CAP_SYS_TTY_CONFIG
|
2008-07-09 12:11:50 +00:00
|
|
|
Use
|
2012-03-03 08:30:21 +00:00
|
|
|
.BR vhangup (2);
|
|
|
|
employ various privileged
|
|
|
|
.BR ioctl (2)
|
|
|
|
operations on virtual terminals.
|
2011-09-08 01:37:09 +00:00
|
|
|
.TP
|
|
|
|
.BR CAP_SYSLOG " (since Linux 2.6.37)"
|
2014-05-14 04:16:37 +00:00
|
|
|
.RS
|
|
|
|
.PD 0
|
2016-10-18 07:22:50 +00:00
|
|
|
.IP * 2
|
2011-09-08 01:37:09 +00:00
|
|
|
Perform privileged
|
|
|
|
.BR syslog (2)
|
|
|
|
operations.
|
|
|
|
See
|
|
|
|
.BR syslog (2)
|
|
|
|
for information on which operations require privilege.
|
2012-10-15 06:57:09 +00:00
|
|
|
.IP *
|
|
|
|
View kernel addresses exposed via
|
|
|
|
.I /proc
|
|
|
|
and other interfaces when
|
|
|
|
.IR /proc/sys/kernel/kptr_restrict
|
|
|
|
has the value 1.
|
2012-10-15 09:13:31 +00:00
|
|
|
(See the discussion of the
|
2012-10-15 06:57:09 +00:00
|
|
|
.I kptr_restrict
|
|
|
|
in
|
|
|
|
.BR proc (5).)
|
2014-05-14 04:16:37 +00:00
|
|
|
.PD
|
|
|
|
.RE
|
2012-03-05 00:54:01 +00:00
|
|
|
.TP
|
|
|
|
.BR CAP_WAKE_ALARM " (since Linux 3.0)"
|
|
|
|
Trigger something that will wake up the system (set
|
|
|
|
.B CLOCK_REALTIME_ALARM
|
|
|
|
and
|
|
|
|
.B CLOCK_BOOTTIME_ALARM
|
|
|
|
timers).
|
2008-07-09 12:11:50 +00:00
|
|
|
.\"
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS Past and current implementation
|
2008-07-09 12:11:50 +00:00
|
|
|
A full implementation of capabilities requires that:
|
|
|
|
.IP 1. 3
|
|
|
|
For all privileged operations,
|
|
|
|
the kernel must check whether the thread has the required
|
|
|
|
capability in its effective set.
|
|
|
|
.IP 2.
|
2010-01-31 15:21:29 +00:00
|
|
|
The kernel must provide system calls allowing a thread's capability sets to
|
2008-07-09 12:11:50 +00:00
|
|
|
be changed and retrieved.
|
|
|
|
.IP 3.
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
The filesystem must support attaching capabilities to an executable file,
|
2008-07-09 12:11:50 +00:00
|
|
|
so that a process gains those capabilities when the file is executed.
|
|
|
|
.PP
|
|
|
|
Before kernel 2.6.24, only the first two of these requirements are met;
|
|
|
|
since kernel 2.6.24, all three requirements are met.
|
|
|
|
.\"
|
2016-12-15 11:27:28 +00:00
|
|
|
.SS Notes to kernel developers
|
|
|
|
When adding a new kernel feature that should be governed by a capability,
|
|
|
|
consider the following points.
|
|
|
|
.IP * 3
|
2016-12-15 19:32:02 +00:00
|
|
|
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.
|
2016-12-15 11:27:28 +00:00
|
|
|
.IP *
|
|
|
|
You have the choice of either creating a new capability for your new feature,
|
|
|
|
or associating the feature with one of the existing capabilities.
|
2016-12-15 19:32:02 +00:00
|
|
|
In order to keep the set of capabilities to a manageable size,
|
2016-12-15 11:27:28 +00:00
|
|
|
the latter option is preferable,
|
|
|
|
unless there are compelling reasons to take the former option.
|
2016-12-15 19:32:02 +00:00
|
|
|
(There is also a technical limit:
|
|
|
|
the size of capability sets is currently limited to 64 bits.)
|
2016-12-15 11:27:28 +00:00
|
|
|
.IP *
|
|
|
|
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.
|
2016-12-15 19:32:02 +00:00
|
|
|
One approach to take is to determine if there are other features
|
2019-02-23 20:14:00 +00:00
|
|
|
requiring capabilities that will always be used along with the new feature.
|
2016-12-15 19:32:02 +00:00
|
|
|
If the new feature is useless without these other features,
|
|
|
|
you should use the same capability as the other features.
|
2016-12-15 11:27:28 +00:00
|
|
|
.IP *
|
|
|
|
.IR Don't
|
|
|
|
choose
|
|
|
|
.B CAP_SYS_ADMIN
|
|
|
|
if you can possibly avoid it!
|
|
|
|
A vast proportion of existing capability checks are associated
|
2016-12-20 08:48:14 +00:00
|
|
|
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.
|
2016-12-15 11:27:28 +00:00
|
|
|
Don't make the problem worse.
|
|
|
|
The only new features that should be associated with
|
|
|
|
.B CAP_SYS_ADMIN
|
|
|
|
are ones that
|
|
|
|
.I closely
|
|
|
|
match existing uses in that silo.
|
|
|
|
.IP *
|
|
|
|
If you have determined that it really is necessary to create
|
|
|
|
a new capability for your feature,
|
2016-12-15 19:32:02 +00:00
|
|
|
don't make or name it as a "single-use" capability.
|
2016-12-15 11:27:28 +00:00
|
|
|
Thus, for example, the addition of the highly specific
|
2018-01-13 19:58:51 +00:00
|
|
|
.BR CAP_SYS_PACCT
|
2016-12-15 11:27:28 +00:00
|
|
|
was 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.
|
|
|
|
.\"
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS Thread capability sets
|
2018-05-01 10:40:14 +00:00
|
|
|
Each thread has the following capability sets containing zero or more
|
2004-11-03 13:51:07 +00:00
|
|
|
of the above capabilities:
|
|
|
|
.TP
|
2018-05-01 11:14:02 +00:00
|
|
|
.IR Permitted
|
2008-07-09 12:11:50 +00:00
|
|
|
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
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
capability in its effective set.
|
2017-08-12 21:25:45 +00:00
|
|
|
.IP
|
2006-05-02 00:36:39 +00:00
|
|
|
If a thread drops a capability from its permitted set,
|
close.2, epoll_create.2, epoll_ctl.2, fcntl.2, madvise.2, mmap.2, mremap.2, select_tut.2, setgid.2, setuid.2, syscalls.2, vmsplice.2, dlopen.3, fts.3, getpw.3, stdio.3, fd.4, initrd.4, random.4, sd.4, bootparam.7, capabilities.7, cpuset.7, epoll.7, inotify.7, man.7, socket.7, x25.7: Global fix: s/re-/re/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "re-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 17:45:23 +00:00
|
|
|
it can never reacquire that capability (unless it
|
2007-05-21 22:12:44 +00:00
|
|
|
.BR execve (2)s
|
2008-07-09 12:11:50 +00:00
|
|
|
either a set-user-ID-root program, or
|
|
|
|
a program whose associated file capabilities grant that capability).
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2018-05-01 11:14:02 +00:00
|
|
|
.IR Inheritable
|
2008-07-09 12:11:50 +00:00
|
|
|
This is a set of capabilities preserved across an
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR execve (2).
|
2015-12-04 07:32:35 +00:00
|
|
|
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.
|
|
|
|
.IP
|
|
|
|
Because inheritable capabilities are not generally preserved across
|
|
|
|
.BR execve (2)
|
|
|
|
when running as a non-root user, applications that wish to run helper
|
2015-12-04 08:56:51 +00:00
|
|
|
programs with elevated capabilities should consider using
|
|
|
|
ambient capabilities, described below.
|
2008-07-09 12:11:50 +00:00
|
|
|
.TP
|
2018-05-01 11:14:02 +00:00
|
|
|
.IR Effective
|
2008-07-09 12:11:50 +00:00
|
|
|
This is the set of capabilities used by the kernel to
|
|
|
|
perform permission checks for the thread.
|
2015-12-04 07:32:35 +00:00
|
|
|
.TP
|
2018-05-01 10:54:28 +00:00
|
|
|
.IR Bounding " (per-thread since Linux 2.6.25)"
|
|
|
|
The capability bounding set is a mechanism that can be used
|
|
|
|
to limit the capabilities that are gained during
|
|
|
|
.BR execve (2).
|
|
|
|
.IP
|
|
|
|
Since Linux 2.6.25, this is a per-thread capability set.
|
|
|
|
In older kernels, the capability bounding set was a system wide attribute
|
|
|
|
shared by all threads on the system.
|
|
|
|
.IP
|
|
|
|
For more details on the capability bounding set, see below.
|
|
|
|
.TP
|
2018-05-01 11:14:02 +00:00
|
|
|
.IR Ambient " (since Linux 4.3)"
|
2015-12-04 08:56:51 +00:00
|
|
|
.\" commit 58319057b7847667f0c9585b9de0e8932b0fdb08
|
2015-12-04 07:32:35 +00:00
|
|
|
This is a set of capabilities that are preserved across an
|
|
|
|
.BR execve (2)
|
2015-12-04 09:20:18 +00:00
|
|
|
of a program that is not privileged.
|
2015-12-04 08:56:51 +00:00
|
|
|
The ambient capability set obeys the invariant that no capability
|
|
|
|
can ever be ambient if it is not both permitted and inheritable.
|
2017-08-12 21:25:45 +00:00
|
|
|
.IP
|
2015-12-04 09:20:18 +00:00
|
|
|
The ambient capability set can be directly modified using
|
|
|
|
.BR prctl (2).
|
|
|
|
Ambient capabilities are automatically lowered if either of
|
|
|
|
the corresponding permitted or inheritable capabilities is lowered.
|
2017-08-12 21:25:45 +00:00
|
|
|
.IP
|
2015-12-04 09:20:18 +00:00
|
|
|
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
|
2015-12-04 07:32:35 +00:00
|
|
|
.BR execve (2)
|
2015-12-04 08:56:51 +00:00
|
|
|
is called.
|
2018-09-12 22:44:15 +00:00
|
|
|
If ambient capabilities cause a process's permitted and effective
|
|
|
|
capabilities to increase during an
|
|
|
|
.BR execve (2),
|
|
|
|
this does not trigger the secure-execution mode described in
|
|
|
|
.BR ld.so (8).
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
A child created via
|
|
|
|
.BR fork (2)
|
|
|
|
inherits copies of its parent's capability sets.
|
2005-10-28 17:41:30 +00:00
|
|
|
See below for a discussion of the treatment of capabilities during
|
2007-05-21 22:12:44 +00:00
|
|
|
.BR execve (2).
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
Using
|
|
|
|
.BR capset (2),
|
2008-07-09 12:11:50 +00:00
|
|
|
a thread may manipulate its own capability sets (see below).
|
2013-04-07 12:23:00 +00:00
|
|
|
.PP
|
|
|
|
Since Linux 3.2, the file
|
|
|
|
.I /proc/sys/kernel/cap_last_cap
|
2013-04-07 12:23:00 +00:00
|
|
|
.\" commit 73efc0394e148d0e15583e13712637831f926720
|
2013-04-07 12:23:00 +00:00
|
|
|
exposes 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.
|
2008-07-09 12:11:50 +00:00
|
|
|
.\"
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS File capabilities
|
2008-07-09 12:11:50 +00:00
|
|
|
Since kernel 2.6.24, the kernel supports
|
|
|
|
associating capability sets with an executable file using
|
|
|
|
.BR setcap (8).
|
|
|
|
The file capability sets are stored in an extended attribute (see
|
2017-11-07 19:55:35 +00:00
|
|
|
.BR setxattr (2)
|
|
|
|
and
|
|
|
|
.BR xattr (7))
|
2008-07-09 12:11:50 +00:00
|
|
|
named
|
|
|
|
.IR "security.capability" .
|
|
|
|
Writing to this extended attribute requires the
|
|
|
|
.BR CAP_SETFCAP
|
2004-11-03 13:51:07 +00:00
|
|
|
capability.
|
2008-07-09 12:11:50 +00:00
|
|
|
The file capability sets,
|
2006-05-02 00:36:39 +00:00
|
|
|
in conjunction with the capability sets of the thread,
|
2008-07-09 12:11:50 +00:00
|
|
|
determine the capabilities of a thread after an
|
2007-05-21 22:12:44 +00:00
|
|
|
.BR execve (2).
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2008-07-09 12:11:50 +00:00
|
|
|
The three file capability sets are:
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2005-10-28 17:41:30 +00:00
|
|
|
.IR Permitted " (formerly known as " forced ):
|
2008-07-09 12:11:50 +00:00
|
|
|
These capabilities are automatically permitted to the thread,
|
2006-05-02 00:36:39 +00:00
|
|
|
regardless of the thread's inheritable capabilities.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2008-07-09 12:11:50 +00:00
|
|
|
.IR 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
|
|
|
|
.BR execve (2).
|
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR Effective :
|
2008-07-09 12:11:50 +00:00
|
|
|
This is not a set, but rather just a single bit.
|
|
|
|
If this bit is set, then during an
|
|
|
|
.BR 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
|
|
|
|
.BR execve (2),
|
|
|
|
none of the new permitted capabilities is in the new effective set.
|
2017-08-12 21:25:45 +00:00
|
|
|
.IP
|
2008-07-09 12:11:50 +00:00
|
|
|
Enabling the file effective capability bit implies
|
2008-07-09 13:55:24 +00:00
|
|
|
that any file permitted or inheritable capability that causes a
|
2008-07-09 12:11:50 +00:00
|
|
|
thread to acquire the corresponding permitted capability during an
|
|
|
|
.BR execve (2)
|
2009-01-14 03:20:50 +00:00
|
|
|
(see the transformation rules described below) will also acquire that
|
2008-07-09 12:11:50 +00:00
|
|
|
capability in its effective set.
|
|
|
|
Therefore, when assigning capabilities to a file
|
|
|
|
.RB ( setcap (8),
|
|
|
|
.BR cap_set_file (3),
|
|
|
|
.BR 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.
|
|
|
|
.\"
|
2018-07-01 09:25:21 +00:00
|
|
|
.SS File capability extended attribute versioning
|
2018-01-13 19:55:53 +00:00
|
|
|
To allow extensibility,
|
|
|
|
the kernel supports a scheme to encode a version number inside the
|
|
|
|
.I security.capability
|
|
|
|
extended attribute that is used to implement file capabilities.
|
|
|
|
These version numbers are internal to the implementation,
|
|
|
|
and not directly visible to user-space applications.
|
|
|
|
To date, the following versions are supported:
|
|
|
|
.TP
|
|
|
|
.BR VFS_CAP_REVISION_1
|
|
|
|
This was the original file capability implementation,
|
|
|
|
which supported 32-bit masks for file capabilities.
|
|
|
|
.TP
|
|
|
|
.BR VFS_CAP_REVISION_2 " (since Linux 2.6.25)"
|
|
|
|
.\" commit e338d263a76af78fe8f38a72131188b58fceb591
|
|
|
|
This version allows for file capability masks that are 64 bits in size,
|
|
|
|
and was necessary as the number of supported capabilities grew beyond 32.
|
|
|
|
The kernel transparently continues to support the execution of files
|
|
|
|
that have 32-bit version 1 capability masks,
|
|
|
|
but when adding capabilities to files that did not previously
|
|
|
|
have capabilities, or modifying the capabilities of existing files,
|
2018-04-13 19:04:29 +00:00
|
|
|
it automatically uses the version 2 scheme
|
|
|
|
(or possibly the version 3 scheme, as described below).
|
2018-01-13 19:55:53 +00:00
|
|
|
.TP
|
|
|
|
.BR VFS_CAP_REVISION_3 " (since Linux 4.14)"
|
|
|
|
.\" commit 8db6c34f1dbc8e06aa016a9b829b06902c3e1340
|
2018-04-13 19:04:29 +00:00
|
|
|
Version 3 file capabilities are provided
|
2018-01-14 20:39:15 +00:00
|
|
|
to support namespaced file capabilities (described below).
|
2018-04-13 19:04:29 +00:00
|
|
|
.IP
|
2018-01-13 19:55:53 +00:00
|
|
|
As with version 2 file capabilities,
|
2018-04-13 19:04:29 +00:00
|
|
|
version 3 capability masks are 64 bits in size.
|
|
|
|
But in addition, the root user ID of namespace is encoded in the
|
2018-01-13 19:55:53 +00:00
|
|
|
.I security.capability
|
|
|
|
extended attribute.
|
2018-04-13 11:42:11 +00:00
|
|
|
(A namespace's root user ID is the value that user ID 0
|
|
|
|
inside that namespace maps to in the initial user namespace.)
|
2018-04-13 13:41:10 +00:00
|
|
|
.IP
|
2018-04-13 19:04:29 +00:00
|
|
|
Version 3 file capabilities are designed to coexist
|
|
|
|
with version 2 capabilities;
|
|
|
|
that is, on a modern Linux system,
|
|
|
|
there may be some files with version 2 capabilities
|
|
|
|
while others have version 3 capabilities.
|
|
|
|
.PP
|
|
|
|
Before Linux 4.14,
|
2018-07-01 09:25:21 +00:00
|
|
|
the only kind of file capability extended attribute
|
|
|
|
that could be attached to a file was a
|
2018-04-13 19:04:29 +00:00
|
|
|
.B VFS_CAP_REVISION_2
|
2018-07-01 09:25:21 +00:00
|
|
|
attribute.
|
2018-04-13 19:04:29 +00:00
|
|
|
Since Linux 4.14,
|
2018-07-01 09:28:13 +00:00
|
|
|
the version of the
|
2018-04-13 19:04:29 +00:00
|
|
|
.I security.capability
|
2018-07-01 09:28:13 +00:00
|
|
|
extended attribute that is attached to a file
|
|
|
|
depends on the circumstances in which the attribute was created.
|
2018-04-13 19:04:29 +00:00
|
|
|
.PP
|
2018-04-13 13:41:10 +00:00
|
|
|
Starting with Linux 4.14, a
|
|
|
|
.I security.capability
|
|
|
|
extended attribute is automatically created as (or converted to)
|
2018-04-13 19:04:29 +00:00
|
|
|
a version 3
|
|
|
|
.RB ( VFS_CAP_REVISION_3 )
|
|
|
|
attribute if both of the following are true:
|
2018-04-13 13:41:10 +00:00
|
|
|
.IP (1) 4
|
2018-06-24 06:54:17 +00:00
|
|
|
The thread writing the attribute resides in a noninitial user namespace.
|
2018-04-13 13:41:10 +00:00
|
|
|
(More precisely: the thread resides in a user namespace other
|
|
|
|
than the one from which the underlying filesystem was mounted.)
|
|
|
|
.IP (2)
|
|
|
|
The thread has the
|
|
|
|
.BR CAP_SETFCAP
|
|
|
|
capability over the file inode,
|
|
|
|
meaning that (a) the thread has the
|
|
|
|
.B CAP_SETFCAP
|
|
|
|
capability in its own user namespace;
|
|
|
|
and (b) the UID and GID of the file inode have mappings in
|
|
|
|
the writer's user namespace.
|
2018-04-13 19:04:29 +00:00
|
|
|
.PP
|
2018-04-13 13:41:10 +00:00
|
|
|
When a
|
|
|
|
.BR VFS_CAP_REVISION_3
|
|
|
|
.I security.capability
|
|
|
|
extended attribute is created, the root user ID of the creating thread's
|
|
|
|
user namespace is saved in the extended attribute.
|
2018-04-13 19:04:29 +00:00
|
|
|
.PP
|
2018-07-01 10:25:47 +00:00
|
|
|
By contrast, creating or modifying a
|
2018-04-13 13:41:10 +00:00
|
|
|
.I security.capability
|
|
|
|
extended attribute from a privileged
|
|
|
|
.RB ( CAP_SETFCAP )
|
|
|
|
thread that resides in the
|
2018-04-26 21:28:16 +00:00
|
|
|
namespace where the underlying filesystem was mounted
|
2018-04-13 13:41:10 +00:00
|
|
|
(this normally means the initial user namespace)
|
2018-07-01 10:25:47 +00:00
|
|
|
automatically results in the creation of a version 2
|
2018-04-13 19:04:29 +00:00
|
|
|
.RB ( VFS_CAP_REVISION_2 )
|
2018-04-13 13:41:10 +00:00
|
|
|
attribute.
|
2018-04-13 19:04:29 +00:00
|
|
|
.PP
|
2018-07-01 10:25:47 +00:00
|
|
|
Note that the creation of a version 3
|
|
|
|
.I security.capability
|
|
|
|
extended attribute is automatic.
|
|
|
|
That is to say, when a user-space application writes
|
|
|
|
.RB ( setxattr (2))
|
|
|
|
a
|
|
|
|
.I security.capability
|
|
|
|
attribute in the version 2 format,
|
|
|
|
the kernel will automatically create a version 3 attribute
|
|
|
|
if the attribute is created in the circumstances described above.
|
|
|
|
Correspondingly, when a version 3
|
|
|
|
.I security.capability
|
|
|
|
attribute is retrieved
|
|
|
|
.RB ( getxattr (2))
|
|
|
|
by a process that resides inside a user namespace that was created by the
|
|
|
|
root user ID (or a descendant of that user namespace),
|
|
|
|
the returned attribute is (automatically)
|
|
|
|
simplified to appear as a version 2 attribute
|
|
|
|
(i.e., the returned value is the size of a version 2 attribute and does
|
|
|
|
not include the root user ID).
|
|
|
|
These automatic translations mean that no changes are required to
|
|
|
|
user-space tools (e.g.,
|
|
|
|
.BR setcap (1)
|
|
|
|
and
|
|
|
|
.BR getcap (1))
|
|
|
|
in order for those tools to be used to create and retrieve version 3
|
|
|
|
.I security.capability
|
|
|
|
attributes.
|
|
|
|
.PP
|
2018-04-13 19:04:29 +00:00
|
|
|
Note that a file can have either a version 2 or a version 3
|
|
|
|
.I security.capability
|
|
|
|
extended attribute associated with it, but not both:
|
|
|
|
creation or modification of the
|
|
|
|
.I security.capability
|
|
|
|
extended attribute will automatically modify the version
|
|
|
|
according to the circumstances in which the extended attribute is
|
|
|
|
created or modified.
|
2018-01-13 19:55:53 +00:00
|
|
|
.\"
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS Transformation of capabilities during execve()
|
2007-04-12 22:42:49 +00:00
|
|
|
During an
|
2007-05-21 22:12:44 +00:00
|
|
|
.BR execve (2),
|
2005-10-20 15:11:10 +00:00
|
|
|
the kernel calculates the new capabilities of
|
2004-11-03 13:51:07 +00:00
|
|
|
the process using the following algorithm:
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2007-12-19 06:57:44 +00:00
|
|
|
.in +4n
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EX
|
2016-12-15 08:51:30 +00:00
|
|
|
P'(ambient) = (file is privileged) ? 0 : P(ambient)
|
2015-12-04 07:32:35 +00:00
|
|
|
|
2016-12-15 08:51:30 +00:00
|
|
|
P'(permitted) = (P(inheritable) & F(inheritable)) |
|
2018-05-01 10:57:14 +00:00
|
|
|
(F(permitted) & P(bounding)) | P'(ambient)
|
2004-11-03 13:51:07 +00:00
|
|
|
|
2016-12-15 08:51:30 +00:00
|
|
|
P'(effective) = F(effective) ? P'(permitted) : P'(ambient)
|
2004-11-03 13:51:07 +00:00
|
|
|
|
2005-05-30 09:56:32 +00:00
|
|
|
P'(inheritable) = P(inheritable) [i.e., unchanged]
|
2018-05-01 10:57:14 +00:00
|
|
|
|
|
|
|
P'(bounding) = P(bounding) [i.e., unchanged]
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EE
|
2007-12-19 06:57:44 +00:00
|
|
|
.in
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2004-11-03 13:51:07 +00:00
|
|
|
where:
|
2008-07-09 12:11:50 +00:00
|
|
|
.RS 4
|
2018-05-01 10:57:14 +00:00
|
|
|
.IP P() 6
|
2007-04-12 22:42:49 +00:00
|
|
|
denotes the value of a thread capability set before the
|
2007-05-21 22:12:44 +00:00
|
|
|
.BR execve (2)
|
2018-05-01 10:57:14 +00:00
|
|
|
.IP P'()
|
2016-03-09 00:25:11 +00:00
|
|
|
denotes the value of a thread capability set after the
|
2007-05-21 22:12:44 +00:00
|
|
|
.BR execve (2)
|
2018-05-01 10:57:14 +00:00
|
|
|
.IP F()
|
2004-11-03 13:51:07 +00:00
|
|
|
denotes a file capability set
|
2008-07-09 12:11:50 +00:00
|
|
|
.RE
|
2015-12-04 09:20:18 +00:00
|
|
|
.PP
|
2018-05-01 11:11:36 +00:00
|
|
|
Note the following details relating to the above capability
|
|
|
|
transformation rules:
|
|
|
|
.IP * 3
|
|
|
|
The ambient capability set is present only since Linux 4.3.
|
|
|
|
When determining the transformation of the ambient set during
|
|
|
|
.BR execve (2),
|
|
|
|
a privileged file is one that has capabilities or
|
2015-12-04 09:20:18 +00:00
|
|
|
has the set-user-ID or set-group-ID bit set.
|
2018-05-01 11:11:36 +00:00
|
|
|
.IP *
|
|
|
|
Prior to Linux 2.6.25,
|
|
|
|
the bounding set was a system-wide attribute shared by all threads.
|
|
|
|
That system-wide value was employed to calculate the new permitted set during
|
|
|
|
.BR execve (2)
|
|
|
|
in the same manner as shown above for
|
|
|
|
.IR P(bounding) .
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2016-12-15 08:59:04 +00:00
|
|
|
.IR Note :
|
2019-02-12 09:29:21 +00:00
|
|
|
during the capability transitions described above,
|
|
|
|
file capabilities may be ignored (treated as empty) for the same reasons
|
2016-12-15 08:59:04 +00:00
|
|
|
that the set-user-ID and set-group-ID bits are ignored; see
|
|
|
|
.BR execve (2).
|
2019-02-12 09:29:21 +00:00
|
|
|
File capabilities are similarly ignored if the kernel was booted with the
|
2019-02-12 09:15:35 +00:00
|
|
|
.I no_file_caps
|
2019-02-12 09:29:21 +00:00
|
|
|
option.
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2017-05-04 17:15:19 +00:00
|
|
|
.IR Note :
|
|
|
|
according to the rules above,
|
|
|
|
if a process with nonzero user IDs performs an
|
|
|
|
.BR 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
|
|
|
|
.BR execve (2),
|
|
|
|
see below under
|
|
|
|
.IR "Capabilities and execution of programs by root" .
|
2008-07-09 12:11:50 +00:00
|
|
|
.\"
|
2016-03-10 00:02:30 +00:00
|
|
|
.SS Safety checking for capability-dumb binaries
|
2016-03-10 16:55:28 +00:00
|
|
|
A capability-dumb binary is an application that has been
|
2016-03-10 00:02:30 +00:00
|
|
|
marked to have file capabilities, but has not been converted to use the
|
|
|
|
.BR 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.)
|
2016-03-15 03:47:25 +00:00
|
|
|
For such applications,
|
2016-03-10 00:02:30 +00:00
|
|
|
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.
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2016-03-10 00:02:30 +00:00
|
|
|
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
|
|
|
|
.I not
|
|
|
|
occur 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
|
|
|
|
.BR execve (2)
|
|
|
|
fails with the error
|
|
|
|
.BR 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
|
|
|
|
.BR libcap (3)
|
|
|
|
API.
|
|
|
|
.\"
|
2008-07-09 12:11:50 +00:00
|
|
|
.SS Capabilities and execution of programs by root
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
.\" See cap_bprm_set_creds(), bprm_caps_from_vfs_cap() and
|
|
|
|
.\" handle_privileged_root() in security/commoncap.c (Linux 5.0 source)
|
2019-02-10 02:40:15 +00:00
|
|
|
In order to mirror traditional UNIX semantics,
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
the kernel performs special treatment of file capabilities when
|
|
|
|
a process with UID 0 (root) executes a program and
|
|
|
|
when a set-user-ID-root program is executed.
|
2019-02-10 02:40:15 +00:00
|
|
|
.PP
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
After having performed any changes to the process effective ID that
|
|
|
|
were triggered by the set-user-ID mode bit of the binary\(eme.g.,
|
|
|
|
switching the effective user ID to 0 (root) because
|
|
|
|
a set-user-ID-root program was executed\(emthe
|
|
|
|
kernel calculates the file capability sets as follows:
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP 1. 3
|
2019-02-10 02:40:15 +00:00
|
|
|
If the real or effective user ID of the process is 0 (root),
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
then the file inheritable and permitted sets are ignored;
|
|
|
|
instead they are notionally considered to be all ones
|
2008-07-09 12:11:50 +00:00
|
|
|
(i.e., all capabilities enabled).
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
(There is one exception to this behavior, described below in
|
|
|
|
.IR "Set-user-ID-root programs that have file capabilities" .)
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP 2.
|
2019-02-10 02:40:15 +00:00
|
|
|
If the effective user ID of the process is 0 (root) or
|
|
|
|
the file effective bit is in fact enabled,
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
then the file effective bit is notionally defined to be one (enabled).
|
2005-10-28 17:41:30 +00:00
|
|
|
.PP
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
These notional values for the file's capability sets are then used
|
|
|
|
as described above to calculate the transformation of the process's
|
|
|
|
capabilities during
|
|
|
|
.BR execve (2).
|
2019-02-10 02:40:15 +00:00
|
|
|
.PP
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
Thus, when a process with nonzero UIDs
|
2007-05-21 22:12:44 +00:00
|
|
|
.BR execve (2)s
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
a set-user-ID-root program that does not have capabilities attached,
|
|
|
|
or when a process whose real and effective UIDs are zero
|
2017-05-04 17:38:50 +00:00
|
|
|
.BR execve (2)s
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
a program, the calculation of the process's new
|
|
|
|
permitted capabilities simplifies to:
|
|
|
|
.PP
|
|
|
|
.in +4n
|
|
|
|
.EX
|
|
|
|
P'(permitted) = P(inheritable) | P(bounding)
|
|
|
|
|
|
|
|
P'(effective) = P'(permitted)
|
|
|
|
.EE
|
|
|
|
.in
|
|
|
|
.PP
|
|
|
|
Consequently, the process gains all capabilities in its permitted and
|
|
|
|
effective capability sets,
|
2017-05-04 17:38:50 +00:00
|
|
|
except those masked out by the capability bounding set.
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
(In the calculation of P'(permitted),
|
|
|
|
the P'(ambient) term can be simplified away because it is by
|
|
|
|
definition a proper subset of P(inheritable).)
|
2017-05-04 17:38:50 +00:00
|
|
|
.PP
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
The special treatments of user ID 0 (root) described in this subsection
|
|
|
|
can be disabled using the securebits mechanism described below.
|
|
|
|
.\"
|
2017-07-18 20:41:37 +00:00
|
|
|
.\"
|
|
|
|
.SS Set-user-ID-root programs that have file capabilities
|
capabilities.7: Substantially rework "Capabilities and execution of programs by root"
Rework for improved clarity, and also to include missing details
on the case where (1) the binary that is being executed has
capabilities attached and (2) the real user ID of the process is
not 0 (root) and (3) the effective user ID of the process is 0
(root).
Kernel code analysis and some test code (GPLv3 licensed) below.
======
My analysis of security/commoncaps.c capabilities handling
(from Linux 4.20 source):
execve() eventually calls __do_execve_file():
__do_execve_file()
|
+-prepare_bprm_creds(&bprm)
| |
| +-prepare_exec_creds()
| | |
| | +-prepare_creds()
| | |
| | | // Returns copy of existing creds
| | |
| | +-security_prepare_creds()
| | |
| | +-cred_prepare() [via hook]
| | // Seems to do nothing for commoncaps
| |
| // Returns creds provided by prepare_creds()
|
// Places creds returned by prepare_exec_creds() in bprm->creds
|
|
+-prepare_binprm(&bprm) // bprm from prepare_bprm_creds()
|
+-bprm_fill_uid(&bprm)
|
| // Places current credentials into bprm
|
| // Performs set-UID & set-GID transitions if those file bits are set
|
+-security_bprm_set_creds(&bprm)
|
+-bprm_set_creds(&bprm) [via hook]
|
+-cap_bprm_set_creds(&bprm)
|
// effective = false
|
+-get_file_caps(&bprm, &effective, &has_fcap)
| |
| +-get_vfs_caps_from_disk(..., &vcaps)
| |
| | // Fetches file capabilities from disk and places in vcaps
| |
| +-bprm_caps_from_vfs_caps(&vcaps, &bprm, &effective, &has_fcap)
|
| // If file effective bit is set: effective = true
| //
| // If file has capabilities: has_fcap |= true
| //
| // Perform execve transformation:
| // P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset)
|
+-handle_privileged_root(&bprm, has_fcap, &effective, root_uid)
|
| // If has_fcap && (rUID != root && eUID == root) then
| // return without doing anything
| //
| // If rUID == root || eUID == root then
| // P'(perm) = P(inh) | P(bset)
| //
| // If eUID == root then
| // effective = true
|
// Perform execve() transformation:
//
// P'(Amb) = (privprog) ? 0 : P(Amb)
// P'(Perm) |= P'(Amb)
// P'(Eff) = effective ? P'(Perm) : P'(Amb)
Summary
1. Perform set-UID/set-GID transformations
2. P'(Amb) = (privprog) ? 0 : P(Amb)
3. If [process has nonzero UIDs] OR
([file has caps] && [rUID != root && eUID == root]), then
P'(perm) = F(inh) & P(Inh) | F(Perm) & P(bset) | P'(Amb)
else // ~ [process has rUID == root || eUID == root]
P'(perm) = P(inh) | P(bset) | P'(Amb)
4. P'(Eff) = (F(eff) || eUID == root) ? P'(Perm) : P'(Amb)
======
$ cat show_creds_and_caps_long.c
int
main(int argc, char *argv[])
{
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
cap_t caps;
char *s;
if (getresuid(&ruid, &euid, &suid) == -1) {
perror("getresuid");
exit(EXIT_FAILURE);
}
if (getresgid(&rgid, &egid, &sgid) == -1) {
perror("getresgid");
exit(EXIT_FAILURE);
}
printf("UID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) ruid, (long) euid, (long) suid);
printf("GID: %5ld (real), %5ld (effective), %5ld (saved)\n",
(long) rgid, (long) egid, (long) sgid);
caps = cap_get_proc();
if (caps == NULL) {
perror("cap_get_proc");
exit(EXIT_FAILURE);
}
s = cap_to_text(caps, NULL);
if (s == NULL) {
perror("cap_to_text");
exit(EXIT_FAILURE);
}
printf("Capabilities: %s\n", s);
cap_free(caps);
cap_free(s);
exit(EXIT_SUCCESS);
}
$ cat cred_launcher.c
} while (0)
do { fprintf(stderr, "Usage: "); \
fprintf(stderr, msg, progName); \
exit(EXIT_FAILURE); } while (0)
int
main(int argc, char *argv[])
{
uid_t r, e, s;
if (argc != 5 || strcmp(argv[1], "--help") == 0)
usageErr("%s rUID eUID sUID <prog>\n", argv[0]);
r = atoi(argv[1]);
e = atoi(argv[2]);
s = atoi(argv[3]);
if (setresuid(r, e, s) == -1)
errExit("setresuid");
if (getresuid(&r, &e, &s) == -1)
errExit("getresuid");
execv(argv[4], &argv[4]);
errExit("execve");
}
$ cc -o cred_launcher cred_launcher.c
$ cc -o show_creds_and_caps_long show_creds_and_caps_long.c -lcap
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: =ep
$ sudo setcap cap_kill=pe show_creds_and_caps_long
$ sudo ./cred_launcher 1000 0 1000 ./show_creds_and_caps_long
UID: 1000 (real), 0 (effective), 0 (saved)
GID: 0 (real), 0 (effective), 0 (saved)
Capabilities: = cap_kill+ep
The final program execution above shows the special casing
that occurs in handle_privileged_root() for the case where:
rUID != root && eUID == root && [file has capabilities]
======
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-12 15:56:13 +00:00
|
|
|
There is one exception to the behavior described under
|
|
|
|
.IR "Capabilities and execution of programs by root" .
|
|
|
|
If (a) the binary that is being executed has capabilities attached and
|
|
|
|
(b) the real user ID of the process is
|
|
|
|
.I not
|
|
|
|
0 (root) and
|
|
|
|
(c) the effective user ID of the process
|
|
|
|
.I is
|
|
|
|
0 (root), then the file capability bits are honored
|
|
|
|
(i.e., they are not notionally considered to be all ones).
|
|
|
|
The usual way in which this situation can arise is when executing
|
|
|
|
a set-UID-root program that also has file capabilities.
|
|
|
|
When such a program is executed,
|
|
|
|
the process gains just the capabilities granted by the program
|
2017-07-18 20:41:37 +00:00
|
|
|
(i.e., not all capabilities,
|
|
|
|
as would occur when executing a set-user-ID-root program
|
|
|
|
that does not have any associated file capabilities).
|
2019-02-10 02:40:15 +00:00
|
|
|
.PP
|
2017-07-18 20:44:44 +00:00
|
|
|
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.
|
2017-07-18 20:41:37 +00:00
|
|
|
.\"
|
2008-07-09 12:11:50 +00:00
|
|
|
.SS Capability bounding set
|
|
|
|
The capability bounding set is a security mechanism that can be used
|
|
|
|
to limit the capabilities that can be gained during an
|
|
|
|
.BR execve (2).
|
|
|
|
The bounding set is used in the following ways:
|
|
|
|
.IP * 2
|
|
|
|
During an
|
|
|
|
.BR 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.
|
|
|
|
.IP *
|
|
|
|
(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
|
|
|
|
.BR capset (2).
|
2009-09-28 10:44:05 +00:00
|
|
|
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
|
2008-07-09 12:11:50 +00:00
|
|
|
permitted set when it
|
|
|
|
.BR execve (2)s
|
|
|
|
a file that has the capability in its inheritable set.
|
|
|
|
.PP
|
|
|
|
Note that the bounding set masks the file permitted capabilities,
|
2017-12-02 14:08:52 +00:00
|
|
|
but not the inheritable capabilities.
|
|
|
|
If a thread maintains a capability in its inheritable set
|
2008-07-09 12:11:50 +00:00
|
|
|
that is not in its bounding set,
|
|
|
|
then it can still gain that capability in its permitted set
|
2017-12-02 14:08:52 +00:00
|
|
|
by executing a file that has the capability in its inheritable set.
|
2008-07-09 12:11:50 +00:00
|
|
|
.PP
|
|
|
|
Depending on the kernel version, the capability bounding set is either
|
|
|
|
a system-wide attribute, or a per-process attribute.
|
|
|
|
.PP
|
Changes.old, clone.2, execve.2, fcntl.2, futex.2, getitimer.2, getpriority.2, mmap.2, mount.2, mprotect.2, sched_setscheduler.2, select_tut.2, setuid.2, sigaltstack.2, vfork.2, div.3, fenv.3, fmod.3, memchr.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_getattr_np.3, queue.3, scanf.3, trunc.3, st.4, proc.5, services.5, utmp.5, bootparam.7, capabilities.7, feature_test_macros.7, futex.7, glob.7, man.7, netlink.7, unicode.7: Switch to American usage: "-wards" ==> "-ward"
American English uses "afterward" in preference to "afterwards",
and so on
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-26 05:34:47 +00:00
|
|
|
.B "Capability bounding set from Linux 2.6.25 onward"
|
2008-07-09 12:11:50 +00:00
|
|
|
.PP
|
|
|
|
From Linux 2.6.25, the
|
|
|
|
.I "capability bounding set"
|
|
|
|
is a per-thread attribute.
|
2018-05-01 11:03:10 +00:00
|
|
|
(The system-wide capability bounding set described below no longer exists.)
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2008-07-09 12:11:50 +00:00
|
|
|
The bounding set is inherited at
|
|
|
|
.BR fork (2)
|
|
|
|
from the thread's parent, and is preserved across an
|
|
|
|
.BR execve (2).
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2008-07-09 12:11:50 +00:00
|
|
|
A thread may remove capabilities from its capability bounding set using the
|
|
|
|
.BR prctl (2)
|
|
|
|
.B PR_CAPBSET_DROP
|
|
|
|
operation, provided it has the
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
capability.
|
|
|
|
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
|
|
|
|
.BR prctl (2)
|
|
|
|
.B PR_CAPBSET_READ
|
|
|
|
operation.
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
intro.1, _syscall.2, access.2, arch_prctl.2, cacheflush.2, chown.2, clock_getres.2, clone.2, create_module.2, fcntl.2, flock.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getpriority.2, getrlimit.2, getrusage.2, ioprio_set.2, kexec_load.2, madvise.2, mbind.2, migrate_pages.2, mknod.2, mmap.2, mount.2, move_pages.2, mprotect.2, open.2, pause.2, pciconfig_read.2, perf_event_open.2, prctl.2, ptrace.2, query_module.2, read.2, reboot.2, recv.2, s390_runtime_instr.2, sched_setscheduler.2, select_tut.2, send.2, set_mempolicy.2, setfsgid.2, setfsuid.2, sigaction.2, spu_create.2, spu_run.2, stime.2, swapon.2, syslog.2, timer_create.2, timer_getoverrun.2, times.2, tkill.2, umount.2, unimplemented.2, ustat.2, vm86.2, wait.2, abs.3, aio_read.3, aio_write.3, bsd_signal.3, catgets.3, clearenv.3, cmsg.3, dbopen.3, dirfd.3, dlopen.3, exec.3, fenv.3, ferror.3, fmemopen.3, fnmatch.3, fopen.3, futimes.3, getaddrinfo.3, getifaddrs.3, getipnodebyname.3, hsearch.3, if_nameindex.3, inet_pton.3, mblen.3, mbrlen.3, mbsrtowcs.3, mbtowc.3, mcheck.3, memfrob.3, mq_notify.3, netlink.3, posix_memalign.3, printf.3, pthread_attr_setscope.3, pthread_cleanup_push.3, pthread_kill_other_threads_np.3, pthread_self.3, pthread_setcancelstate.3, pthread_setconcurrency.3, raise.3, resolver.3, rpc.3, rtime.3, rtnetlink.3, scanf.3, setbuf.3, setnetgrent.3, shm_open.3, sigpause.3, sigset.3, sigwait.3, sockatmark.3, strcasecmp.3, strcmp.3, strdup.3, strftime.3, strptime.3, strsignal.3, strverscmp.3, sysv_signal.3, termios.3, wcrtomb.3, wcsnlen.3, wcsnrtombs.3, wcsrtombs.3, wctomb.3, wprintf.3, console_codes.4, cpuid.4, msr.4, rtc.4, sk98lin.4, st.4, tty.4, charmap.5, core.5, elf.5, hosts.equiv.5, proc.5, resolv.conf.5, services.5, slabinfo.5, arp.7, bootparam.7, capabilities.7, charsets.7, cpuset.7, ddp.7, epoll.7, feature_test_macros.7, futex.7, hier.7, icmp.7, inotify.7, ip.7, ipv6.7, man-pages.7, mdoc.7, mdoc.samples.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, posixoptions.7, pthreads.7, raw.7, rtld-audit.7, rtnetlink.7, sem_overview.7, sigevent.7, socket.7, spufs.7, tcp.7, udp.7, unicode.7, uri.7, utf-8.7, intro.8, ldconfig.8, sync.8: Global fix: fix placement of word "only"
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-03-31 08:53:00 +00:00
|
|
|
Removing capabilities from the bounding set is supported only if file
|
2011-09-09 01:47:35 +00:00
|
|
|
capabilities are compiled into the kernel.
|
|
|
|
In kernels before Linux 2.6.33,
|
|
|
|
file capabilities were an optional feature configurable via the
|
2014-07-29 17:45:08 +00:00
|
|
|
.B CONFIG_SECURITY_FILE_CAPABILITIES
|
2011-09-09 01:47:35 +00:00
|
|
|
option.
|
2015-02-05 14:17:07 +00:00
|
|
|
Since Linux 2.6.33,
|
|
|
|
.\" commit b3a222e52e4d4be77cc4520a57af1a4a0d8222d1
|
|
|
|
the configuration option has been removed
|
2011-09-09 01:47:35 +00:00
|
|
|
and file capabilities are always part of the kernel.
|
|
|
|
When file capabilities are compiled into the kernel, the
|
2008-07-09 12:11:50 +00:00
|
|
|
.B init
|
|
|
|
process (the ancestor of all processes) begins with a full bounding set.
|
|
|
|
If file capabilities are not compiled into the kernel, then
|
|
|
|
.B init
|
|
|
|
begins with a full bounding set minus
|
|
|
|
.BR CAP_SETPCAP ,
|
|
|
|
because this capability has a different meaning when there are
|
|
|
|
no file capabilities.
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2008-07-09 12:11:50 +00:00
|
|
|
Removing a capability from the bounding set does not remove it
|
2017-12-02 14:08:52 +00:00
|
|
|
from the thread's inheritable set.
|
2008-07-09 12:11:50 +00:00
|
|
|
However it does prevent the capability from being added
|
2017-12-02 14:08:52 +00:00
|
|
|
back into the thread's inheritable set in the future.
|
2018-05-01 11:00:16 +00:00
|
|
|
.PP
|
|
|
|
.B "Capability bounding set prior to Linux 2.6.25"
|
|
|
|
.PP
|
|
|
|
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
|
|
|
|
.IR /proc/sys/kernel/cap-bound .
|
|
|
|
(Confusingly, this bit mask parameter is expressed as a
|
|
|
|
signed decimal number in
|
|
|
|
.IR /proc/sys/kernel/cap-bound .)
|
|
|
|
.PP
|
|
|
|
Only the
|
|
|
|
.B init
|
|
|
|
process may set capabilities in the capability bounding set;
|
|
|
|
other than that, the superuser (more precisely: a process with the
|
|
|
|
.B CAP_SYS_MODULE
|
|
|
|
capability) may only clear capabilities from this set.
|
|
|
|
.PP
|
|
|
|
On a standard system the capability bounding set always masks out the
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
capability.
|
|
|
|
To remove this restriction (dangerous!), modify the definition of
|
|
|
|
.B CAP_INIT_EFF_SET
|
|
|
|
in
|
|
|
|
.I include/linux/capability.h
|
|
|
|
and rebuild the kernel.
|
|
|
|
.PP
|
|
|
|
The system-wide capability bounding set feature was added
|
|
|
|
to Linux starting with kernel version 2.2.11.
|
|
|
|
.\"
|
2008-07-09 12:11:50 +00:00
|
|
|
.\"
|
|
|
|
.\"
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS Effect of user ID changes on capabilities
|
2007-04-12 22:42:49 +00:00
|
|
|
To preserve the traditional semantics for transitions between
|
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt.2, gettimeofday.2, intro.2, ioctl_list.2, ioperm.2, mlock.2, pivot_root.2, poll.2, prctl.2, ptrace.2, sched_setscheduler.2, select_tut.2, semget.2, sigaltstack.2, signalfd.2, sysctl.2, timer_settime.2, timerfd_create.2, wait.2, CPU_SET.3, argz_add.3, assert_perror.3, atexit.3, backtrace.3, bcmp.3, clearenv.3, ctime.3, dl_iterate_phdr.3, dlopen.3, ecvt.3, errno.3, error.3, ether_aton.3, exit.3, fenv.3, ferror.3, finite.3, flockfile.3, fnmatch.3, fpathconf.3, fpclassify.3, ftime.3, ftok.3, ftw.3, fwide.3, getaddrinfo.3, gethostbyname.3, getlogin.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getrpcent.3, getservent.3, glob.3, hsearch.3, inet.3, isalpha.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, longjmp.3, lsearch.3, malloc.3, matherr.3, mblen.3, mbsinit.3, mbtowc.3, on_exit.3, printf.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_equal.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, ptsname.3, putenv.3, putgrent.3, raise.3, rcmd.3, regex.3, rexec.3, rpc.3, rpmatch.3, rtnetlink.3, scandir.3, sem_init.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, signbit.3, stdio_ext.3, strtod.3, strtol.3, strtoul.3, system.3, termios.3, timeradd.3, tzset.3, ualarm.3, wctomb.3, xdr.3, st.4, tty_ioctl.4, core.5, elf.5, proc.5, bootparam.7, capabilities.7, icmp.7, ip.7, ipv6.7, math_error.7, mdoc.samples.7, mq_overview.7, pthreads.7, raw.7, regex.7, socket.7, tcp.7, tzselect.8: Global fix: s/non-zero/nonzero/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:40:55 +00:00
|
|
|
0 and nonzero user IDs,
|
2007-04-12 22:42:49 +00:00
|
|
|
the kernel makes the following changes to a thread's capability
|
|
|
|
sets on changes to the thread's real, effective, saved set,
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
and filesystem user IDs (using
|
2005-10-28 17:41:30 +00:00
|
|
|
.BR setuid (2),
|
|
|
|
.BR setresuid (2),
|
|
|
|
or similar):
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP 1. 3
|
2007-04-12 22:42:49 +00:00
|
|
|
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
|
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt.2, gettimeofday.2, intro.2, ioctl_list.2, ioperm.2, mlock.2, pivot_root.2, poll.2, prctl.2, ptrace.2, sched_setscheduler.2, select_tut.2, semget.2, sigaltstack.2, signalfd.2, sysctl.2, timer_settime.2, timerfd_create.2, wait.2, CPU_SET.3, argz_add.3, assert_perror.3, atexit.3, backtrace.3, bcmp.3, clearenv.3, ctime.3, dl_iterate_phdr.3, dlopen.3, ecvt.3, errno.3, error.3, ether_aton.3, exit.3, fenv.3, ferror.3, finite.3, flockfile.3, fnmatch.3, fpathconf.3, fpclassify.3, ftime.3, ftok.3, ftw.3, fwide.3, getaddrinfo.3, gethostbyname.3, getlogin.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getrpcent.3, getservent.3, glob.3, hsearch.3, inet.3, isalpha.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, longjmp.3, lsearch.3, malloc.3, matherr.3, mblen.3, mbsinit.3, mbtowc.3, on_exit.3, printf.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_equal.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, ptsname.3, putenv.3, putgrent.3, raise.3, rcmd.3, regex.3, rexec.3, rpc.3, rpmatch.3, rtnetlink.3, scandir.3, sem_init.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, signbit.3, stdio_ext.3, strtod.3, strtol.3, strtoul.3, system.3, termios.3, timeradd.3, tzset.3, ualarm.3, wctomb.3, xdr.3, st.4, tty_ioctl.4, core.5, elf.5, proc.5, bootparam.7, capabilities.7, icmp.7, ip.7, ipv6.7, math_error.7, mdoc.samples.7, mq_overview.7, pthreads.7, raw.7, regex.7, socket.7, tcp.7, tzselect.8: Global fix: s/non-zero/nonzero/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:40:55 +00:00
|
|
|
have a nonzero value,
|
2017-12-02 10:08:40 +00:00
|
|
|
then all capabilities are cleared from the permitted, effective, and ambient
|
2005-10-28 17:41:30 +00:00
|
|
|
capability sets.
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP 2.
|
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt.2, gettimeofday.2, intro.2, ioctl_list.2, ioperm.2, mlock.2, pivot_root.2, poll.2, prctl.2, ptrace.2, sched_setscheduler.2, select_tut.2, semget.2, sigaltstack.2, signalfd.2, sysctl.2, timer_settime.2, timerfd_create.2, wait.2, CPU_SET.3, argz_add.3, assert_perror.3, atexit.3, backtrace.3, bcmp.3, clearenv.3, ctime.3, dl_iterate_phdr.3, dlopen.3, ecvt.3, errno.3, error.3, ether_aton.3, exit.3, fenv.3, ferror.3, finite.3, flockfile.3, fnmatch.3, fpathconf.3, fpclassify.3, ftime.3, ftok.3, ftw.3, fwide.3, getaddrinfo.3, gethostbyname.3, getlogin.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getrpcent.3, getservent.3, glob.3, hsearch.3, inet.3, isalpha.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, longjmp.3, lsearch.3, malloc.3, matherr.3, mblen.3, mbsinit.3, mbtowc.3, on_exit.3, printf.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_equal.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, ptsname.3, putenv.3, putgrent.3, raise.3, rcmd.3, regex.3, rexec.3, rpc.3, rpmatch.3, rtnetlink.3, scandir.3, sem_init.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, signbit.3, stdio_ext.3, strtod.3, strtol.3, strtoul.3, system.3, termios.3, timeradd.3, tzset.3, ualarm.3, wctomb.3, xdr.3, st.4, tty_ioctl.4, core.5, elf.5, proc.5, bootparam.7, capabilities.7, icmp.7, ip.7, ipv6.7, math_error.7, mdoc.samples.7, mq_overview.7, pthreads.7, raw.7, regex.7, socket.7, tcp.7, tzselect.8: Global fix: s/non-zero/nonzero/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:40:55 +00:00
|
|
|
If the effective user ID is changed from 0 to nonzero,
|
2005-10-28 17:41:30 +00:00
|
|
|
then all capabilities are cleared from the effective set.
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP 3.
|
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt.2, gettimeofday.2, intro.2, ioctl_list.2, ioperm.2, mlock.2, pivot_root.2, poll.2, prctl.2, ptrace.2, sched_setscheduler.2, select_tut.2, semget.2, sigaltstack.2, signalfd.2, sysctl.2, timer_settime.2, timerfd_create.2, wait.2, CPU_SET.3, argz_add.3, assert_perror.3, atexit.3, backtrace.3, bcmp.3, clearenv.3, ctime.3, dl_iterate_phdr.3, dlopen.3, ecvt.3, errno.3, error.3, ether_aton.3, exit.3, fenv.3, ferror.3, finite.3, flockfile.3, fnmatch.3, fpathconf.3, fpclassify.3, ftime.3, ftok.3, ftw.3, fwide.3, getaddrinfo.3, gethostbyname.3, getlogin.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getrpcent.3, getservent.3, glob.3, hsearch.3, inet.3, isalpha.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, longjmp.3, lsearch.3, malloc.3, matherr.3, mblen.3, mbsinit.3, mbtowc.3, on_exit.3, printf.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_equal.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, ptsname.3, putenv.3, putgrent.3, raise.3, rcmd.3, regex.3, rexec.3, rpc.3, rpmatch.3, rtnetlink.3, scandir.3, sem_init.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, signbit.3, stdio_ext.3, strtod.3, strtol.3, strtoul.3, system.3, termios.3, timeradd.3, tzset.3, ualarm.3, wctomb.3, xdr.3, st.4, tty_ioctl.4, core.5, elf.5, proc.5, bootparam.7, capabilities.7, icmp.7, ip.7, ipv6.7, math_error.7, mdoc.samples.7, mq_overview.7, pthreads.7, raw.7, regex.7, socket.7, tcp.7, tzselect.8: Global fix: s/non-zero/nonzero/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:40:55 +00:00
|
|
|
If the effective user ID is changed from nonzero to 0,
|
2007-04-12 22:42:49 +00:00
|
|
|
then the permitted set is copied to the effective set.
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP 4.
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
If the filesystem user ID is changed from 0 to nonzero (see
|
2014-03-26 12:54:53 +00:00
|
|
|
.BR setfsuid (2)),
|
2005-10-28 17:41:30 +00:00
|
|
|
then the following capabilities are cleared from the effective set:
|
|
|
|
.BR CAP_CHOWN ,
|
|
|
|
.BR CAP_DAC_OVERRIDE ,
|
|
|
|
.BR CAP_DAC_READ_SEARCH ,
|
|
|
|
.BR CAP_FOWNER ,
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR CAP_FSETID ,
|
2009-08-02 07:08:41 +00:00
|
|
|
.B CAP_LINUX_IMMUTABLE
|
2013-09-27 09:17:46 +00:00
|
|
|
(since Linux 2.6.30),
|
2009-08-02 07:08:41 +00:00
|
|
|
.BR CAP_MAC_OVERRIDE ,
|
2005-10-28 17:41:30 +00:00
|
|
|
and
|
2009-08-02 07:08:41 +00:00
|
|
|
.B CAP_MKNOD
|
2013-09-27 09:17:46 +00:00
|
|
|
(since Linux 2.6.30).
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
If the filesystem UID is changed from nonzero to 0,
|
2007-04-12 22:42:49 +00:00
|
|
|
then any of these capabilities that are enabled in the permitted set
|
2005-10-28 17:41:30 +00:00
|
|
|
are enabled in the effective set.
|
|
|
|
.PP
|
2006-05-02 00:36:39 +00:00
|
|
|
If a thread that has a 0 value for one or more of its user IDs wants
|
2005-10-28 17:41:30 +00:00
|
|
|
to prevent its permitted capability set being cleared when it resets
|
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt.2, gettimeofday.2, intro.2, ioctl_list.2, ioperm.2, mlock.2, pivot_root.2, poll.2, prctl.2, ptrace.2, sched_setscheduler.2, select_tut.2, semget.2, sigaltstack.2, signalfd.2, sysctl.2, timer_settime.2, timerfd_create.2, wait.2, CPU_SET.3, argz_add.3, assert_perror.3, atexit.3, backtrace.3, bcmp.3, clearenv.3, ctime.3, dl_iterate_phdr.3, dlopen.3, ecvt.3, errno.3, error.3, ether_aton.3, exit.3, fenv.3, ferror.3, finite.3, flockfile.3, fnmatch.3, fpathconf.3, fpclassify.3, ftime.3, ftok.3, ftw.3, fwide.3, getaddrinfo.3, gethostbyname.3, getlogin.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getrpcent.3, getservent.3, glob.3, hsearch.3, inet.3, isalpha.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, longjmp.3, lsearch.3, malloc.3, matherr.3, mblen.3, mbsinit.3, mbtowc.3, on_exit.3, printf.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_equal.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, ptsname.3, putenv.3, putgrent.3, raise.3, rcmd.3, regex.3, rexec.3, rpc.3, rpmatch.3, rtnetlink.3, scandir.3, sem_init.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, signbit.3, stdio_ext.3, strtod.3, strtol.3, strtoul.3, system.3, termios.3, timeradd.3, tzset.3, ualarm.3, wctomb.3, xdr.3, st.4, tty_ioctl.4, core.5, elf.5, proc.5, bootparam.7, capabilities.7, icmp.7, ip.7, ipv6.7, math_error.7, mdoc.samples.7, mq_overview.7, pthreads.7, raw.7, regex.7, socket.7, tcp.7, tzselect.8: Global fix: s/non-zero/nonzero/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:40:55 +00:00
|
|
|
all of its user IDs to nonzero values, it can do so using the
|
2015-02-07 20:09:09 +00:00
|
|
|
.B SECBIT_KEEP_CAPS
|
2015-03-21 10:21:40 +00:00
|
|
|
securebits flag described below.
|
2008-07-09 12:11:50 +00:00
|
|
|
.\"
|
|
|
|
.SS Programmatically adjusting capability sets
|
2018-05-01 10:46:48 +00:00
|
|
|
A thread can retrieve and change its permitted, effective, and inheritable
|
|
|
|
capability sets using the
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR capget (2)
|
|
|
|
and
|
|
|
|
.BR capset (2)
|
|
|
|
system calls.
|
|
|
|
However, the use of
|
|
|
|
.BR cap_get_proc (3)
|
|
|
|
and
|
|
|
|
.BR cap_set_proc (3),
|
|
|
|
both provided in the
|
|
|
|
.I libcap
|
|
|
|
package,
|
|
|
|
is preferred for this purpose.
|
|
|
|
The following rules govern changes to the thread capability sets:
|
|
|
|
.IP 1. 3
|
|
|
|
If the caller does not have the
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
capability,
|
|
|
|
the new inheritable set must be a subset of the combination
|
|
|
|
of the existing inheritable and permitted sets.
|
|
|
|
.IP 2.
|
2013-01-06 21:10:16 +00:00
|
|
|
(Since Linux 2.6.25)
|
2008-07-09 12:11:50 +00:00
|
|
|
The new inheritable set must be a subset of the combination of the
|
|
|
|
existing inheritable set and the capability bounding set.
|
|
|
|
.IP 3.
|
|
|
|
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).
|
|
|
|
.IP 4.
|
|
|
|
The new effective set must be a subset of the new permitted set.
|
intro.1, time.1, _syscall.2, accept.2, capget.2, clone.2, execve.2, fcntl.2, intro.2, ioctl_list.2, ioprio_set.2, kill.2, mlock.2, nanosleep.2, perf_event_open.2, select.2, stat.2, times.2, ustat.2, vfork.2, wait.2, cfree.3, dbopen.3, dlopen.3, fenv.3, fmtmsg.3, gamma.3, getaddrinfo.3, gethostbyname.3, getnameinfo.3, getspnam.3, login.3, printf.3, regex.3, stdio.3, sysconf.3, termios.3, ttyslot.3, undocumented.3, wordexp.3, console_codes.4, initrd.4, mouse.4, random.4, st.4, tty_ioctl.4, wavelan.4, charmap.5, dir_colors.5, hosts.5, termcap.5, armscii-8.7, boot.7, bootparam.7, capabilities.7, charsets.7, ddp.7, futex.7, glob.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man.7, numa.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, rtnetlink.7, signal.7, time.7, udp.7, udplite.7, unicode.7, uri.7, utf-8.7: G;lobal fix: remove unneeded double quotes in .SS headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:02:18 +00:00
|
|
|
.SS The securebits flags: establishing a capabilities-only environment
|
2008-07-09 12:11:50 +00:00
|
|
|
.\" For some background:
|
|
|
|
.\" see http://lwn.net/Articles/280279/ and
|
|
|
|
.\" http://article.gmane.org/gmane.linux.kernel.lsm/5476/
|
|
|
|
Starting with kernel 2.6.26,
|
|
|
|
and with a kernel in which file capabilities are enabled,
|
|
|
|
Linux implements a set of per-thread
|
|
|
|
.I securebits
|
|
|
|
flags that can be used to disable special handling of capabilities for UID 0
|
|
|
|
.RI ( root ).
|
|
|
|
These flags are as follows:
|
|
|
|
.TP
|
2010-01-31 14:43:38 +00:00
|
|
|
.B SECBIT_KEEP_CAPS
|
2008-07-09 12:11:50 +00:00
|
|
|
Setting this flag allows a thread that has one or more 0 UIDs to retain
|
2018-11-01 13:32:55 +00:00
|
|
|
capabilities in its permitted set
|
2017-12-02 14:43:02 +00:00
|
|
|
when it switches all of its UIDs to nonzero values.
|
2008-07-09 12:11:50 +00:00
|
|
|
If this flag is not set,
|
2018-11-01 13:32:55 +00:00
|
|
|
then such a UID switch causes the thread to lose all permitted capabilities.
|
2008-07-09 12:11:50 +00:00
|
|
|
This flag is always cleared on an
|
|
|
|
.BR execve (2).
|
2017-12-02 15:17:57 +00:00
|
|
|
.IP
|
capabilities.7: Add details about SECBIT_KEEP_CAPS
The description of SECBIT_KEEP_CAPS is misleading about the
effects on the effective capabilities of a process during a
switch to nonzero UIDs. The effective set is cleared based on
the effective UID switching to a nonzero value, even if
SECBIT_KEEP_CAPS is set. However, with this bit set, the
effective and permitted sets are not cleared if the real and
saved set-user-ID are set to nonzero values.
This was tested using the following C code and reading the kernel
source at security/commoncap.c: cap_emulate_setxuid.
void print_caps(void) {
cap_t current = cap_get_proc();
if (!current) {
perror("Current caps");
return;
}
char *text = cap_to_text(current, NULL);
if (!text) {
perror("Converting caps to text");
goto free_caps;
}
printf("Capabilities: %s\n", text);
cap_free(text);
free_caps:
cap_free(current);
}
void print_creds(void) {
uid_t ruid, suid, euid;
if (getresuid(&ruid, &euid, &suid)) {
perror("Error getting UIDs");
return;
}
printf("real = %d, effective = %d, saved set-user-ID = %d\n", ruid, euid, suid);
}
void set_caps(int size, const cap_value_t *caps) {
cap_t current = cap_init();
if (!current) {
perror("Error getting current caps");
return;
}
if (cap_clear(current)) {
perror("Error clearing caps");
}
if (cap_set_flag(current, CAP_INHERITABLE, size, caps, CAP_SET)) {
perror("setting caps");
goto free_caps;
}
if (cap_set_flag(current, CAP_EFFECTIVE, size, caps, CAP_SET)) {
perror("setting caps");
goto free_caps;
}
if (cap_set_flag(current, CAP_PERMITTED, size, caps, CAP_SET)) {
perror("setting caps");
goto free_caps;
}
if (cap_set_proc(current)) {
perror("Comitting caps");
goto free_caps;
}
free_caps:
cap_free(current);
}
const cap_value_t caps[] = {CAP_SETUID, CAP_SETPCAP};
const size_t num_caps = sizeof(caps) / sizeof(cap_value_t);
int main(int argc, char **argv) {
puts("[+] Dropping most capabilities to reduce amount of console output...");
set_caps(num_caps, caps);
puts("[+] Dropped capabilities. Starting with these credentials and capabilities:");
print_caps();
print_creds();
if (argc >= 2 && 0 == strncmp(argv[1], "keep", 4)) {
puts("[+] Setting SECBIT_KEEP_CAPS bit");
if (prctl(PR_SET_SECUREBITS, SECBIT_KEEP_CAPS, 0, 0, 0)) {
perror("Setting secure bits");
return 1;
}
}
puts("[+] Setting effective UID to 1000");
if (seteuid(1000)) {
perror("Error setting effective UID");
return 2;
}
print_caps();
print_creds();
puts("[+] Raising caps again");
set_caps(num_caps, caps);
print_caps();
print_creds();
puts("[+] Setting all remaining UIDs to nonzero values");
if (setreuid(1000, 1000)) {
perror("Error setting all UIDs to 1000");
return 3;
}
print_caps();
print_creds();
return 0;
}
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-10-31 09:35:47 +00:00
|
|
|
Note that even with the
|
|
|
|
.B SECBIT_KEEP_CAPS
|
|
|
|
flag set, the effective capabilities of a thread are cleared when it
|
2018-11-01 13:38:06 +00:00
|
|
|
switches its effective UID to a nonzero value.
|
|
|
|
However,
|
|
|
|
if the thread has set this flag and its effective UID is already nonzero,
|
|
|
|
and the thread subsequently switches all other UIDs to nonzero values,
|
|
|
|
then the effective capabilities will not be cleared.
|
capabilities.7: Add details about SECBIT_KEEP_CAPS
The description of SECBIT_KEEP_CAPS is misleading about the
effects on the effective capabilities of a process during a
switch to nonzero UIDs. The effective set is cleared based on
the effective UID switching to a nonzero value, even if
SECBIT_KEEP_CAPS is set. However, with this bit set, the
effective and permitted sets are not cleared if the real and
saved set-user-ID are set to nonzero values.
This was tested using the following C code and reading the kernel
source at security/commoncap.c: cap_emulate_setxuid.
void print_caps(void) {
cap_t current = cap_get_proc();
if (!current) {
perror("Current caps");
return;
}
char *text = cap_to_text(current, NULL);
if (!text) {
perror("Converting caps to text");
goto free_caps;
}
printf("Capabilities: %s\n", text);
cap_free(text);
free_caps:
cap_free(current);
}
void print_creds(void) {
uid_t ruid, suid, euid;
if (getresuid(&ruid, &euid, &suid)) {
perror("Error getting UIDs");
return;
}
printf("real = %d, effective = %d, saved set-user-ID = %d\n", ruid, euid, suid);
}
void set_caps(int size, const cap_value_t *caps) {
cap_t current = cap_init();
if (!current) {
perror("Error getting current caps");
return;
}
if (cap_clear(current)) {
perror("Error clearing caps");
}
if (cap_set_flag(current, CAP_INHERITABLE, size, caps, CAP_SET)) {
perror("setting caps");
goto free_caps;
}
if (cap_set_flag(current, CAP_EFFECTIVE, size, caps, CAP_SET)) {
perror("setting caps");
goto free_caps;
}
if (cap_set_flag(current, CAP_PERMITTED, size, caps, CAP_SET)) {
perror("setting caps");
goto free_caps;
}
if (cap_set_proc(current)) {
perror("Comitting caps");
goto free_caps;
}
free_caps:
cap_free(current);
}
const cap_value_t caps[] = {CAP_SETUID, CAP_SETPCAP};
const size_t num_caps = sizeof(caps) / sizeof(cap_value_t);
int main(int argc, char **argv) {
puts("[+] Dropping most capabilities to reduce amount of console output...");
set_caps(num_caps, caps);
puts("[+] Dropped capabilities. Starting with these credentials and capabilities:");
print_caps();
print_creds();
if (argc >= 2 && 0 == strncmp(argv[1], "keep", 4)) {
puts("[+] Setting SECBIT_KEEP_CAPS bit");
if (prctl(PR_SET_SECUREBITS, SECBIT_KEEP_CAPS, 0, 0, 0)) {
perror("Setting secure bits");
return 1;
}
}
puts("[+] Setting effective UID to 1000");
if (seteuid(1000)) {
perror("Error setting effective UID");
return 2;
}
print_caps();
print_creds();
puts("[+] Raising caps again");
set_caps(num_caps, caps);
print_caps();
print_creds();
puts("[+] Setting all remaining UIDs to nonzero values");
if (setreuid(1000, 1000)) {
perror("Error setting all UIDs to 1000");
return 3;
}
print_caps();
print_creds();
return 0;
}
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-10-31 09:35:47 +00:00
|
|
|
.IP
|
2017-12-02 21:31:21 +00:00
|
|
|
The setting of the
|
|
|
|
.B SECBIT_KEEP_CAPS
|
|
|
|
flag is ignored if the
|
|
|
|
.B SECBIT_NO_SETUID_FIXUP
|
|
|
|
flag is set.
|
|
|
|
(The latter flag provides a superset of the effect of the former flag.)
|
|
|
|
.IP
|
2017-12-02 15:17:57 +00:00
|
|
|
This flag provides the same functionality as the older
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR prctl (2)
|
|
|
|
.B PR_SET_KEEPCAPS
|
2017-12-02 15:17:57 +00:00
|
|
|
operation.
|
2008-07-09 12:11:50 +00:00
|
|
|
.TP
|
2010-01-31 14:43:38 +00:00
|
|
|
.B SECBIT_NO_SETUID_FIXUP
|
2017-12-02 15:34:39 +00:00
|
|
|
Setting this flag stops the kernel from adjusting the process's
|
|
|
|
permitted, effective, and ambient capability sets when
|
2016-02-28 00:32:40 +00:00
|
|
|
the thread's effective and filesystem UIDs are switched between
|
intro.1, time.1, adjtimex.2, capget.2, eventfd.2, fcntl.2, getrlimit.2, getsockopt.2, gettimeofday.2, intro.2, ioctl_list.2, ioperm.2, mlock.2, pivot_root.2, poll.2, prctl.2, ptrace.2, sched_setscheduler.2, select_tut.2, semget.2, sigaltstack.2, signalfd.2, sysctl.2, timer_settime.2, timerfd_create.2, wait.2, CPU_SET.3, argz_add.3, assert_perror.3, atexit.3, backtrace.3, bcmp.3, clearenv.3, ctime.3, dl_iterate_phdr.3, dlopen.3, ecvt.3, errno.3, error.3, ether_aton.3, exit.3, fenv.3, ferror.3, finite.3, flockfile.3, fnmatch.3, fpathconf.3, fpclassify.3, ftime.3, ftok.3, ftw.3, fwide.3, getaddrinfo.3, gethostbyname.3, getlogin.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getrpcent.3, getservent.3, glob.3, hsearch.3, inet.3, isalpha.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, longjmp.3, lsearch.3, malloc.3, matherr.3, mblen.3, mbsinit.3, mbtowc.3, on_exit.3, printf.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_attr_setdetachstate.3, pthread_attr_setguardsize.3, pthread_attr_setinheritsched.3, pthread_attr_setschedparam.3, pthread_attr_setschedpolicy.3, pthread_attr_setscope.3, pthread_attr_setstack.3, pthread_attr_setstackaddr.3, pthread_attr_setstacksize.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_equal.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setcancelstate.3, pthread_setconcurrency.3, pthread_setschedparam.3, pthread_setschedprio.3, ptsname.3, putenv.3, putgrent.3, raise.3, rcmd.3, regex.3, rexec.3, rpc.3, rpmatch.3, rtnetlink.3, scandir.3, sem_init.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, signbit.3, stdio_ext.3, strtod.3, strtol.3, strtoul.3, system.3, termios.3, timeradd.3, tzset.3, ualarm.3, wctomb.3, xdr.3, st.4, tty_ioctl.4, core.5, elf.5, proc.5, bootparam.7, capabilities.7, icmp.7, ip.7, ipv6.7, math_error.7, mdoc.samples.7, mq_overview.7, pthreads.7, raw.7, regex.7, socket.7, tcp.7, tzselect.8: Global fix: s/non-zero/nonzero/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:40:55 +00:00
|
|
|
zero and nonzero values.
|
2008-07-09 12:11:50 +00:00
|
|
|
(See the subsection
|
2016-02-28 23:40:56 +00:00
|
|
|
.IR "Effect of user ID changes on capabilities" .)
|
2008-07-09 12:11:50 +00:00
|
|
|
.TP
|
2010-01-31 14:43:38 +00:00
|
|
|
.B SECBIT_NOROOT
|
2008-07-09 12:11:50 +00:00
|
|
|
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
|
2008-07-09 13:55:24 +00:00
|
|
|
.BR execve (2).
|
2008-07-09 12:11:50 +00:00
|
|
|
(See the subsection
|
|
|
|
.IR "Capabilities and execution of programs by root" .)
|
2015-12-04 07:32:35 +00:00
|
|
|
.TP
|
|
|
|
.B SECBIT_NO_CAP_AMBIENT_RAISE
|
2015-12-04 09:20:18 +00:00
|
|
|
Setting this flag disallows raising ambient capabilities via the
|
|
|
|
.BR prctl (2)
|
|
|
|
.BR PR_CAP_AMBIENT_RAISE
|
|
|
|
operation.
|
2008-07-09 12:11:50 +00:00
|
|
|
.PP
|
|
|
|
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:
|
2010-01-31 14:43:38 +00:00
|
|
|
.BR SECBIT_KEEP_CAPS_LOCKED ,
|
|
|
|
.BR SECBIT_NO_SETUID_FIXUP_LOCKED ,
|
2015-12-04 07:32:35 +00:00
|
|
|
.BR SECBIT_NOROOT_LOCKED ,
|
2008-07-09 12:11:50 +00:00
|
|
|
and
|
2016-02-26 15:31:44 +00:00
|
|
|
.BR SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED .
|
2008-07-09 12:11:50 +00:00
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.I securebits
|
|
|
|
flags can be modified and retrieved using the
|
|
|
|
.BR prctl (2)
|
|
|
|
.B PR_SET_SECUREBITS
|
|
|
|
and
|
|
|
|
.B PR_GET_SECUREBITS
|
|
|
|
operations.
|
|
|
|
The
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
capability is required to modify the flags.
|
2018-10-31 20:07:49 +00:00
|
|
|
Note that the
|
|
|
|
.BR SECBIT_*
|
|
|
|
constants are available only after including the
|
|
|
|
.I <linux/securebits.h>
|
|
|
|
header file.
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2008-07-09 12:11:50 +00:00
|
|
|
The
|
|
|
|
.I securebits
|
|
|
|
flags are inherited by child processes.
|
|
|
|
During an
|
|
|
|
.BR execve (2),
|
|
|
|
all of the flags are preserved, except
|
2011-09-08 14:52:50 +00:00
|
|
|
.B SECBIT_KEEP_CAPS
|
2008-07-09 12:11:50 +00:00
|
|
|
which is always cleared.
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2008-07-09 12:11:50 +00:00
|
|
|
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:
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2008-07-09 12:11:50 +00:00
|
|
|
.in +4n
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EX
|
2008-07-09 12:11:50 +00:00
|
|
|
prctl(PR_SET_SECUREBITS,
|
2018-05-02 09:37:29 +00:00
|
|
|
/* SECBIT_KEEP_CAPS off */
|
2010-01-31 14:43:38 +00:00
|
|
|
SECBIT_KEEP_CAPS_LOCKED |
|
|
|
|
SECBIT_NO_SETUID_FIXUP |
|
|
|
|
SECBIT_NO_SETUID_FIXUP_LOCKED |
|
|
|
|
SECBIT_NOROOT |
|
|
|
|
SECBIT_NOROOT_LOCKED);
|
2017-12-02 20:47:28 +00:00
|
|
|
/* Setting/locking SECBIT_NO_CAP_AMBIENT_RAISE
|
capabilities.7: Note on SECURE_NO_CAP_AMBIENT_RAISE for capabilities-only environment
A few months after applying Andy Lutomirski's patch that documented
ambient capabilities, I found myself again asking a question
that I'd already once asked of Any. So, best to be more explicit
in the man page that setting/locking SECBIT_NO_CAP_AMBIENT_RAISE
is not required when using prctl(PR_SET_SECUREBITS) to create
a capabilities-only environment.
This was the 4 Dec 2015 reply from Andy to my question:
> In the capabilities(7) page tehre is the longstanding text:
>
> 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 associ‐
> ated file capabilities:
>
> prctl(PR_SET_SECUREBITS,
> SECBIT_KEEP_CAPS_LOCKED |
> SECBIT_NO_SETUID_FIXUP |
> SECBIT_NO_SETUID_FIXUP_LOCKED |
> SECBIT_NOROOT |
> SECBIT_NOROOT_LOCKED);
>
> As far as I can estimate, no changes are needed here to include
> SECBIT_NO_CAP_AMBIENT_RAISE and SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED
> in the above prctl() call, but could you confirm please?
Correct. I'll probably write up a patch to suggest that doing this is
a poor idea on a conventional distro, though, and I'll explain why. I
suppose than deleting this would be an option, too.
Reported-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-07-06 08:10:32 +00:00
|
|
|
is not required */
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EE
|
2008-07-09 12:11:50 +00:00
|
|
|
.in
|
2019-02-14 07:25:25 +00:00
|
|
|
.\"
|
|
|
|
.\"
|
2019-02-14 10:09:50 +00:00
|
|
|
.SS Per-user-namespace """set-user-ID-root""" programs
|
|
|
|
A set-user-ID program whose UID matches the UID that
|
|
|
|
created a user namespace will confer capabilities
|
|
|
|
in the process's permitted and effective sets
|
|
|
|
when executed by any process inside that namespace
|
|
|
|
or any descendant user namespace.
|
|
|
|
.PP
|
|
|
|
The rules about the transformation of the process's capabilities during the
|
|
|
|
.BR execve (2)
|
|
|
|
are exactly as described in the subsections
|
|
|
|
.IR "Transformation of capabilities during execve()"
|
|
|
|
and
|
|
|
|
.IR "Capabilities and execution of programs by root" ,
|
|
|
|
with the difference that, in the latter subsection, "root"
|
|
|
|
is the UID of the creator of the user namespace.
|
|
|
|
.\"
|
|
|
|
.\"
|
2018-01-14 20:39:15 +00:00
|
|
|
.SS Namespaced file capabilities
|
|
|
|
.\" commit 8db6c34f1dbc8e06aa016a9b829b06902c3e1340
|
|
|
|
Traditional (i.e., version 2) file capabilities associate
|
|
|
|
only a set of capability masks with a binary executable file.
|
|
|
|
When a process executes a binary with such capabilities,
|
|
|
|
it gains the associated capabilities (within its user namespace)
|
|
|
|
as per the rules described above in
|
|
|
|
"Transformation of capabilities during execve()".
|
|
|
|
.PP
|
|
|
|
Because version 2 file capabilities confer capabilities to
|
|
|
|
the executing process regardless of which user namespace it resides in,
|
|
|
|
only privileged processes are permitted to associate capabilities with a file.
|
2018-04-13 19:04:29 +00:00
|
|
|
Here, "privileged" means a process that has the
|
2018-01-14 20:39:15 +00:00
|
|
|
.BR CAP_SETFCAP
|
|
|
|
capability in the user namespace where the filesystem was mounted
|
|
|
|
(normally the initial user namespace).
|
|
|
|
This limitation renders file capabilities useless for certain use cases.
|
|
|
|
For example, in user-namespaced containers,
|
|
|
|
it can be desirable to be able to create a binary that
|
|
|
|
confers capabilities only to processes executed inside that container,
|
|
|
|
but not to processes that are executed outside the container.
|
|
|
|
.PP
|
|
|
|
Linux 4.14 added so-called namespaced file capabilities
|
|
|
|
to support such use cases.
|
|
|
|
Namespaced file capabilities are recorded as version 3 (i.e.,
|
|
|
|
.BR VFS_CAP_REVISION_3 )
|
|
|
|
.I security.capability
|
|
|
|
extended attributes.
|
2018-07-01 09:40:26 +00:00
|
|
|
Such an attribute is automatically created in the circumstances described
|
|
|
|
above under "File capability extended attribute versioning".
|
|
|
|
When a version 3
|
|
|
|
.I security.capability
|
|
|
|
extended attribute is created,
|
2018-01-14 20:39:15 +00:00
|
|
|
the kernel records not just the capability masks in the extended attribute,
|
2018-04-13 19:04:29 +00:00
|
|
|
but also the namespace root user ID.
|
2018-01-14 20:39:15 +00:00
|
|
|
.PP
|
2018-04-13 19:04:29 +00:00
|
|
|
As with a binary that has
|
|
|
|
.BR VFS_CAP_REVISION_2
|
|
|
|
file capabilities, a binary with
|
|
|
|
.BR VFS_CAP_REVISION_3
|
|
|
|
file capabilities confers capabilities to a process during
|
|
|
|
.BR execve ().
|
|
|
|
However, capabilities are conferred only if the binary is executed by
|
|
|
|
a process that resides in a user namespace whose
|
|
|
|
UID 0 maps to the root user ID that is saved in the extended attribute,
|
2018-05-02 19:16:20 +00:00
|
|
|
or when executed by a process that resides in a descendant of such a namespace.
|
2019-02-14 09:47:34 +00:00
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.SS Interaction with user namespaces
|
|
|
|
For further information on the interaction of
|
|
|
|
capabilities and user namespaces, see
|
|
|
|
.BR user_namespaces (7).
|
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bdflush.2, bind.2, brk.2, cacheflush.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, clone.2, close.2, connect.2, create_module.2, delete_module.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, flock.2, fork.2, fstatat.2, fsync.2, futex.2, futimesat.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getitimer.2, getpagesize.2, getpeername.2, getpid.2, getpriority.2, getresuid.2, getrlimit.2, getrusage.2, getsid.2, getsockname.2, getsockopt.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, getxattr.2, idle.2, init_module.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, intro.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl.2, ioctl_list.2, ioperm.2, iopl.2, ioprio_set.2, ipc.2, kcmp.2, kill.2, killpg.2, link.2, linkat.2, listen.2, listxattr.2, llseek.2, lookup_dcookie.2, lseek.2, madvise.2, migrate_pages.2, mincore.2, mkdir.2, mkdirat.2, mknod.2, mknodat.2, mlock.2, mmap.2, mmap2.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, mq_getsetattr.2, mremap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nfsservctl.2, nice.2, open.2, openat.2, outb.2, pause.2, pciconfig_read.2, perf_event_open.2, perfmonctl.2, personality.2, pipe.2, pivot_root.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, read.2, readahead.2, readdir.2, readlink.2, readlinkat.2, readv.2, reboot.2, recv.2, remap_file_pages.2, removexattr.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, semctl.2, semget.2, semop.2, send.2, sendfile.2, set_thread_area.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, setup.2, setxattr.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, sigaltstack.2, signal.2, signalfd.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, socket.2, socketcall.2, socketpair.2, splice.2, stat.2, statfs.2, stime.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, sysctl.2, sysfs.2, sysinfo.2, syslog.2, tee.2, time.2, timerfd_create.2, times.2, tkill.2, truncate.2, umask.2, umount.2, uname.2, unimplemented.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, MB_CUR_MAX.3, MB_LEN_MAX.3, __setfpucw.3, a64l.3, abort.3, abs.3, acos.3, acosh.3, addseverity.3, adjtime.3, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, alloca.3, argz_add.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, backtrace.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, btowc.3, btree.3, byteorder.3, bzero.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, catgets.3, catopen.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cerf.3, cexp.3, cexp2.3, cfree.3, cimag.3, clearenv.3, clock.3, clock_getcpuclockid.3, clog.3, clog10.3, clog2.3, closedir.3, cmsg.3, confstr.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, crypt.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctermid.3, ctime.3, daemon.3, dbopen.3, des_crypt.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, encrypt.3, end.3, endian.3, envz_add.3, erf.3, erfc.3, err.3, errno.3, error.3, ether_aton.3, euidaccess.3, exec.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fclose.3, fcloseall.3, fdim.3, fenv.3, ferror.3, fexecve.3, fflush.3, ffs.3, fgetgrent.3, fgetpwent.3, fgetwc.3, fgetws.3, finite.3, flockfile.3, floor.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmod.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fpurge.3, fputwc.3, fputws.3, fread.3, frexp.3, fseek.3, fseeko.3, ftime.3, ftok.3, fts.3, ftw.3, futimes.3, fwide.3, gamma.3, gcvt.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getipnodebyname.3, getline.3, getloadavg.3, getlogin.3, getmntent.3, getnameinfo.3, getnetent.3, getnetent_r.3, getopt.3, getpass.3, getprotoent.3, getprotoent_r.3, getpt.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getrpcent_r.3, getrpcport.3, gets.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, getumask.3, getusershell.3, getutent.3, getw.3, getwchar.3, glob.3, grantpt.3, gsignal.3, hash.3, hsearch.3, hypot.3, iconv.3, iconv_close.3, iconv_open.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, j0.3, key_setsecret.3, ldexp.3, lgamma.3, lio_listio.3, localeconv.3, lockf.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, longjmp.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, malloc.3, malloc_hook.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, mempcpy.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mpool.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, nan.3, netlink.3, nextafter.3, nl_langinfo.3, offsetof.3, on_exit.3, opendir.3, openpty.3, perror.3, popen.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, printf.3, profil.3, program_invocation_name.3, psignal.3, pthread_kill_other_threads_np.3, ptsname.3, putenv.3, putgrent.3, putpwent.3, puts.3, putwchar.3, qecvt.3, qsort.3, queue.3, raise.3, rand.3, random.3, random_r.3, rcmd.3, re_comp.3, readdir.3, realpath.3, recno.3, regex.3, remainder.3, remove.3, remquo.3, resolver.3, rewinddir.3, rexec.3, rint.3, round.3, rpc.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, scandirat.3, scanf.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, setnetgrent.3, shm_open.3, siginterrupt.3, signbit.3, significand.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sin.3, sincos.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdarg.3, stdin.3, stdio.3, stdio_ext.3, stpcpy.3, stpncpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfmon.3, strfry.3, strftime.3, string.3, strlen.3, strnlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, termios.3, tgamma.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, towctrans.3, towlower.3, towupper.3, trunc.3, tsearch.3, ttyname.3, ttyslot.3, tzset.3, ualarm.3, ulimit.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, updwtmp.3, usleep.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, xcrypt.3, xdr.3, y0.3, cciss.4, console.4, console_codes.4, console_ioctl.4, dsp56k.4, fd.4, full.4, hd.4, hpsa.4, initrd.4, intro.4, lp.4, mem.4, mouse.4, null.4, pts.4, ram.4, random.4, rtc.4, sk98lin.4, st.4, tty.4, ttyS.4, tty_ioctl.4, vcs.4, wavelan.4, acct.5, charmap.5, dir_colors.5, filesystems.5, ftpusers.5, group.5, host.conf.5, hosts.5, hosts.equiv.5, intro.5, issue.5, locale.5, motd.5, networks.5, nologin.5, nscd.conf.5, passwd.5, proc.5, protocols.5, resolv.conf.5, rpc.5, securetty.5, services.5, shells.5, termcap.5, ttytype.5, utmp.5, armscii-8.7, arp.7, ascii.7, bootparam.7, capabilities.7, charsets.7, complex.7, cp1251.7, credentials.7, ddp.7, environ.7, epoll.7, fifo.7, futex.7, glob.7, hier.7, icmp.7, inotify.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, locale.7, mailaddr.7, man.7, mq_overview.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, raw.7, regex.7, rtld-audit.7, rtnetlink.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, socket.7, standards.7, suffixes.7, svipc.7, tcp.7, termio.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, nscd.8, sync.8, tzselect.8, zdump.8, zic.8: Global fix: remove unneeded double quotes in .SH headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:01:36 +00:00
|
|
|
.SH CONFORMING TO
|
2007-05-19 04:30:20 +00:00
|
|
|
No standards govern capabilities, but the Linux capability implementation
|
2008-07-09 12:11:50 +00:00
|
|
|
is based on the withdrawn POSIX.1e draft standard; see
|
2018-09-28 21:07:03 +00:00
|
|
|
.UR https://archive.org\:/details\:/posix_1003.1e-990310
|
capget.2, futex.2, sched_setscheduler.2, spu_create.2, spu_run.2, vfork.2, getnameinfo.3, netlink.3, cciss.4, console_codes.4, dsp56k.4, hpsa.4, sk98lin.4, filesystems.5, protocols.5, aio.7, capabilities.7, charsets.7, feature_test_macros.7, futex.7, hier.7, iso_8859-16.7, iso_8859-2.7, koi8-r.7, libc.7, man.7, netlink.7, numa.7, standards.7, unicode.7, units.7, uri.7, x25.7: Global fix: use UR macro where applicable
The syntax .UR http://example.com paired with .UE will create
links which one can interact, if the pager allows that. One
way to see the effect is ask the man(1) command to use browser
display, e.g.:
man -H man7/uri.7
("\:" is optional groff syntax to permit hyphenless line breaks.)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-08-13 08:02:36 +00:00
|
|
|
.UE .
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTES
|
2019-07-17 02:19:01 +00:00
|
|
|
When attempting to
|
|
|
|
.BR strace (1)
|
|
|
|
binaries that have capabilities (or set-user-ID-root binaries),
|
|
|
|
you may find the
|
|
|
|
.I \-u <username>
|
|
|
|
option useful.
|
|
|
|
Something like:
|
|
|
|
.PP
|
|
|
|
.in +4n
|
|
|
|
.EX
|
|
|
|
$ \fBsudo strace \-o trace.log \-u ceci ./myprivprog\fP
|
|
|
|
.EE
|
|
|
|
.in
|
|
|
|
.PP
|
2015-02-05 14:15:56 +00:00
|
|
|
From kernel 2.5.27 to kernel 2.6.26,
|
|
|
|
.\" commit 5915eb53861c5776cfec33ca4fcc1fd20d66dd27 removed
|
|
|
|
.\" CONFIG_SECURITY_CAPABILITIES
|
|
|
|
capabilities were an optional kernel component,
|
2016-03-09 23:22:33 +00:00
|
|
|
and could be enabled/disabled via the
|
2014-08-01 15:09:20 +00:00
|
|
|
.B CONFIG_SECURITY_CAPABILITIES
|
2008-07-09 12:11:50 +00:00
|
|
|
kernel configuration option.
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2008-07-09 12:11:50 +00:00
|
|
|
The
|
getrusage.2, madvise.2, memfd_create.2, mlock.2, mount.2, getauxval.3, core.5, capabilities.7, pid_namespaces.7, symlink.7, user_namespaces.7: Consistently use /proc/[pid] (not /proc/PID)
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-10-07 20:42:07 +00:00
|
|
|
.I /proc/[pid]/task/TID/status
|
2008-07-09 12:11:50 +00:00
|
|
|
file can be used to view the capability sets of a thread.
|
|
|
|
The
|
getrusage.2, madvise.2, memfd_create.2, mlock.2, mount.2, getauxval.3, core.5, capabilities.7, pid_namespaces.7, symlink.7, user_namespaces.7: Consistently use /proc/[pid] (not /proc/PID)
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-10-07 20:42:07 +00:00
|
|
|
.I /proc/[pid]/status
|
2008-07-09 12:11:50 +00:00
|
|
|
file shows the capability sets of a process's main thread.
|
2013-02-28 13:52:41 +00:00
|
|
|
Before Linux 3.8, nonexistent capabilities were shown as being
|
|
|
|
enabled (1) in these sets.
|
|
|
|
Since Linux 3.8,
|
|
|
|
.\" 7b9a7ec565505699f503b4fcf61500dceb36e744
|
2014-01-02 21:11:34 +00:00
|
|
|
all nonexistent capabilities (above
|
2013-03-10 12:05:00 +00:00
|
|
|
.BR CAP_LAST_CAP )
|
2013-02-28 13:52:41 +00:00
|
|
|
are shown as disabled (0).
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2004-11-03 13:51:07 +00:00
|
|
|
The
|
|
|
|
.I libcap
|
|
|
|
package provides a suite of routines for setting and
|
2006-05-02 00:36:39 +00:00
|
|
|
getting capabilities that is more comfortable and less likely
|
2004-11-03 13:51:07 +00:00
|
|
|
to change than the interface provided by
|
|
|
|
.BR capset (2)
|
|
|
|
and
|
|
|
|
.BR capget (2).
|
2008-07-09 12:11:50 +00:00
|
|
|
This package also provides the
|
|
|
|
.BR setcap (8)
|
|
|
|
and
|
|
|
|
.BR getcap (8)
|
|
|
|
programs.
|
|
|
|
It can be found at
|
|
|
|
.br
|
2018-11-17 06:03:07 +00:00
|
|
|
.UR https://git.kernel.org\:/pub\:/scm\:/libs\:/libcap\:/libcap.git\:/refs/
|
capget.2, futex.2, sched_setscheduler.2, spu_create.2, spu_run.2, vfork.2, getnameinfo.3, netlink.3, cciss.4, console_codes.4, dsp56k.4, hpsa.4, sk98lin.4, filesystems.5, protocols.5, aio.7, capabilities.7, charsets.7, feature_test_macros.7, futex.7, hier.7, iso_8859-16.7, iso_8859-2.7, koi8-r.7, libc.7, man.7, netlink.7, numa.7, standards.7, unicode.7, units.7, uri.7, x25.7: Global fix: use UR macro where applicable
The syntax .UR http://example.com paired with .UE will create
links which one can interact, if the pager allows that. One
way to see the effect is ask the man(1) command to use browser
display, e.g.:
man -H man7/uri.7
("\:" is optional groff syntax to permit hyphenless line breaks.)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-08-13 08:02:36 +00:00
|
|
|
.UE .
|
2017-08-12 21:25:45 +00:00
|
|
|
.PP
|
2014-11-16 17:03:38 +00:00
|
|
|
Before kernel 2.6.24, and from kernel 2.6.24 to kernel 2.6.32 if
|
2008-07-09 12:11:50 +00:00
|
|
|
file capabilities are not enabled, a thread with the
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
capability can manipulate the capabilities of threads other than itself.
|
|
|
|
However, this is only theoretically possible,
|
|
|
|
since no thread ever has
|
|
|
|
.BR CAP_SETPCAP
|
|
|
|
in either of these cases:
|
|
|
|
.IP * 2
|
|
|
|
In the pre-2.6.25 implementation the system-wide capability bounding set,
|
|
|
|
.IR /proc/sys/kernel/cap-bound ,
|
2019-12-30 09:57:50 +00:00
|
|
|
always masks out the
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
capability, and this can not be changed
|
|
|
|
without modifying the kernel source and rebuilding the kernel.
|
2008-07-09 12:11:50 +00:00
|
|
|
.IP *
|
2019-12-30 10:00:02 +00:00
|
|
|
If file capabilities are disabled (i.e., the kernel
|
|
|
|
.B CONFIG_SECURITY_FILE_CAPABILITIES
|
|
|
|
option is disabled), then
|
2008-07-09 12:11:50 +00:00
|
|
|
.B init
|
2019-12-30 09:57:50 +00:00
|
|
|
starts out with the
|
|
|
|
.B CAP_SETPCAP
|
|
|
|
capability removed from its per-process bounding
|
2008-07-09 12:11:50 +00:00
|
|
|
set, and that bounding set is inherited by all other processes
|
|
|
|
created on the system.
|
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bdflush.2, bind.2, brk.2, cacheflush.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, clone.2, close.2, connect.2, create_module.2, delete_module.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, flock.2, fork.2, fstatat.2, fsync.2, futex.2, futimesat.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getitimer.2, getpagesize.2, getpeername.2, getpid.2, getpriority.2, getresuid.2, getrlimit.2, getrusage.2, getsid.2, getsockname.2, getsockopt.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, getxattr.2, idle.2, init_module.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, intro.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl.2, ioctl_list.2, ioperm.2, iopl.2, ioprio_set.2, ipc.2, kcmp.2, kill.2, killpg.2, link.2, linkat.2, listen.2, listxattr.2, llseek.2, lookup_dcookie.2, lseek.2, madvise.2, migrate_pages.2, mincore.2, mkdir.2, mkdirat.2, mknod.2, mknodat.2, mlock.2, mmap.2, mmap2.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, mq_getsetattr.2, mremap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nfsservctl.2, nice.2, open.2, openat.2, outb.2, pause.2, pciconfig_read.2, perf_event_open.2, perfmonctl.2, personality.2, pipe.2, pivot_root.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, read.2, readahead.2, readdir.2, readlink.2, readlinkat.2, readv.2, reboot.2, recv.2, remap_file_pages.2, removexattr.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, semctl.2, semget.2, semop.2, send.2, sendfile.2, set_thread_area.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, setup.2, setxattr.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, sigaltstack.2, signal.2, signalfd.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, socket.2, socketcall.2, socketpair.2, splice.2, stat.2, statfs.2, stime.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, sysctl.2, sysfs.2, sysinfo.2, syslog.2, tee.2, time.2, timerfd_create.2, times.2, tkill.2, truncate.2, umask.2, umount.2, uname.2, unimplemented.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, MB_CUR_MAX.3, MB_LEN_MAX.3, __setfpucw.3, a64l.3, abort.3, abs.3, acos.3, acosh.3, addseverity.3, adjtime.3, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, alloca.3, argz_add.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, backtrace.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, btowc.3, btree.3, byteorder.3, bzero.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, catgets.3, catopen.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cerf.3, cexp.3, cexp2.3, cfree.3, cimag.3, clearenv.3, clock.3, clock_getcpuclockid.3, clog.3, clog10.3, clog2.3, closedir.3, cmsg.3, confstr.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, crypt.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctermid.3, ctime.3, daemon.3, dbopen.3, des_crypt.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, encrypt.3, end.3, endian.3, envz_add.3, erf.3, erfc.3, err.3, errno.3, error.3, ether_aton.3, euidaccess.3, exec.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fclose.3, fcloseall.3, fdim.3, fenv.3, ferror.3, fexecve.3, fflush.3, ffs.3, fgetgrent.3, fgetpwent.3, fgetwc.3, fgetws.3, finite.3, flockfile.3, floor.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmod.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fpurge.3, fputwc.3, fputws.3, fread.3, frexp.3, fseek.3, fseeko.3, ftime.3, ftok.3, fts.3, ftw.3, futimes.3, fwide.3, gamma.3, gcvt.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getipnodebyname.3, getline.3, getloadavg.3, getlogin.3, getmntent.3, getnameinfo.3, getnetent.3, getnetent_r.3, getopt.3, getpass.3, getprotoent.3, getprotoent_r.3, getpt.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getrpcent_r.3, getrpcport.3, gets.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, getumask.3, getusershell.3, getutent.3, getw.3, getwchar.3, glob.3, grantpt.3, gsignal.3, hash.3, hsearch.3, hypot.3, iconv.3, iconv_close.3, iconv_open.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, j0.3, key_setsecret.3, ldexp.3, lgamma.3, lio_listio.3, localeconv.3, lockf.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, longjmp.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, malloc.3, malloc_hook.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, mempcpy.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mpool.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, nan.3, netlink.3, nextafter.3, nl_langinfo.3, offsetof.3, on_exit.3, opendir.3, openpty.3, perror.3, popen.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, printf.3, profil.3, program_invocation_name.3, psignal.3, pthread_kill_other_threads_np.3, ptsname.3, putenv.3, putgrent.3, putpwent.3, puts.3, putwchar.3, qecvt.3, qsort.3, queue.3, raise.3, rand.3, random.3, random_r.3, rcmd.3, re_comp.3, readdir.3, realpath.3, recno.3, regex.3, remainder.3, remove.3, remquo.3, resolver.3, rewinddir.3, rexec.3, rint.3, round.3, rpc.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, scandirat.3, scanf.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, setnetgrent.3, shm_open.3, siginterrupt.3, signbit.3, significand.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sin.3, sincos.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdarg.3, stdin.3, stdio.3, stdio_ext.3, stpcpy.3, stpncpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfmon.3, strfry.3, strftime.3, string.3, strlen.3, strnlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, termios.3, tgamma.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, towctrans.3, towlower.3, towupper.3, trunc.3, tsearch.3, ttyname.3, ttyslot.3, tzset.3, ualarm.3, ulimit.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, updwtmp.3, usleep.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, xcrypt.3, xdr.3, y0.3, cciss.4, console.4, console_codes.4, console_ioctl.4, dsp56k.4, fd.4, full.4, hd.4, hpsa.4, initrd.4, intro.4, lp.4, mem.4, mouse.4, null.4, pts.4, ram.4, random.4, rtc.4, sk98lin.4, st.4, tty.4, ttyS.4, tty_ioctl.4, vcs.4, wavelan.4, acct.5, charmap.5, dir_colors.5, filesystems.5, ftpusers.5, group.5, host.conf.5, hosts.5, hosts.equiv.5, intro.5, issue.5, locale.5, motd.5, networks.5, nologin.5, nscd.conf.5, passwd.5, proc.5, protocols.5, resolv.conf.5, rpc.5, securetty.5, services.5, shells.5, termcap.5, ttytype.5, utmp.5, armscii-8.7, arp.7, ascii.7, bootparam.7, capabilities.7, charsets.7, complex.7, cp1251.7, credentials.7, ddp.7, environ.7, epoll.7, fifo.7, futex.7, glob.7, hier.7, icmp.7, inotify.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, locale.7, mailaddr.7, man.7, mq_overview.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, raw.7, regex.7, rtld-audit.7, rtnetlink.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, socket.7, standards.7, suffixes.7, svipc.7, tcp.7, termio.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, nscd.8, sync.8, tzselect.8, zdump.8, zic.8: Global fix: remove unneeded double quotes in .SH headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:01:36 +00:00
|
|
|
.SH SEE ALSO
|
2014-04-09 13:27:32 +00:00
|
|
|
.BR capsh (1),
|
2015-03-20 21:50:37 +00:00
|
|
|
.BR setpriv (1),
|
2005-10-28 17:41:30 +00:00
|
|
|
.BR prctl (2),
|
2006-05-02 00:36:39 +00:00
|
|
|
.BR setfsuid (2),
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR cap_clear (3),
|
2008-07-14 15:52:21 +00:00
|
|
|
.BR cap_copy_ext (3),
|
|
|
|
.BR cap_from_text (3),
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR cap_get_file (3),
|
|
|
|
.BR cap_get_proc (3),
|
|
|
|
.BR cap_init (3),
|
|
|
|
.BR capgetp (3),
|
|
|
|
.BR capsetp (3),
|
2012-03-02 18:41:13 +00:00
|
|
|
.BR libcap (3),
|
2016-09-20 14:57:11 +00:00
|
|
|
.BR proc (5),
|
2007-06-08 07:57:18 +00:00
|
|
|
.BR credentials (7),
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR pthreads (7),
|
2016-08-07 18:57:13 +00:00
|
|
|
.BR user_namespaces (7),
|
2017-09-25 11:04:30 +00:00
|
|
|
.BR captest (8), \" from libcap-ng
|
2017-05-08 08:38:12 +00:00
|
|
|
.BR filecap (8), \" from libcap-ng
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR getcap (8),
|
2020-06-10 06:00:46 +00:00
|
|
|
.BR getpcaps (8),
|
2017-05-08 08:38:12 +00:00
|
|
|
.BR netcap (8), \" from libcap-ng
|
|
|
|
.BR pscap (8), \" from libcap-ng
|
2008-07-09 12:11:50 +00:00
|
|
|
.BR setcap (8)
|
|
|
|
.PP
|
|
|
|
.I include/linux/capability.h
|
arch_prctl.2, fcntl.2, flock.2, get_robust_list.2, getpriority.2, ioprio_set.2, migrate_pages.2, mmap.2, mremap.2, msync.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, socket.2, subpage_prot.2, unshare.2, btree.3, dbopen.3, dl_iterate_phdr.3, dlopen.3, getnameinfo.3, hash.3, lockf.3, netlink.3, recno.3, rpc.3, xdr.3, cciss.4, console_ioctl.4, hpsa.4, initrd.4, msr.4, rtc.4, st.4, hosts.5, services.5, tzfile.5, aio.7, arp.7, capabilities.7, cpuset.7, feature_test_macros.7, futex.7, inotify.7, ip.7, ipv6.7, iso_8859-16.7, iso_8859-2.7, koi8-r.7, math_error.7, netlink.7, packet.7, pthreads.7, raw.7, spufs.7, udplite.7, uri.7, x25.7: Global fix: Various consistency fixes for SEE ALSO
Coauthored-by: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-09-24 07:53:22 +00:00
|
|
|
in the Linux kernel source tree
|