RIGHTS(4) | Device Drivers Manual | RIGHTS(4) |
Capability rights
—
Capsicum capability rights for file descriptors
When a file descriptor is created by a function such as accept(2), accept4(2), fhopen(2), kqueue(2), mq_open(2), open(2), openat(2), pdfork(2), pipe(2), shm_open(2), socket(2) or socketpair(2), it is assigned all capability rights. Those rights can be reduced (but never expanded) by using the cap_rights_limit(2), cap_fcntls_limit(2) and cap_ioctls_limit(2) system calls. Once capability rights are reduced, operations on the file descriptor will be limited to those permitted by rights.
The complete list of capability rights is provided below. The cap_rights_t type is used to store list of capability rights. The cap_rights_init(3) family of functions should be used to manage the structure.
The following rights may be specified in a rights mask:
CAP_ACCEPT
CAP_ACL_CHECK
CAP_ACL_DELETE
CAP_ACL_GET
CAP_ACL_SET
CAP_BIND
AT_FDCWD
in the fd
parameter. Note that sockets can also become bound implicitly as a result
of connect(2) or send(2), and that
socket options set with setsockopt(2) may also affect
binding behavior.CAP_BINDAT
CAP_LOOKUP
right.CAP_CHFLAGSAT
CAP_FCHFLAGS
and
CAP_LOOKUP
.CAP_CONNECT
AT_FDCWD
in the fd
parameter. This right is also required for sendto(2)
with a non-NULL destination address.CAP_CONNECTAT
CAP_LOOKUP
right.CAP_CREATE
O_CREAT
flag.CAP_EVENT
CAP_EXTATTR_DELETE
CAP_EXTATTR_GET
CAP_EXTATTR_LIST
CAP_EXTATTR_SET
CAP_FCHDIR
CAP_FCHFLAGS
CAP_LOOKUP
right is also present.CAP_FCHMOD
CAP_LOOKUP
right is also present.CAP_FCHMODAT
CAP_FCHMOD
and
CAP_LOOKUP
.CAP_FCHOWN
CAP_LOOKUP
right is also present.CAP_FCHOWNAT
CAP_FCHOWN
and
CAP_LOOKUP
.CAP_FCNTL
F_GETFL
, F_SETFL
,
F_GETOWN
and F_SETOWN
commands require this capability right. Also note that the list of
permitted commands can be further limited with the
cap_fcntls_limit(2) system call.CAP_FEXECVE
O_EXEC
flag; CAP_READ
is also required.CAP_FLOCK
F_GETLK
, F_SETLK
,
F_SETLKW
or F_SETLK_REMOTE
flag) and openat(2) (with
O_EXLOCK
or O_SHLOCK
flag).CAP_FPATHCONF
CAP_FSCK
CAP_FSTAT
CAP_LOOKUP
right is also present.CAP_FSTATAT
CAP_FSTAT
and
CAP_LOOKUP
.CAP_FSTATFS
CAP_FSYNC
O_FSYNC
or O_SYNC
flag.CAP_FTRUNCATE
O_TRUNC
flag.CAP_FUTIMES
CAP_LOOKUP
right is also present.CAP_FUTIMESAT
CAP_FUTIMES
and
CAP_LOOKUP
.CAP_GETPEERNAME
CAP_GETSOCKNAME
CAP_GETSOCKOPT
CAP_IOCTL
CAP_KQUEUE
CAP_KQUEUE_CHANGE
and
CAP_KQUEUE_EVENT
.CAP_KQUEUE_CHANGE
CAP_KQUEUE_EVENT
CAP_EVENT
is also required
on file descriptors that will be monitored using
kevent(2).CAP_LINKAT_SOURCE
CAP_LOOKUP
right.
Warning: CAP_LINKAT_SOURCE
makes it
possible to link files in a directory for which file descriptors exist
that have additional rights. For example, a file stored in a directory
that does not allow CAP_READ
may be linked in
another directory that does allow CAP_READ
,
thereby granting read access to a file that is otherwise unreadable.
CAP_LINKAT_TARGET
CAP_LOOKUP
right.CAP_LISTEN
CAP_BIND
.CAP_LOOKUP
CAP_MAC_GET
CAP_MAC_SET
CAP_MKDIRAT
CAP_LOOKUP
right.CAP_MKFIFOAT
CAP_LOOKUP
right.CAP_MKNODAT
CAP_LOOKUP
right.CAP_MMAP
PROT_NONE
protection.CAP_MMAP_R
PROT_READ
protection. This right includes the
CAP_READ
and CAP_SEEK
rights.CAP_MMAP_RW
CAP_MMAP_R
and
CAP_MMAP_W
.CAP_MMAP_RWX
CAP_MMAP_R
,
CAP_MMAP_W
and
CAP_MMAP_X
.CAP_MMAP_RX
CAP_MMAP_R
and
CAP_MMAP_X
.CAP_MMAP_W
PROT_WRITE
protection. This right includes the
CAP_WRITE
and CAP_SEEK
rights.CAP_MMAP_WX
CAP_MMAP_W
and
CAP_MMAP_X
.CAP_MMAP_X
PROT_EXEC
protection. This right includes the
CAP_SEEK
right.CAP_PDGETPID
CAP_PDKILL
CAP_PDWAIT
CAP_PEELOFF
CAP_PREAD
CAP_READ
and
CAP_SEEK
.CAP_PWRITE
CAP_SEEK
and
CAP_WRITE
.CAP_READ
CAP_SEEK
is
also required), openat(2) with the
O_RDONLY flag,
read(2),
readv(2), recv(2),
recvfrom(2), recvmsg(2),
pread(2) (CAP_SEEK
is also
required), preadv(2) (CAP_SEEK
is also required) and related system calls.CAP_RECV
CAP_READ
.CAP_RENAMEAT_SOURCE
CAP_LOOKUP
right.
Warning: CAP_RENAMEAT_SOURCE
makes it
possible to move files to a directory for which file descriptors exist
that have additional rights. For example, a file stored in a directory
that does not allow CAP_READ
may be moved to
another directory that does allow CAP_READ
,
thereby granting read access to a file that is otherwise unreadable.
CAP_RENAMEAT_TARGET
CAP_LOOKUP
right.CAP_SEEK
CAP_SEM_GETVALUE
CAP_SEM_POST
CAP_SEM_WAIT
CAP_SEND
CAP_WRITE
.CAP_SETSOCKOPT
CAP_SHUTDOWN
CAP_SYMLINKAT
CAP_LOOKUP
right.CAP_TTYHOOK
CAP_UNLINKAT
CAP_LOOKUP
right.CAP_WRITE
O_WRONLY
and O_APPEND
flags set, send(2), sendmsg(2),
sendto(2), write(2),
writev(2), pwrite(2),
pwritev(2) and related system calls. For
sendto(2) with a non-NULL connection address,
CAP_CONNECT
is also required. For
openat(2) with the O_WRONLY
flag, but without the O_APPEND
flag,
CAP_SEEK
is also required. For
aio_write(2), pwrite(2) and
pwritev(2) CAP_SEEK
is also
required.accept(2), accept4(2), aio_fsync(2), aio_read(2), aio_write(2), bind(2), bindat(2), cap_enter(2), cap_fcntls_limit(2), cap_ioctls_limit(2), cap_rights_limit(2), chflagsat(2), connect(2), connectat(2), extattr_delete_fd(2), extattr_get_fd(2), extattr_list_fd(2), extattr_set_fd(2), fchflags(2), fchmod(2), fchmodat(2), fchown(2), fchownat(2), fcntl(2), fexecve(2), fhopen(2), flock(2), fpathconf(2), fstat(2), fstatat(2), fstatfs(2), fsync(2), ftruncate(2), futimes(2), getpeername(2), getsockname(2), getsockopt(2), ioctl(2), kevent(2), kqueue(2), linkat(2), listen(2), mmap(2), mq_open(2), open(2), openat(2), pdfork(2), pdgetpid(2), pdkill(2), pdwait4(2), pipe(2), poll(2), pread(2), preadv(2), pwrite(2), pwritev(2), read(2), readv(2), recv(2), recvfrom(2), recvmsg(2), renameat(2), sctp_peeloff(2), select(2), send(2), sendmsg(2), sendto(2), setsockopt(2), shm_open(2), shutdown(2), socket(2), socketpair(2), symlinkat(2), unlinkat(2), write(2), writev(2), acl_delete_fd_np(3), acl_get_fd(3), acl_get_fd_np(3), acl_set_fd(3), acl_set_fd_np(3), acl_valid_fd_np(3), mac_get_fd(3), mac_set_fd(3), sem_getvalue(3), sem_post(3), sem_trywait(3), sem_wait(3), capsicum(4), snp(4)
Support for capabilities and capabilities mode was developed as part of the TrustedBSD Project.
This manual page was created by Pawel Jakub Dawidek <pawel@dawidek.net> under sponsorship from the FreeBSD Foundation based on the cap_new(2) manual page by Robert Watson <rwatson@FreeBSD.org>.
April 30, 2018 | Debian |