Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Jul 2015 19:05:17 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285172 - in head/sys: cddl/compat/opensolaris/sys compat/linux fs/fdescfs kern security/audit
Message-ID:  <201507051905.t65J5Hre003220@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sun Jul  5 19:05:16 2015
New Revision: 285172
URL: https://svnweb.freebsd.org/changeset/base/285172

Log:
  fd: make 'rights' a manadatory argument to fget* functions

Modified:
  head/sys/cddl/compat/opensolaris/sys/file.h
  head/sys/compat/linux/linux_stats.c
  head/sys/fs/fdescfs/fdesc_vnops.c
  head/sys/kern/kern_descrip.c
  head/sys/kern/vfs_aio.c
  head/sys/security/audit/audit_bsm_klib.c

Modified: head/sys/cddl/compat/opensolaris/sys/file.h
==============================================================================
--- head/sys/cddl/compat/opensolaris/sys/file.h	Sun Jul  5 18:16:06 2015	(r285171)
+++ head/sys/cddl/compat/opensolaris/sys/file.h	Sun Jul  5 19:05:16 2015	(r285172)
@@ -52,9 +52,10 @@ static __inline void
 releasef(int fd)
 {
 	struct file *fp;
+	cap_rights_t rights;
 
 	/* No CAP_ rights required, as we're only releasing. */
-	if (fget(curthread, fd, NULL, &fp) == 0) {
+	if (fget(curthread, fd, cap_rights_init(&rights), &fp) == 0) {
 		fdrop(fp, curthread);
 		fdrop(fp, curthread);
 	}

Modified: head/sys/compat/linux/linux_stats.c
==============================================================================
--- head/sys/compat/linux/linux_stats.c	Sun Jul  5 18:16:06 2015	(r285171)
+++ head/sys/compat/linux/linux_stats.c	Sun Jul  5 19:05:16 2015	(r285172)
@@ -139,13 +139,14 @@ translate_fd_major_minor(struct thread *
 {
 	struct file *fp;
 	struct vnode *vp;
+	cap_rights_t rights;
 	int major, minor;
 
 	/*
 	 * No capability rights required here.
 	 */
 	if ((!S_ISCHR(buf->st_mode) && !S_ISBLK(buf->st_mode)) ||
-	    fget(td, fd, 0, &fp) != 0)
+	    fget(td, fd, cap_rights_init(&rights), &fp) != 0)
 		return;
 	vp = fp->f_vnode;
 	if (vp != NULL && vp->v_rdev != NULL &&

Modified: head/sys/fs/fdescfs/fdesc_vnops.c
==============================================================================
--- head/sys/fs/fdescfs/fdesc_vnops.c	Sun Jul  5 18:16:06 2015	(r285171)
+++ head/sys/fs/fdescfs/fdesc_vnops.c	Sun Jul  5 19:05:16 2015	(r285172)
@@ -288,6 +288,7 @@ fdesc_lookup(ap)
 	struct thread *td = cnp->cn_thread;
 	struct file *fp;
 	struct fdesc_get_ino_args arg;
+	cap_rights_t rights;
 	int nlen = cnp->cn_namelen;
 	u_int fd, fd1;
 	int error;
@@ -332,7 +333,7 @@ fdesc_lookup(ap)
 	/*
 	 * No rights to check since 'fp' isn't actually used.
 	 */
-	if ((error = fget(td, fd, NULL, &fp)) != 0)
+	if ((error = fget(td, fd, cap_rights_init(&rights), &fp)) != 0)
 		goto bad;
 
 	/* Check if we're looking up ourselves. */

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Sun Jul  5 18:16:06 2015	(r285171)
+++ head/sys/kern/kern_descrip.c	Sun Jul  5 19:05:16 2015	(r285172)
@@ -2423,13 +2423,10 @@ _fget(struct thread *td, int fd, struct 
 {
 	struct filedesc *fdp;
 	struct file *fp;
-	cap_rights_t needrights;
 	int error;
 
 	*fpp = NULL;
 	fdp = td->td_proc->p_fd;
-	if (needrightsp == NULL)
-		needrightsp = cap_rights_init(&needrights);
 	error = fget_unlocked(fdp, fd, needrightsp, &fp, seqp);
 	if (error != 0)
 		return (error);

Modified: head/sys/kern/vfs_aio.c
==============================================================================
--- head/sys/kern/vfs_aio.c	Sun Jul  5 18:16:06 2015	(r285171)
+++ head/sys/kern/vfs_aio.c	Sun Jul  5 19:05:16 2015	(r285172)
@@ -2058,6 +2058,7 @@ sys_aio_cancel(struct thread *td, struct
 	struct aiocblist *cbe, *cbn;
 	struct file *fp;
 	struct socket *so;
+	cap_rights_t rights;
 	int error;
 	int remove;
 	int cancelled = 0;
@@ -2065,7 +2066,7 @@ sys_aio_cancel(struct thread *td, struct
 	struct vnode *vp;
 
 	/* Lookup file object. */
-	error = fget(td, uap->fd, NULL, &fp);
+	error = fget(td, uap->fd, cap_rights_init(&rights), &fp);
 	if (error)
 		return (error);
 

Modified: head/sys/security/audit/audit_bsm_klib.c
==============================================================================
--- head/sys/security/audit/audit_bsm_klib.c	Sun Jul  5 18:16:06 2015	(r285171)
+++ head/sys/security/audit/audit_bsm_klib.c	Sun Jul  5 19:05:16 2015	(r285172)
@@ -32,6 +32,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/capsicum.h>
 #include <sys/fcntl.h>
 #include <sys/filedesc.h>
 #include <sys/libkern.h>
@@ -467,6 +468,7 @@ audit_canon_path(struct thread *td, int 
 	char *rbuf, *fbuf, *copy;
 	struct filedesc *fdp;
 	struct sbuf sbf;
+	cap_rights_t rights;
 	int error, needslash;
 
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "%s: at %s:%d",
@@ -495,7 +497,7 @@ audit_canon_path(struct thread *td, int 
 			vhold(cvnp);
 		} else {
 			/* XXX: fgetvp() that vhold()s vnode instead of vref()ing it would be better */
-			error = fgetvp(td, dirfd, NULL, &cvnp);
+			error = fgetvp(td, dirfd, cap_rights_init(&rights), &cvnp);
 			if (error) {
 				FILEDESC_SUNLOCK(fdp);
 				cpath[0] = '\0';



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507051905.t65J5Hre003220>