2011-03-01 13:28:27 +00:00
|
|
|
##
|
|
|
|
## Copyright (c) 2008-2010 Robert N. M. Watson
|
|
|
|
## All rights reserved.
|
|
|
|
##
|
|
|
|
## This software was developed at the University of Cambridge Computer
|
|
|
|
## Laboratory with support from a grant from Google, Inc.
|
|
|
|
##
|
|
|
|
## Redistribution and use in source and binary forms, with or without
|
|
|
|
## modification, are permitted provided that the following conditions
|
|
|
|
## are met:
|
|
|
|
## 1. Redistributions of source code must retain the above copyright
|
|
|
|
## notice, this list of conditions and the following disclaimer.
|
|
|
|
## 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
## notice, this list of conditions and the following disclaimer in the
|
|
|
|
## documentation and/or other materials provided with the distribution.
|
|
|
|
##
|
|
|
|
## THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
## SUCH DAMAGE.
|
|
|
|
##
|
|
|
|
## List of system calls enabled in capability mode, one name per line.
|
|
|
|
##
|
|
|
|
## Notes:
|
|
|
|
## - sys_exit(2), abort2(2) and close(2) are very important.
|
|
|
|
## - Sorted alphabetically, please keep it that way.
|
|
|
|
##
|
|
|
|
## $FreeBSD$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow ACL and MAC label operations by file descriptor, subject to
|
|
|
|
## capability rights. Allow MAC label operations on the current process but
|
|
|
|
## we will need to scope __mac_get_pid(2).
|
|
|
|
##
|
|
|
|
__acl_aclcheck_fd
|
|
|
|
__acl_delete_fd
|
|
|
|
__acl_get_fd
|
|
|
|
__acl_set_fd
|
|
|
|
__mac_get_fd
|
|
|
|
#__mac_get_pid
|
|
|
|
__mac_get_proc
|
|
|
|
__mac_set_fd
|
|
|
|
__mac_set_proc
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow sysctl(2) as we scope internal to the call; this is a global
|
|
|
|
## namespace, but there are several critical sysctls required for almost
|
|
|
|
## anything to run, such as hw.pagesize. For now that policy lives in the
|
|
|
|
## kernel for performance and simplicity, but perhaps it could move to a
|
|
|
|
## proxying daemon in userspace.
|
|
|
|
##
|
|
|
|
__sysctl
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow umtx operations as these are scoped by address space.
|
|
|
|
##
|
|
|
|
## XXRW: Need to check this very carefully.
|
|
|
|
##
|
|
|
|
_umtx_op
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow process termination using abort2(2).
|
|
|
|
##
|
|
|
|
abort2
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow accept(2) since it doesn't manipulate namespaces directly, rather
|
|
|
|
## relies on existing bindings on a socket, subject to capability rights.
|
|
|
|
##
|
|
|
|
accept
|
2013-05-01 20:10:21 +00:00
|
|
|
accept4
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow AIO operations by file descriptor, subject to capability rights.
|
|
|
|
##
|
|
|
|
aio_cancel
|
|
|
|
aio_error
|
|
|
|
aio_fsync
|
|
|
|
aio_read
|
|
|
|
aio_return
|
|
|
|
aio_suspend
|
|
|
|
aio_waitcomplete
|
|
|
|
aio_write
|
|
|
|
|
|
|
|
##
|
|
|
|
## audit(2) is a global operation, submitting to the global trail, but it is
|
|
|
|
## controlled by privilege, and it might be useful to be able to submit
|
|
|
|
## records from sandboxes. For now, disallow, but we may want to think about
|
|
|
|
## providing some sort of proxy service for this.
|
|
|
|
##
|
|
|
|
#audit
|
|
|
|
|
|
|
|
##
|
2013-03-02 21:11:30 +00:00
|
|
|
## Allow bindat(2).
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
2013-03-02 21:11:30 +00:00
|
|
|
bindat
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow capability mode and capability system calls.
|
|
|
|
##
|
|
|
|
cap_enter
|
Merge Capsicum overhaul:
- Capability is no longer separate descriptor type. Now every descriptor
has set of its own capability rights.
- The cap_new(2) system call is left, but it is no longer documented and
should not be used in new code.
- The new syscall cap_rights_limit(2) should be used instead of
cap_new(2), which limits capability rights of the given descriptor
without creating a new one.
- The cap_getrights(2) syscall is renamed to cap_rights_get(2).
- If CAP_IOCTL capability right is present we can further reduce allowed
ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed
ioctls can be retrived with cap_ioctls_get(2) syscall.
- If CAP_FCNTL capability right is present we can further reduce fcntls
that can be used with the new cap_fcntls_limit(2) syscall and retrive
them with cap_fcntls_get(2).
- To support ioctl and fcntl white-listing the filedesc structure was
heavly modified.
- The audit subsystem, kdump and procstat tools were updated to
recognize new syscalls.
- Capability rights were revised and eventhough I tried hard to provide
backward API and ABI compatibility there are some incompatible changes
that are described in detail below:
CAP_CREATE old behaviour:
- Allow for openat(2)+O_CREAT.
- Allow for linkat(2).
- Allow for symlinkat(2).
CAP_CREATE new behaviour:
- Allow for openat(2)+O_CREAT.
Added CAP_LINKAT:
- Allow for linkat(2). ABI: Reuses CAP_RMDIR bit.
- Allow to be target for renameat(2).
Added CAP_SYMLINKAT:
- Allow for symlinkat(2).
Removed CAP_DELETE. Old behaviour:
- Allow for unlinkat(2) when removing non-directory object.
- Allow to be source for renameat(2).
Removed CAP_RMDIR. Old behaviour:
- Allow for unlinkat(2) when removing directory.
Added CAP_RENAMEAT:
- Required for source directory for the renameat(2) syscall.
Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR):
- Allow for unlinkat(2) on any object.
- Required if target of renameat(2) exists and will be removed by this
call.
Removed CAP_MAPEXEC.
CAP_MMAP old behaviour:
- Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and
PROT_WRITE.
CAP_MMAP new behaviour:
- Allow for mmap(2)+PROT_NONE.
Added CAP_MMAP_R:
- Allow for mmap(PROT_READ).
Added CAP_MMAP_W:
- Allow for mmap(PROT_WRITE).
Added CAP_MMAP_X:
- Allow for mmap(PROT_EXEC).
Added CAP_MMAP_RW:
- Allow for mmap(PROT_READ | PROT_WRITE).
Added CAP_MMAP_RX:
- Allow for mmap(PROT_READ | PROT_EXEC).
Added CAP_MMAP_WX:
- Allow for mmap(PROT_WRITE | PROT_EXEC).
Added CAP_MMAP_RWX:
- Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC).
Renamed CAP_MKDIR to CAP_MKDIRAT.
Renamed CAP_MKFIFO to CAP_MKFIFOAT.
Renamed CAP_MKNODE to CAP_MKNODEAT.
CAP_READ old behaviour:
- Allow pread(2).
- Disallow read(2), readv(2) (if there is no CAP_SEEK).
CAP_READ new behaviour:
- Allow read(2), readv(2).
- Disallow pread(2) (CAP_SEEK was also required).
CAP_WRITE old behaviour:
- Allow pwrite(2).
- Disallow write(2), writev(2) (if there is no CAP_SEEK).
CAP_WRITE new behaviour:
- Allow write(2), writev(2).
- Disallow pwrite(2) (CAP_SEEK was also required).
Added convinient defines:
#define CAP_PREAD (CAP_SEEK | CAP_READ)
#define CAP_PWRITE (CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ)
#define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL)
#define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W)
#define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X)
#define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X)
#define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X)
#define CAP_RECV CAP_READ
#define CAP_SEND CAP_WRITE
#define CAP_SOCK_CLIENT \
(CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
#define CAP_SOCK_SERVER \
(CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \
CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \
CAP_SETSOCKOPT | CAP_SHUTDOWN)
Added defines for backward API compatibility:
#define CAP_MAPEXEC CAP_MMAP_X
#define CAP_DELETE CAP_UNLINKAT
#define CAP_MKDIR CAP_MKDIRAT
#define CAP_RMDIR CAP_UNLINKAT
#define CAP_MKFIFO CAP_MKFIFOAT
#define CAP_MKNOD CAP_MKNODAT
#define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER)
Sponsored by: The FreeBSD Foundation
Reviewed by: Christoph Mallon <christoph.mallon@gmx.de>
Many aspects discussed with: rwatson, benl, jonathan
ABI compatibility discussed with: kib
2013-03-02 00:53:12 +00:00
|
|
|
cap_fcntls_get
|
|
|
|
cap_fcntls_limit
|
2011-03-01 13:28:27 +00:00
|
|
|
cap_getmode
|
Merge Capsicum overhaul:
- Capability is no longer separate descriptor type. Now every descriptor
has set of its own capability rights.
- The cap_new(2) system call is left, but it is no longer documented and
should not be used in new code.
- The new syscall cap_rights_limit(2) should be used instead of
cap_new(2), which limits capability rights of the given descriptor
without creating a new one.
- The cap_getrights(2) syscall is renamed to cap_rights_get(2).
- If CAP_IOCTL capability right is present we can further reduce allowed
ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed
ioctls can be retrived with cap_ioctls_get(2) syscall.
- If CAP_FCNTL capability right is present we can further reduce fcntls
that can be used with the new cap_fcntls_limit(2) syscall and retrive
them with cap_fcntls_get(2).
- To support ioctl and fcntl white-listing the filedesc structure was
heavly modified.
- The audit subsystem, kdump and procstat tools were updated to
recognize new syscalls.
- Capability rights were revised and eventhough I tried hard to provide
backward API and ABI compatibility there are some incompatible changes
that are described in detail below:
CAP_CREATE old behaviour:
- Allow for openat(2)+O_CREAT.
- Allow for linkat(2).
- Allow for symlinkat(2).
CAP_CREATE new behaviour:
- Allow for openat(2)+O_CREAT.
Added CAP_LINKAT:
- Allow for linkat(2). ABI: Reuses CAP_RMDIR bit.
- Allow to be target for renameat(2).
Added CAP_SYMLINKAT:
- Allow for symlinkat(2).
Removed CAP_DELETE. Old behaviour:
- Allow for unlinkat(2) when removing non-directory object.
- Allow to be source for renameat(2).
Removed CAP_RMDIR. Old behaviour:
- Allow for unlinkat(2) when removing directory.
Added CAP_RENAMEAT:
- Required for source directory for the renameat(2) syscall.
Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR):
- Allow for unlinkat(2) on any object.
- Required if target of renameat(2) exists and will be removed by this
call.
Removed CAP_MAPEXEC.
CAP_MMAP old behaviour:
- Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and
PROT_WRITE.
CAP_MMAP new behaviour:
- Allow for mmap(2)+PROT_NONE.
Added CAP_MMAP_R:
- Allow for mmap(PROT_READ).
Added CAP_MMAP_W:
- Allow for mmap(PROT_WRITE).
Added CAP_MMAP_X:
- Allow for mmap(PROT_EXEC).
Added CAP_MMAP_RW:
- Allow for mmap(PROT_READ | PROT_WRITE).
Added CAP_MMAP_RX:
- Allow for mmap(PROT_READ | PROT_EXEC).
Added CAP_MMAP_WX:
- Allow for mmap(PROT_WRITE | PROT_EXEC).
Added CAP_MMAP_RWX:
- Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC).
Renamed CAP_MKDIR to CAP_MKDIRAT.
Renamed CAP_MKFIFO to CAP_MKFIFOAT.
Renamed CAP_MKNODE to CAP_MKNODEAT.
CAP_READ old behaviour:
- Allow pread(2).
- Disallow read(2), readv(2) (if there is no CAP_SEEK).
CAP_READ new behaviour:
- Allow read(2), readv(2).
- Disallow pread(2) (CAP_SEEK was also required).
CAP_WRITE old behaviour:
- Allow pwrite(2).
- Disallow write(2), writev(2) (if there is no CAP_SEEK).
CAP_WRITE new behaviour:
- Allow write(2), writev(2).
- Disallow pwrite(2) (CAP_SEEK was also required).
Added convinient defines:
#define CAP_PREAD (CAP_SEEK | CAP_READ)
#define CAP_PWRITE (CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ)
#define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL)
#define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W)
#define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X)
#define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X)
#define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X)
#define CAP_RECV CAP_READ
#define CAP_SEND CAP_WRITE
#define CAP_SOCK_CLIENT \
(CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
#define CAP_SOCK_SERVER \
(CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \
CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \
CAP_SETSOCKOPT | CAP_SHUTDOWN)
Added defines for backward API compatibility:
#define CAP_MAPEXEC CAP_MMAP_X
#define CAP_DELETE CAP_UNLINKAT
#define CAP_MKDIR CAP_MKDIRAT
#define CAP_RMDIR CAP_UNLINKAT
#define CAP_MKFIFO CAP_MKFIFOAT
#define CAP_MKNOD CAP_MKNODAT
#define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER)
Sponsored by: The FreeBSD Foundation
Reviewed by: Christoph Mallon <christoph.mallon@gmx.de>
Many aspects discussed with: rwatson, benl, jonathan
ABI compatibility discussed with: kib
2013-03-02 00:53:12 +00:00
|
|
|
cap_ioctls_get
|
|
|
|
cap_ioctls_limit
|
Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.
The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.
The structure definition looks like this:
struct cap_rights {
uint64_t cr_rights[CAP_RIGHTS_VERSION + 2];
};
The initial CAP_RIGHTS_VERSION is 0.
The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.
The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.
To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.
#define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL)
We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:
#define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL)
#define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL)
#define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP)
There is new API to manage the new cap_rights_t structure:
cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
void cap_rights_set(cap_rights_t *rights, ...);
void cap_rights_clear(cap_rights_t *rights, ...);
bool cap_rights_is_set(const cap_rights_t *rights, ...);
bool cap_rights_is_valid(const cap_rights_t *rights);
void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);
Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:
cap_rights_t rights;
cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);
There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:
#define cap_rights_set(rights, ...) \
__cap_rights_set((rights), __VA_ARGS__, 0ULL)
void __cap_rights_set(cap_rights_t *rights, ...);
Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:
cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);
Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.
This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.
Sponsored by: The FreeBSD Foundation
2013-09-05 00:09:56 +00:00
|
|
|
__cap_rights_get
|
Merge Capsicum overhaul:
- Capability is no longer separate descriptor type. Now every descriptor
has set of its own capability rights.
- The cap_new(2) system call is left, but it is no longer documented and
should not be used in new code.
- The new syscall cap_rights_limit(2) should be used instead of
cap_new(2), which limits capability rights of the given descriptor
without creating a new one.
- The cap_getrights(2) syscall is renamed to cap_rights_get(2).
- If CAP_IOCTL capability right is present we can further reduce allowed
ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed
ioctls can be retrived with cap_ioctls_get(2) syscall.
- If CAP_FCNTL capability right is present we can further reduce fcntls
that can be used with the new cap_fcntls_limit(2) syscall and retrive
them with cap_fcntls_get(2).
- To support ioctl and fcntl white-listing the filedesc structure was
heavly modified.
- The audit subsystem, kdump and procstat tools were updated to
recognize new syscalls.
- Capability rights were revised and eventhough I tried hard to provide
backward API and ABI compatibility there are some incompatible changes
that are described in detail below:
CAP_CREATE old behaviour:
- Allow for openat(2)+O_CREAT.
- Allow for linkat(2).
- Allow for symlinkat(2).
CAP_CREATE new behaviour:
- Allow for openat(2)+O_CREAT.
Added CAP_LINKAT:
- Allow for linkat(2). ABI: Reuses CAP_RMDIR bit.
- Allow to be target for renameat(2).
Added CAP_SYMLINKAT:
- Allow for symlinkat(2).
Removed CAP_DELETE. Old behaviour:
- Allow for unlinkat(2) when removing non-directory object.
- Allow to be source for renameat(2).
Removed CAP_RMDIR. Old behaviour:
- Allow for unlinkat(2) when removing directory.
Added CAP_RENAMEAT:
- Required for source directory for the renameat(2) syscall.
Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR):
- Allow for unlinkat(2) on any object.
- Required if target of renameat(2) exists and will be removed by this
call.
Removed CAP_MAPEXEC.
CAP_MMAP old behaviour:
- Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and
PROT_WRITE.
CAP_MMAP new behaviour:
- Allow for mmap(2)+PROT_NONE.
Added CAP_MMAP_R:
- Allow for mmap(PROT_READ).
Added CAP_MMAP_W:
- Allow for mmap(PROT_WRITE).
Added CAP_MMAP_X:
- Allow for mmap(PROT_EXEC).
Added CAP_MMAP_RW:
- Allow for mmap(PROT_READ | PROT_WRITE).
Added CAP_MMAP_RX:
- Allow for mmap(PROT_READ | PROT_EXEC).
Added CAP_MMAP_WX:
- Allow for mmap(PROT_WRITE | PROT_EXEC).
Added CAP_MMAP_RWX:
- Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC).
Renamed CAP_MKDIR to CAP_MKDIRAT.
Renamed CAP_MKFIFO to CAP_MKFIFOAT.
Renamed CAP_MKNODE to CAP_MKNODEAT.
CAP_READ old behaviour:
- Allow pread(2).
- Disallow read(2), readv(2) (if there is no CAP_SEEK).
CAP_READ new behaviour:
- Allow read(2), readv(2).
- Disallow pread(2) (CAP_SEEK was also required).
CAP_WRITE old behaviour:
- Allow pwrite(2).
- Disallow write(2), writev(2) (if there is no CAP_SEEK).
CAP_WRITE new behaviour:
- Allow write(2), writev(2).
- Disallow pwrite(2) (CAP_SEEK was also required).
Added convinient defines:
#define CAP_PREAD (CAP_SEEK | CAP_READ)
#define CAP_PWRITE (CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ)
#define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL)
#define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W)
#define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X)
#define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X)
#define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X)
#define CAP_RECV CAP_READ
#define CAP_SEND CAP_WRITE
#define CAP_SOCK_CLIENT \
(CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
#define CAP_SOCK_SERVER \
(CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \
CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \
CAP_SETSOCKOPT | CAP_SHUTDOWN)
Added defines for backward API compatibility:
#define CAP_MAPEXEC CAP_MMAP_X
#define CAP_DELETE CAP_UNLINKAT
#define CAP_MKDIR CAP_MKDIRAT
#define CAP_RMDIR CAP_UNLINKAT
#define CAP_MKFIFO CAP_MKFIFOAT
#define CAP_MKNOD CAP_MKNODAT
#define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER)
Sponsored by: The FreeBSD Foundation
Reviewed by: Christoph Mallon <christoph.mallon@gmx.de>
Many aspects discussed with: rwatson, benl, jonathan
ABI compatibility discussed with: kib
2013-03-02 00:53:12 +00:00
|
|
|
cap_rights_limit
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow read-only clock operations.
|
|
|
|
##
|
|
|
|
clock_getres
|
2013-09-07 19:16:02 +00:00
|
|
|
clock_gettime
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Always allow file descriptor close(2).
|
|
|
|
##
|
|
|
|
close
|
|
|
|
closefrom
|
|
|
|
|
|
|
|
##
|
2013-03-02 21:11:30 +00:00
|
|
|
## Allow connectat(2).
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
2013-03-02 21:11:30 +00:00
|
|
|
connectat
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## cpuset(2) and related calls require scoping by process, but should
|
|
|
|
## eventually be allowed, at least in the current process case.
|
|
|
|
##
|
|
|
|
#cpuset
|
|
|
|
#cpuset_getaffinity
|
|
|
|
#cpuset_getid
|
|
|
|
#cpuset_setaffinity
|
|
|
|
#cpuset_setid
|
|
|
|
|
|
|
|
##
|
|
|
|
## Always allow dup(2) and dup2(2) manipulation of the file descriptor table.
|
|
|
|
##
|
|
|
|
dup
|
|
|
|
dup2
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow extended attribute operations by file descriptor, subject to
|
|
|
|
## capability rights.
|
|
|
|
##
|
|
|
|
extattr_delete_fd
|
|
|
|
extattr_get_fd
|
|
|
|
extattr_list_fd
|
|
|
|
extattr_set_fd
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow changing file flags, mode, and owner by file descriptor, subject to
|
|
|
|
## capability rights.
|
|
|
|
##
|
|
|
|
fchflags
|
|
|
|
fchmod
|
|
|
|
fchown
|
|
|
|
|
|
|
|
##
|
|
|
|
## For now, allow fcntl(2), subject to capability rights, but this probably
|
|
|
|
## needs additional scoping.
|
|
|
|
##
|
|
|
|
fcntl
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow fexecve(2), subject to capability rights. We perform some scoping,
|
|
|
|
## such as disallowing privilege escalation.
|
|
|
|
##
|
|
|
|
fexecve
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow flock(2), subject to capability rights.
|
|
|
|
##
|
|
|
|
flock
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow fork(2), even though it returns pids -- some applications seem to
|
|
|
|
## prefer this interface.
|
|
|
|
##
|
|
|
|
fork
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow fpathconf(2), subject to capability rights.
|
|
|
|
##
|
|
|
|
fpathconf
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow various file descriptor-based I/O operations, subject to capability
|
2011-08-13 17:22:16 +00:00
|
|
|
## rights.
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
|
|
|
freebsd6_ftruncate
|
|
|
|
freebsd6_lseek
|
|
|
|
freebsd6_mmap
|
|
|
|
freebsd6_pread
|
|
|
|
freebsd6_pwrite
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying file and file system state with fstat(2) and fstatfs(2),
|
|
|
|
## subject to capability rights.
|
|
|
|
##
|
|
|
|
fstat
|
|
|
|
fstatfs
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow further file descriptor-based I/O operations, subject to capability
|
|
|
|
## rights.
|
|
|
|
##
|
|
|
|
fsync
|
|
|
|
ftruncate
|
|
|
|
|
|
|
|
##
|
2015-01-23 21:07:08 +00:00
|
|
|
## Allow futimens(2) and futimes(2), subject to capability rights.
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
2015-01-23 21:07:08 +00:00
|
|
|
futimens
|
2011-03-01 13:28:27 +00:00
|
|
|
futimes
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying process audit state, subject to normal access control.
|
|
|
|
##
|
|
|
|
getaudit
|
|
|
|
getaudit_addr
|
|
|
|
getauid
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow thread context management with getcontext(2).
|
|
|
|
##
|
|
|
|
getcontext
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow directory I/O on a file descriptor, subject to capability rights.
|
|
|
|
## Originally we had separate capabilities for directory-specific read
|
|
|
|
## operations, but on BSD we allow reading the raw directory data, so we just
|
Merge Capsicum overhaul:
- Capability is no longer separate descriptor type. Now every descriptor
has set of its own capability rights.
- The cap_new(2) system call is left, but it is no longer documented and
should not be used in new code.
- The new syscall cap_rights_limit(2) should be used instead of
cap_new(2), which limits capability rights of the given descriptor
without creating a new one.
- The cap_getrights(2) syscall is renamed to cap_rights_get(2).
- If CAP_IOCTL capability right is present we can further reduce allowed
ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed
ioctls can be retrived with cap_ioctls_get(2) syscall.
- If CAP_FCNTL capability right is present we can further reduce fcntls
that can be used with the new cap_fcntls_limit(2) syscall and retrive
them with cap_fcntls_get(2).
- To support ioctl and fcntl white-listing the filedesc structure was
heavly modified.
- The audit subsystem, kdump and procstat tools were updated to
recognize new syscalls.
- Capability rights were revised and eventhough I tried hard to provide
backward API and ABI compatibility there are some incompatible changes
that are described in detail below:
CAP_CREATE old behaviour:
- Allow for openat(2)+O_CREAT.
- Allow for linkat(2).
- Allow for symlinkat(2).
CAP_CREATE new behaviour:
- Allow for openat(2)+O_CREAT.
Added CAP_LINKAT:
- Allow for linkat(2). ABI: Reuses CAP_RMDIR bit.
- Allow to be target for renameat(2).
Added CAP_SYMLINKAT:
- Allow for symlinkat(2).
Removed CAP_DELETE. Old behaviour:
- Allow for unlinkat(2) when removing non-directory object.
- Allow to be source for renameat(2).
Removed CAP_RMDIR. Old behaviour:
- Allow for unlinkat(2) when removing directory.
Added CAP_RENAMEAT:
- Required for source directory for the renameat(2) syscall.
Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR):
- Allow for unlinkat(2) on any object.
- Required if target of renameat(2) exists and will be removed by this
call.
Removed CAP_MAPEXEC.
CAP_MMAP old behaviour:
- Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and
PROT_WRITE.
CAP_MMAP new behaviour:
- Allow for mmap(2)+PROT_NONE.
Added CAP_MMAP_R:
- Allow for mmap(PROT_READ).
Added CAP_MMAP_W:
- Allow for mmap(PROT_WRITE).
Added CAP_MMAP_X:
- Allow for mmap(PROT_EXEC).
Added CAP_MMAP_RW:
- Allow for mmap(PROT_READ | PROT_WRITE).
Added CAP_MMAP_RX:
- Allow for mmap(PROT_READ | PROT_EXEC).
Added CAP_MMAP_WX:
- Allow for mmap(PROT_WRITE | PROT_EXEC).
Added CAP_MMAP_RWX:
- Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC).
Renamed CAP_MKDIR to CAP_MKDIRAT.
Renamed CAP_MKFIFO to CAP_MKFIFOAT.
Renamed CAP_MKNODE to CAP_MKNODEAT.
CAP_READ old behaviour:
- Allow pread(2).
- Disallow read(2), readv(2) (if there is no CAP_SEEK).
CAP_READ new behaviour:
- Allow read(2), readv(2).
- Disallow pread(2) (CAP_SEEK was also required).
CAP_WRITE old behaviour:
- Allow pwrite(2).
- Disallow write(2), writev(2) (if there is no CAP_SEEK).
CAP_WRITE new behaviour:
- Allow write(2), writev(2).
- Disallow pwrite(2) (CAP_SEEK was also required).
Added convinient defines:
#define CAP_PREAD (CAP_SEEK | CAP_READ)
#define CAP_PWRITE (CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ)
#define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL)
#define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W)
#define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X)
#define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X)
#define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X)
#define CAP_RECV CAP_READ
#define CAP_SEND CAP_WRITE
#define CAP_SOCK_CLIENT \
(CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
#define CAP_SOCK_SERVER \
(CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \
CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \
CAP_SETSOCKOPT | CAP_SHUTDOWN)
Added defines for backward API compatibility:
#define CAP_MAPEXEC CAP_MMAP_X
#define CAP_DELETE CAP_UNLINKAT
#define CAP_MKDIR CAP_MKDIRAT
#define CAP_RMDIR CAP_UNLINKAT
#define CAP_MKFIFO CAP_MKFIFOAT
#define CAP_MKNOD CAP_MKNODAT
#define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER)
Sponsored by: The FreeBSD Foundation
Reviewed by: Christoph Mallon <christoph.mallon@gmx.de>
Many aspects discussed with: rwatson, benl, jonathan
ABI compatibility discussed with: kib
2013-03-02 00:53:12 +00:00
|
|
|
## rely on CAP_READ now.
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
|
|
|
getdents
|
|
|
|
getdirentries
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying certain trivial global state.
|
|
|
|
##
|
|
|
|
getdomainname
|
2016-09-08 14:04:04 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying certain per-process resource limit state.
|
|
|
|
##
|
2016-08-31 18:33:15 +00:00
|
|
|
getdtablesize
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying current process credential state.
|
|
|
|
##
|
|
|
|
getegid
|
|
|
|
geteuid
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying certain trivial global state.
|
|
|
|
##
|
|
|
|
gethostid
|
|
|
|
gethostname
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying per-process timer.
|
|
|
|
##
|
|
|
|
getitimer
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying current process credential state.
|
|
|
|
##
|
|
|
|
getgid
|
|
|
|
getgroups
|
|
|
|
getlogin
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying certain trivial global state.
|
|
|
|
##
|
|
|
|
getpagesize
|
|
|
|
getpeername
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying certain per-process scheduling, resource limit, and
|
|
|
|
## credential state.
|
|
|
|
##
|
|
|
|
## XXXRW: getpgid(2) needs scoping. It's not clear if it's worth scoping
|
|
|
|
## getppid(2). getpriority(2) needs scoping. getrusage(2) needs scoping.
|
|
|
|
## getsid(2) needs scoping.
|
|
|
|
##
|
|
|
|
getpgid
|
|
|
|
getpgrp
|
|
|
|
getpid
|
|
|
|
getppid
|
|
|
|
getpriority
|
|
|
|
getresgid
|
|
|
|
getresuid
|
|
|
|
getrlimit
|
|
|
|
getrusage
|
|
|
|
getsid
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying socket state, subject to capability rights.
|
|
|
|
##
|
|
|
|
## XXXRW: getsockopt(2) may need more attention.
|
|
|
|
##
|
|
|
|
getsockname
|
|
|
|
getsockopt
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying the global clock.
|
|
|
|
##
|
|
|
|
gettimeofday
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying current process credential state.
|
|
|
|
##
|
|
|
|
getuid
|
|
|
|
|
|
|
|
##
|
Merge Capsicum overhaul:
- Capability is no longer separate descriptor type. Now every descriptor
has set of its own capability rights.
- The cap_new(2) system call is left, but it is no longer documented and
should not be used in new code.
- The new syscall cap_rights_limit(2) should be used instead of
cap_new(2), which limits capability rights of the given descriptor
without creating a new one.
- The cap_getrights(2) syscall is renamed to cap_rights_get(2).
- If CAP_IOCTL capability right is present we can further reduce allowed
ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed
ioctls can be retrived with cap_ioctls_get(2) syscall.
- If CAP_FCNTL capability right is present we can further reduce fcntls
that can be used with the new cap_fcntls_limit(2) syscall and retrive
them with cap_fcntls_get(2).
- To support ioctl and fcntl white-listing the filedesc structure was
heavly modified.
- The audit subsystem, kdump and procstat tools were updated to
recognize new syscalls.
- Capability rights were revised and eventhough I tried hard to provide
backward API and ABI compatibility there are some incompatible changes
that are described in detail below:
CAP_CREATE old behaviour:
- Allow for openat(2)+O_CREAT.
- Allow for linkat(2).
- Allow for symlinkat(2).
CAP_CREATE new behaviour:
- Allow for openat(2)+O_CREAT.
Added CAP_LINKAT:
- Allow for linkat(2). ABI: Reuses CAP_RMDIR bit.
- Allow to be target for renameat(2).
Added CAP_SYMLINKAT:
- Allow for symlinkat(2).
Removed CAP_DELETE. Old behaviour:
- Allow for unlinkat(2) when removing non-directory object.
- Allow to be source for renameat(2).
Removed CAP_RMDIR. Old behaviour:
- Allow for unlinkat(2) when removing directory.
Added CAP_RENAMEAT:
- Required for source directory for the renameat(2) syscall.
Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR):
- Allow for unlinkat(2) on any object.
- Required if target of renameat(2) exists and will be removed by this
call.
Removed CAP_MAPEXEC.
CAP_MMAP old behaviour:
- Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and
PROT_WRITE.
CAP_MMAP new behaviour:
- Allow for mmap(2)+PROT_NONE.
Added CAP_MMAP_R:
- Allow for mmap(PROT_READ).
Added CAP_MMAP_W:
- Allow for mmap(PROT_WRITE).
Added CAP_MMAP_X:
- Allow for mmap(PROT_EXEC).
Added CAP_MMAP_RW:
- Allow for mmap(PROT_READ | PROT_WRITE).
Added CAP_MMAP_RX:
- Allow for mmap(PROT_READ | PROT_EXEC).
Added CAP_MMAP_WX:
- Allow for mmap(PROT_WRITE | PROT_EXEC).
Added CAP_MMAP_RWX:
- Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC).
Renamed CAP_MKDIR to CAP_MKDIRAT.
Renamed CAP_MKFIFO to CAP_MKFIFOAT.
Renamed CAP_MKNODE to CAP_MKNODEAT.
CAP_READ old behaviour:
- Allow pread(2).
- Disallow read(2), readv(2) (if there is no CAP_SEEK).
CAP_READ new behaviour:
- Allow read(2), readv(2).
- Disallow pread(2) (CAP_SEEK was also required).
CAP_WRITE old behaviour:
- Allow pwrite(2).
- Disallow write(2), writev(2) (if there is no CAP_SEEK).
CAP_WRITE new behaviour:
- Allow write(2), writev(2).
- Disallow pwrite(2) (CAP_SEEK was also required).
Added convinient defines:
#define CAP_PREAD (CAP_SEEK | CAP_READ)
#define CAP_PWRITE (CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ)
#define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL)
#define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W)
#define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X)
#define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X)
#define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X)
#define CAP_RECV CAP_READ
#define CAP_SEND CAP_WRITE
#define CAP_SOCK_CLIENT \
(CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
#define CAP_SOCK_SERVER \
(CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \
CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \
CAP_SETSOCKOPT | CAP_SHUTDOWN)
Added defines for backward API compatibility:
#define CAP_MAPEXEC CAP_MMAP_X
#define CAP_DELETE CAP_UNLINKAT
#define CAP_MKDIR CAP_MKDIRAT
#define CAP_RMDIR CAP_UNLINKAT
#define CAP_MKFIFO CAP_MKFIFOAT
#define CAP_MKNOD CAP_MKNODAT
#define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER)
Sponsored by: The FreeBSD Foundation
Reviewed by: Christoph Mallon <christoph.mallon@gmx.de>
Many aspects discussed with: rwatson, benl, jonathan
ABI compatibility discussed with: kib
2013-03-02 00:53:12 +00:00
|
|
|
## Allow ioctl(2), which hopefully will be limited by applications only to
|
|
|
|
## required commands with cap_ioctls_limit(2) syscall.
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
Merge Capsicum overhaul:
- Capability is no longer separate descriptor type. Now every descriptor
has set of its own capability rights.
- The cap_new(2) system call is left, but it is no longer documented and
should not be used in new code.
- The new syscall cap_rights_limit(2) should be used instead of
cap_new(2), which limits capability rights of the given descriptor
without creating a new one.
- The cap_getrights(2) syscall is renamed to cap_rights_get(2).
- If CAP_IOCTL capability right is present we can further reduce allowed
ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed
ioctls can be retrived with cap_ioctls_get(2) syscall.
- If CAP_FCNTL capability right is present we can further reduce fcntls
that can be used with the new cap_fcntls_limit(2) syscall and retrive
them with cap_fcntls_get(2).
- To support ioctl and fcntl white-listing the filedesc structure was
heavly modified.
- The audit subsystem, kdump and procstat tools were updated to
recognize new syscalls.
- Capability rights were revised and eventhough I tried hard to provide
backward API and ABI compatibility there are some incompatible changes
that are described in detail below:
CAP_CREATE old behaviour:
- Allow for openat(2)+O_CREAT.
- Allow for linkat(2).
- Allow for symlinkat(2).
CAP_CREATE new behaviour:
- Allow for openat(2)+O_CREAT.
Added CAP_LINKAT:
- Allow for linkat(2). ABI: Reuses CAP_RMDIR bit.
- Allow to be target for renameat(2).
Added CAP_SYMLINKAT:
- Allow for symlinkat(2).
Removed CAP_DELETE. Old behaviour:
- Allow for unlinkat(2) when removing non-directory object.
- Allow to be source for renameat(2).
Removed CAP_RMDIR. Old behaviour:
- Allow for unlinkat(2) when removing directory.
Added CAP_RENAMEAT:
- Required for source directory for the renameat(2) syscall.
Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR):
- Allow for unlinkat(2) on any object.
- Required if target of renameat(2) exists and will be removed by this
call.
Removed CAP_MAPEXEC.
CAP_MMAP old behaviour:
- Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and
PROT_WRITE.
CAP_MMAP new behaviour:
- Allow for mmap(2)+PROT_NONE.
Added CAP_MMAP_R:
- Allow for mmap(PROT_READ).
Added CAP_MMAP_W:
- Allow for mmap(PROT_WRITE).
Added CAP_MMAP_X:
- Allow for mmap(PROT_EXEC).
Added CAP_MMAP_RW:
- Allow for mmap(PROT_READ | PROT_WRITE).
Added CAP_MMAP_RX:
- Allow for mmap(PROT_READ | PROT_EXEC).
Added CAP_MMAP_WX:
- Allow for mmap(PROT_WRITE | PROT_EXEC).
Added CAP_MMAP_RWX:
- Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC).
Renamed CAP_MKDIR to CAP_MKDIRAT.
Renamed CAP_MKFIFO to CAP_MKFIFOAT.
Renamed CAP_MKNODE to CAP_MKNODEAT.
CAP_READ old behaviour:
- Allow pread(2).
- Disallow read(2), readv(2) (if there is no CAP_SEEK).
CAP_READ new behaviour:
- Allow read(2), readv(2).
- Disallow pread(2) (CAP_SEEK was also required).
CAP_WRITE old behaviour:
- Allow pwrite(2).
- Disallow write(2), writev(2) (if there is no CAP_SEEK).
CAP_WRITE new behaviour:
- Allow write(2), writev(2).
- Disallow pwrite(2) (CAP_SEEK was also required).
Added convinient defines:
#define CAP_PREAD (CAP_SEEK | CAP_READ)
#define CAP_PWRITE (CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ)
#define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL)
#define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W)
#define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X)
#define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X)
#define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X)
#define CAP_RECV CAP_READ
#define CAP_SEND CAP_WRITE
#define CAP_SOCK_CLIENT \
(CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
#define CAP_SOCK_SERVER \
(CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \
CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \
CAP_SETSOCKOPT | CAP_SHUTDOWN)
Added defines for backward API compatibility:
#define CAP_MAPEXEC CAP_MMAP_X
#define CAP_DELETE CAP_UNLINKAT
#define CAP_MKDIR CAP_MKDIRAT
#define CAP_RMDIR CAP_UNLINKAT
#define CAP_MKFIFO CAP_MKFIFOAT
#define CAP_MKNOD CAP_MKNODAT
#define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER)
Sponsored by: The FreeBSD Foundation
Reviewed by: Christoph Mallon <christoph.mallon@gmx.de>
Many aspects discussed with: rwatson, benl, jonathan
ABI compatibility discussed with: kib
2013-03-02 00:53:12 +00:00
|
|
|
ioctl
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying current process credential state.
|
|
|
|
##
|
|
|
|
issetugid
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow kevent(2), as we will authorize based on capability rights on the
|
|
|
|
## target descriptor.
|
|
|
|
##
|
|
|
|
kevent
|
|
|
|
|
2012-11-27 10:22:40 +00:00
|
|
|
##
|
|
|
|
## Allow kill(2), as we allow the process to send signals only to himself.
|
|
|
|
##
|
|
|
|
kill
|
|
|
|
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
|
|
|
## Allow message queue operations on file descriptors, subject to capability
|
|
|
|
## rights.
|
|
|
|
##
|
|
|
|
kmq_notify
|
|
|
|
kmq_setattr
|
|
|
|
kmq_timedreceive
|
|
|
|
kmq_timedsend
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow kqueue(2), we will control use.
|
|
|
|
##
|
|
|
|
kqueue
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow managing per-process timers.
|
|
|
|
##
|
|
|
|
ktimer_create
|
|
|
|
ktimer_delete
|
|
|
|
ktimer_getoverrun
|
|
|
|
ktimer_gettime
|
|
|
|
ktimer_settime
|
|
|
|
|
|
|
|
##
|
|
|
|
## We can't allow ktrace(2) because it relies on a global namespace, but we
|
|
|
|
## might want to introduce an fktrace(2) of some sort.
|
|
|
|
##
|
|
|
|
#ktrace
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow AIO operations by file descriptor, subject to capability rights.
|
|
|
|
##
|
|
|
|
lio_listio
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow listen(2), subject to capability rights.
|
|
|
|
##
|
|
|
|
## XXXRW: One might argue this manipulates a global namespace.
|
|
|
|
##
|
|
|
|
listen
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow I/O-related file descriptors, subject to capability rights.
|
|
|
|
##
|
|
|
|
lseek
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow simple VM operations on the current process.
|
|
|
|
##
|
|
|
|
madvise
|
|
|
|
mincore
|
|
|
|
minherit
|
|
|
|
mlock
|
|
|
|
mlockall
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow memory mapping a file descriptor, and updating protections, subject
|
|
|
|
## to capability rights.
|
|
|
|
##
|
|
|
|
mmap
|
|
|
|
mprotect
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow simple VM operations on the current process.
|
|
|
|
##
|
|
|
|
msync
|
|
|
|
munlock
|
|
|
|
munlockall
|
|
|
|
munmap
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow the current process to sleep.
|
|
|
|
##
|
|
|
|
nanosleep
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying the global clock.
|
|
|
|
##
|
|
|
|
ntp_gettime
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow AIO operations by file descriptor, subject to capability rights.
|
|
|
|
##
|
|
|
|
oaio_read
|
|
|
|
oaio_write
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow simple VM operations on the current process.
|
|
|
|
##
|
|
|
|
obreak
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow AIO operations by file descriptor, subject to capability rights.
|
|
|
|
##
|
|
|
|
olio_listio
|
|
|
|
|
|
|
|
##
|
2011-08-13 10:43:21 +00:00
|
|
|
## Operations relative to directory capabilities.
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
2013-03-21 22:59:01 +00:00
|
|
|
chflagsat
|
2011-08-13 10:43:21 +00:00
|
|
|
faccessat
|
|
|
|
fchmodat
|
2012-05-31 19:32:37 +00:00
|
|
|
fchownat
|
2013-03-15 23:00:13 +00:00
|
|
|
fstatat
|
2011-08-13 10:43:21 +00:00
|
|
|
futimesat
|
2012-05-31 19:32:37 +00:00
|
|
|
linkat
|
2011-08-13 10:43:21 +00:00
|
|
|
mkdirat
|
|
|
|
mkfifoat
|
|
|
|
mknodat
|
|
|
|
openat
|
2012-05-31 19:32:37 +00:00
|
|
|
readlinkat
|
2011-08-13 10:43:21 +00:00
|
|
|
renameat
|
2012-05-31 19:32:37 +00:00
|
|
|
symlinkat
|
|
|
|
unlinkat
|
2015-01-23 21:07:08 +00:00
|
|
|
utimensat
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Process descriptor-related system calls are allowed.
|
|
|
|
##
|
|
|
|
pdfork
|
|
|
|
pdgetpid
|
|
|
|
pdkill
|
Add experimental support for process descriptors
A "process descriptor" file descriptor is used to manage processes
without using the PID namespace. This is required for Capsicum's
Capability Mode, where the PID namespace is unavailable.
New system calls pdfork(2) and pdkill(2) offer the functional equivalents
of fork(2) and kill(2). pdgetpid(2) allows querying the PID of the remote
process for debugging purposes. The currently-unimplemented pdwait(2) will,
in the future, allow querying rusage/exit status. In the interim, poll(2)
may be used to check (and wait for) process termination.
When a process is referenced by a process descriptor, it does not issue
SIGCHLD to the parent, making it suitable for use in libraries---a common
scenario when using library compartmentalisation from within large
applications (such as web browsers). Some observers may note a similarity
to Mach task ports; process descriptors provide a subset of this behaviour,
but in a UNIX style.
This feature is enabled by "options PROCDESC", but as with several other
Capsicum kernel features, is not enabled by default in GENERIC 9.0.
Reviewed by: jhb, kib
Approved by: re (kib), mentor (rwatson)
Sponsored by: Google Inc
2011-08-18 22:51:30 +00:00
|
|
|
#pdwait4 # not yet implemented
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow pipe(2).
|
|
|
|
##
|
|
|
|
pipe
|
2013-05-01 22:42:42 +00:00
|
|
|
pipe2
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow poll(2), which will be scoped by capability rights.
|
|
|
|
## XXXRW: We don't yet do that scoping.
|
|
|
|
##
|
|
|
|
poll
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow I/O-related file descriptors, subject to capability rights.
|
|
|
|
##
|
|
|
|
pread
|
|
|
|
preadv
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow access to profiling state on the current process.
|
|
|
|
##
|
|
|
|
profil
|
|
|
|
|
|
|
|
##
|
|
|
|
## Disallow ptrace(2) for now, but we do need debugging facilities in
|
|
|
|
## capability mode, so we will want to revisit this, possibly by scoping its
|
|
|
|
## operation.
|
|
|
|
##
|
|
|
|
#ptrace
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow I/O-related file descriptors, subject to capability rights.
|
|
|
|
##
|
|
|
|
pwrite
|
|
|
|
pwritev
|
|
|
|
read
|
|
|
|
readv
|
|
|
|
recv
|
|
|
|
recvfrom
|
|
|
|
recvmsg
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow real-time scheduling primitives to be used.
|
|
|
|
##
|
|
|
|
## XXXRW: These require scoping.
|
|
|
|
##
|
|
|
|
rtprio
|
|
|
|
rtprio_thread
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow simple VM operations on the current process.
|
|
|
|
##
|
|
|
|
sbrk
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow querying trivial global scheduler state.
|
|
|
|
##
|
|
|
|
sched_get_priority_max
|
|
|
|
sched_get_priority_min
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow various thread/process scheduler operations.
|
|
|
|
##
|
|
|
|
## XXXRW: Some of these require further scoping.
|
|
|
|
##
|
|
|
|
sched_getparam
|
|
|
|
sched_getscheduler
|
2013-11-06 07:46:10 +00:00
|
|
|
sched_rr_get_interval
|
2011-03-01 13:28:27 +00:00
|
|
|
sched_setparam
|
|
|
|
sched_setscheduler
|
|
|
|
sched_yield
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow I/O-related file descriptors, subject to capability rights.
|
|
|
|
##
|
|
|
|
sctp_generic_recvmsg
|
|
|
|
sctp_generic_sendmsg
|
|
|
|
sctp_generic_sendmsg_iov
|
|
|
|
sctp_peeloff
|
|
|
|
|
|
|
|
##
|
2013-12-15 23:14:27 +00:00
|
|
|
## Allow pselect(2) and select(2), which will be scoped by capability rights.
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
|
|
|
## XXXRW: But is it?
|
|
|
|
##
|
2013-12-15 23:14:27 +00:00
|
|
|
pselect
|
2011-03-01 13:28:27 +00:00
|
|
|
select
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow I/O-related file descriptors, subject to capability rights. Use of
|
|
|
|
## explicit addresses here is restricted by the system calls themselves.
|
|
|
|
##
|
|
|
|
send
|
|
|
|
sendfile
|
|
|
|
sendmsg
|
|
|
|
sendto
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow setting per-process audit state, which is controlled separately by
|
|
|
|
## privileges.
|
|
|
|
##
|
|
|
|
setaudit
|
|
|
|
setaudit_addr
|
|
|
|
setauid
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow setting thread context.
|
|
|
|
##
|
|
|
|
setcontext
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow setting current process credential state, which is controlled
|
|
|
|
## separately by privilege.
|
|
|
|
##
|
|
|
|
setegid
|
|
|
|
seteuid
|
|
|
|
setgid
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow use of the process interval timer.
|
|
|
|
##
|
|
|
|
setitimer
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow setpriority(2).
|
|
|
|
##
|
|
|
|
## XXXRW: Requires scoping.
|
|
|
|
##
|
|
|
|
setpriority
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow setting current process credential state, which is controlled
|
|
|
|
## separately by privilege.
|
|
|
|
##
|
|
|
|
setregid
|
|
|
|
setresgid
|
|
|
|
setresuid
|
|
|
|
setreuid
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow setting process resource limits with setrlimit(2).
|
|
|
|
##
|
|
|
|
setrlimit
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow creating a new session with setsid(2).
|
|
|
|
##
|
|
|
|
setsid
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow setting socket options with setsockopt(2), subject to capability
|
|
|
|
## rights.
|
|
|
|
##
|
|
|
|
## XXXRW: Might require scoping.
|
|
|
|
##
|
|
|
|
setsockopt
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow setting current process credential state, which is controlled
|
|
|
|
## separately by privilege.
|
|
|
|
##
|
|
|
|
setuid
|
|
|
|
|
|
|
|
##
|
2011-08-13 10:43:21 +00:00
|
|
|
## shm_open(2) is scoped so as to allow only access to new anonymous objects.
|
2011-03-01 13:28:27 +00:00
|
|
|
##
|
2011-08-13 10:43:21 +00:00
|
|
|
shm_open
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow I/O-related file descriptors, subject to capability rights.
|
|
|
|
##
|
|
|
|
shutdown
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow signal control on current process.
|
|
|
|
##
|
|
|
|
sigaction
|
|
|
|
sigaltstack
|
|
|
|
sigblock
|
|
|
|
sigpending
|
|
|
|
sigprocmask
|
|
|
|
sigqueue
|
|
|
|
sigreturn
|
|
|
|
sigsetmask
|
|
|
|
sigstack
|
|
|
|
sigsuspend
|
|
|
|
sigtimedwait
|
|
|
|
sigvec
|
|
|
|
sigwaitinfo
|
2014-01-28 01:49:49 +00:00
|
|
|
sigwait
|
2011-03-01 13:28:27 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
## Allow creating new socket pairs with socket(2) and socketpair(2).
|
|
|
|
##
|
|
|
|
socket
|
|
|
|
socketpair
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow simple VM operations on the current process.
|
|
|
|
##
|
|
|
|
## XXXRW: Kernel doesn't implement this, so drop?
|
|
|
|
##
|
|
|
|
sstk
|
|
|
|
|
|
|
|
##
|
|
|
|
## Do allow sync(2) for now, but possibly shouldn't.
|
|
|
|
##
|
|
|
|
sync
|
|
|
|
|
|
|
|
##
|
|
|
|
## Always allow process termination with sys_exit(2).
|
|
|
|
##
|
|
|
|
sys_exit
|
|
|
|
|
|
|
|
##
|
|
|
|
## sysarch(2) does rather diverse things, but is required on at least i386
|
|
|
|
## in order to configure per-thread data. As such, it's scoped on each
|
|
|
|
## architecture.
|
|
|
|
##
|
|
|
|
sysarch
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow thread operations operating only on current process.
|
|
|
|
##
|
|
|
|
thr_create
|
|
|
|
thr_exit
|
|
|
|
thr_kill
|
|
|
|
|
|
|
|
##
|
|
|
|
## Disallow thr_kill2(2), as it may operate beyond the current process.
|
|
|
|
##
|
|
|
|
## XXXRW: Requires scoping.
|
|
|
|
##
|
|
|
|
#thr_kill2
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow thread operations operating only on current process.
|
|
|
|
##
|
|
|
|
thr_new
|
|
|
|
thr_self
|
|
|
|
thr_set_name
|
|
|
|
thr_suspend
|
|
|
|
thr_wake
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow manipulation of the current process umask with umask(2).
|
|
|
|
##
|
|
|
|
umask
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow submitting of process trace entries with utrace(2).
|
|
|
|
##
|
|
|
|
utrace
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow generating UUIDs with uuidgen(2).
|
|
|
|
##
|
|
|
|
uuidgen
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow I/O-related file descriptors, subject to capability rights.
|
|
|
|
##
|
|
|
|
write
|
|
|
|
writev
|
|
|
|
|
|
|
|
##
|
|
|
|
## Allow processes to yield(2).
|
|
|
|
##
|
|
|
|
yield
|