diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2020-11-17 21:14:13 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2020-11-17 21:14:13 +0000 |
commit | 85078b8573332c2c83a79adea8a61b519fb3b6af (patch) | |
tree | a721f4ce38f990646f8bcd322c64c082ddb2353a /sys/kern/vfs_syscalls.c | |
parent | ede4af47ae6e3b6f961462f687d28ba3623882a5 (diff) | |
download | src-85078b8573332c2c83a79adea8a61b519fb3b6af.tar.gz src-85078b8573332c2c83a79adea8a61b519fb3b6af.zip |
Split out cwd/root/jail, cmask state from filedesc table
No functional change intended.
Tracking these structures separately for each proc enables future work to
correctly emulate clone(2) in linux(4).
__FreeBSD_version is bumped (to 1300130) for consumption by, e.g., lsof.
Reviewed by: kib
Discussed with: markj, mjg
Differential Revision: https://reviews.freebsd.org/D27037
Notes
Notes:
svn path=/head/; revision=367777
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r-- | sys/kern/vfs_syscalls.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index dfc46c405a1a..d3d7617c2801 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1098,7 +1098,8 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, int flags, int mode) { struct proc *p = td->td_proc; - struct filedesc *fdp = p->p_fd; + struct filedesc *fdp; + struct pwddesc *pdp; struct file *fp; struct vnode *vp; struct nameidata nd; @@ -1106,6 +1107,8 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, int cmode, error, indx; indx = -1; + fdp = p->p_fd; + pdp = p->p_pd; AUDIT_ARG_FFLAGS(flags); AUDIT_ARG_MODE(mode); @@ -1137,7 +1140,7 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, */ /* Set the flags early so the finit in devfs can pick them up. */ fp->f_flag = flags & FMASK; - cmode = ((mode & ~fdp->fd_cmask) & ALLPERMS) & ~S_ISTXT; + cmode = ((mode & ~pdp->pd_cmask) & ALLPERMS) & ~S_ISTXT; NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, fd, &rights, td); td->td_dupfd = -1; /* XXX check for fdopen */ @@ -1339,7 +1342,7 @@ restart: } else { VATTR_NULL(&vattr); vattr.va_mode = (mode & ALLPERMS) & - ~td->td_proc->p_fd->fd_cmask; + ~td->td_proc->p_pd->pd_cmask; vattr.va_rdev = dev; whiteout = 0; @@ -1454,7 +1457,7 @@ restart: } VATTR_NULL(&vattr); vattr.va_type = VFIFO; - vattr.va_mode = (mode & ALLPERMS) & ~td->td_proc->p_fd->fd_cmask; + vattr.va_mode = (mode & ALLPERMS) & ~td->td_proc->p_pd->pd_cmask; #ifdef MAC error = mac_vnode_check_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd, &vattr); @@ -1726,7 +1729,7 @@ restart: goto restart; } VATTR_NULL(&vattr); - vattr.va_mode = ACCESSPERMS &~ td->td_proc->p_fd->fd_cmask; + vattr.va_mode = ACCESSPERMS &~ td->td_proc->p_pd->pd_cmask; #ifdef MAC vattr.va_type = VLNK; error = mac_vnode_check_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd, @@ -3803,7 +3806,7 @@ restart: } VATTR_NULL(&vattr); vattr.va_type = VDIR; - vattr.va_mode = (mode & ACCESSPERMS) &~ td->td_proc->p_fd->fd_cmask; + vattr.va_mode = (mode & ACCESSPERMS) &~ td->td_proc->p_pd->pd_cmask; #ifdef MAC error = mac_vnode_check_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd, &vattr); @@ -4207,13 +4210,13 @@ struct umask_args { int sys_umask(struct thread *td, struct umask_args *uap) { - struct filedesc *fdp; + struct pwddesc *pdp; - fdp = td->td_proc->p_fd; - FILEDESC_XLOCK(fdp); - td->td_retval[0] = fdp->fd_cmask; - fdp->fd_cmask = uap->newmask & ALLPERMS; - FILEDESC_XUNLOCK(fdp); + pdp = td->td_proc->p_pd; + PWDDESC_XLOCK(pdp); + td->td_retval[0] = pdp->pd_cmask; + pdp->pd_cmask = uap->newmask & ALLPERMS; + PWDDESC_XUNLOCK(pdp); return (0); } |