diff options
author | Robert Watson <rwatson@FreeBSD.org> | 2011-08-11 12:30:23 +0000 |
---|---|---|
committer | Robert Watson <rwatson@FreeBSD.org> | 2011-08-11 12:30:23 +0000 |
commit | a9d2f8d84f69e98100b5746816b35666bcf992ac (patch) | |
tree | 4b691c0e209134040c3cf5ce75660b61282933d0 /sys/sys/file.h | |
parent | 2ffd5fdcc433626b1adb061119cd412f9b3020e9 (diff) | |
download | src-a9d2f8d84f69e98100b5746816b35666bcf992ac.tar.gz src-a9d2f8d84f69e98100b5746816b35666bcf992ac.zip |
Second-to-last commit implementing Capsicum capabilities in the FreeBSD
kernel for FreeBSD 9.0:
Add a new capability mask argument to fget(9) and friends, allowing system
call code to declare what capabilities are required when an integer file
descriptor is converted into an in-kernel struct file *. With options
CAPABILITIES compiled into the kernel, this enforces capability
protection; without, this change is effectively a no-op.
Some cases require special handling, such as mmap(2), which must preserve
information about the maximum rights at the time of mapping in the memory
map so that they can later be enforced in mprotect(2) -- this is done by
narrowing the rights in the existing max_protection field used for similar
purposes with file permissions.
In namei(9), we assert that the code is not reached from within capability
mode, as we're not yet ready to enforce namespace capabilities there.
This will follow in a later commit.
Update two capability names: CAP_EVENT and CAP_KEVENT become
CAP_POST_KEVENT and CAP_POLL_KEVENT to more accurately indicate what they
represent.
Approved by: re (bz)
Submitted by: jonathan
Sponsored by: Google Inc
Notes
Notes:
svn path=/head/; revision=224778
Diffstat (limited to 'sys/sys/file.h')
-rw-r--r-- | sys/sys/file.h | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/sys/sys/file.h b/sys/sys/file.h index eea2c0091f65..2c64bcf644e0 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -176,9 +176,13 @@ extern int maxfiles; /* kernel limit on number of open files */ extern int maxfilesperproc; /* per process limit on number of open files */ extern volatile int openfiles; /* actual number of open files */ -int fget(struct thread *td, int fd, struct file **fpp); -int fget_read(struct thread *td, int fd, struct file **fpp); -int fget_write(struct thread *td, int fd, struct file **fpp); +int fget(struct thread *td, int fd, cap_rights_t rights, struct file **fpp); +int fget_mmap(struct thread *td, int fd, cap_rights_t rights, + u_char *maxprotp, struct file **fpp); +int fget_read(struct thread *td, int fd, cap_rights_t rights, + struct file **fpp); +int fget_write(struct thread *td, int fd, cap_rights_t rights, + struct file **fpp); int fgetcap(struct thread *td, int fd, struct file **fpp); int _fdrop(struct file *fp, struct thread *td); @@ -197,11 +201,16 @@ fo_stat_t soo_stat; fo_close_t soo_close; void finit(struct file *, u_int, short, void *, struct fileops *); -int fgetvp(struct thread *td, int fd, struct vnode **vpp); -int fgetvp_read(struct thread *td, int fd, struct vnode **vpp); -int fgetvp_write(struct thread *td, int fd, struct vnode **vpp); - -int fgetsock(struct thread *td, int fd, struct socket **spp, u_int *fflagp); +int fgetvp(struct thread *td, int fd, cap_rights_t rights, struct vnode **vpp); +int fgetvp_rights(struct thread *td, int fd, cap_rights_t need, + cap_rights_t *have, struct vnode **vpp); +int fgetvp_read(struct thread *td, int fd, cap_rights_t rights, + struct vnode **vpp); +int fgetvp_write(struct thread *td, int fd, cap_rights_t rights, + struct vnode **vpp); + +int fgetsock(struct thread *td, int fd, cap_rights_t rights, + struct socket **spp, u_int *fflagp); void fputsock(struct socket *sp); static __inline int |