PERFORCE change 40354 for review

Chris Vance cvance at FreeBSD.org
Fri Oct 24 01:11:11 GMT 2003


http://perforce.freebsd.org/chv.cgi?CH=40354

Change 40354 by cvance at cvance_osx_laptop on 2003/10/23 18:10:19

	Add vnode read,write, and stat entry points

Affected files ...

.. //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/kern/kern_ktrace.c#3 edit
.. //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/vfs/vfs_syscalls.c#4 edit
.. //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/vfs/vfs_vnops.c#4 edit

Differences ...

==== //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/kern/kern_ktrace.c#3 (text+ko) ====

@@ -562,6 +562,10 @@
 	if (error)
 		goto bad;
 	(void)VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
+#ifdef MAC
+	error = mac_check_vnode_write(p->p_ucred, NOCRED, vp);
+	if (error == 0)
+#endif
 	error = VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, p->p_ucred);
 	if (error == 0 && uio != NULL) {
 		(void)VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);

==== //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/vfs/vfs_syscalls.c#4 (text+ko) ====

@@ -1061,6 +1061,12 @@
 		type = F_FLOCK;
 		if ((flags & FNONBLOCK) == 0)
 			type |= F_WAIT;
+#ifdef MAC_XXX
+		error = mac_check_file_change_flags(p->p_ucred, fp,
+		    fp->f_flag, fp->f_flag | FHASLOCK);
+		if (error)
+			return (error);
+#endif
 		VOP_UNLOCK(vp, 0, p);
 		if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
 			(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
@@ -2260,6 +2266,10 @@
 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
 	if (vp->v_type == VDIR)
 		error = EISDIR;
+#ifdef MAC
+	else if ((error = mac_check_vnode_write(p->p_ucred, NOCRED, vp))) {
+	}
+#endif
 	else if ((error = vn_writechk(vp)) == 0 &&
 	    (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) == 0) {
 		VATTR_NULL(&vattr);
@@ -2311,6 +2321,10 @@
 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
 	if (vp->v_type == VDIR)
 		error = EISDIR;
+#ifdef MAC
+	else if ((error = mac_check_vnode_write(p->p_ucred, fp->f_cred, vp))) {
+	}
+#endif
 	else if ((error = vn_writechk(vp)) == 0) {
 		VATTR_NULL(&vattr);
 		vattr.va_size = uap->length;

==== //depot/projects/trustedbsd/sedarwin/apsl/xnu/bsd/vfs/vfs_vnops.c#4 (text+ko) ====

@@ -162,6 +162,12 @@
 		goto bad;
 	}
 
+#ifdef MAC
+	error = mac_check_vnode_open(cred, vp, fmode);
+	if (error)
+		goto bad;
+#endif
+
 #if DIAGNOSTIC
 	if (UBCINFOMISSING(vp))
 		panic("vn_open: ubc_info_init");
@@ -298,7 +304,14 @@
 	auio.uio_rw = rw;
 	auio.uio_procp = p;
 
+#ifdef MAC
+	/* passed cred is fp->f_cred */
 	if (rw == UIO_READ)
+		error = mac_check_vnode_read(p->p_ucred, cred, vp);
+	else
+		error = mac_check_vnode_write(p->p_ucred, cred, vp);
+#endif
+if (rw == UIO_READ)
 		error = VOP_READ(vp, &auio, ioflg, cred);
 	 else 
 		error = VOP_WRITE(vp, &auio, ioflg, cred);
@@ -387,6 +400,10 @@
 			goto done;
 		}
 	}
+#ifdef MAC
+	error = mac_check_vnode_read(p->p_ucred, cred, vp);
+	if (error == 0)
+#endif
 	error = VOP_READ(vp, uio, ioflag, cred);
 	if ((flags & FOF_OFFSET) == 0)
 		fp->f_offset += count - uio->uio_resid;
@@ -478,6 +495,10 @@
 			goto done;
 		}
 	}
+#ifdef MAC
+	error = mac_check_vnode_write(p->p_ucred, cred, vp);
+	if (error == 0)
+#endif
 	error = VOP_WRITE(vp, uio, ioflag, cred);
 
 	if ((flags & FOF_OFFSET) == 0) {
@@ -513,6 +534,12 @@
 	int error;
 	u_short mode;
 
+#ifdef MAC
+	error = mac_check_vnode_stat(p->p_ucred, NOCRED, vp);
+	if (error)
+		return (error);
+#endif
+
 	vap = &vattr;
 	error = VOP_GETATTR(vp, vap, p->p_ucred, p);
 	if (error)
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list