svn commit: r356432 - in head/sys: kern security/mac_veriexec sys

Mateusz Guzik mjg at FreeBSD.org
Tue Jan 7 04:29:35 UTC 2020


Author: mjg
Date: Tue Jan  7 04:29:34 2020
New Revision: 356432
URL: https://svnweb.freebsd.org/changeset/base/356432

Log:
  vfs: eliminate v_tag from struct vnode
  
  There was only one consumer and it was using it incorrectly.
  
  It is given an equivalent hack.
  
  Reviewed by:	jeff
  Differential Revision:	https://reviews.freebsd.org/D23037

Modified:
  head/sys/kern/vfs_subr.c
  head/sys/security/mac_veriexec/mac_veriexec.c
  head/sys/sys/vnode.h

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Tue Jan  7 04:27:40 2020	(r356431)
+++ head/sys/kern/vfs_subr.c	Tue Jan  7 04:29:34 2020	(r356432)
@@ -1657,7 +1657,6 @@ alloc:
 	KASSERT(vp->v_lockf == NULL, ("stale v_lockf %p", vp));
 	KASSERT(vp->v_pollinfo == NULL, ("stale v_pollinfo %p", vp));
 	vp->v_type = VNON;
-	vp->v_tag = tag;
 	vp->v_op = vops;
 	v_init_counters(vp);
 	vp->v_bufobj.bo_ops = &buf_ops_bio;
@@ -3679,7 +3678,7 @@ vgonel(struct vnode *vp)
 	if (mp != NULL)
 		vn_finished_secondary_write(mp);
 	VNASSERT(vp->v_object == NULL, vp,
-	    ("vop_reclaim left v_object vp=%p, tag=%s", vp, vp->v_tag));
+	    ("vop_reclaim left v_object vp=%p", vp));
 	/*
 	 * Clear the advisory locks and wake up waiting threads.
 	 */
@@ -3697,7 +3696,6 @@ vgonel(struct vnode *vp)
 	VI_LOCK(vp);
 	vp->v_vnlock = &vp->v_lock;
 	vp->v_op = &dead_vnodeops;
-	vp->v_tag = "none";
 	vp->v_type = VBAD;
 }
 
@@ -3733,7 +3731,7 @@ vn_printf(struct vnode *vp, const char *fmt, ...)
 	vprintf(fmt, ap);
 	va_end(ap);
 	printf("%p: ", (void *)vp);
-	printf("tag %s, type %s\n", vp->v_tag, typename[vp->v_type]);
+	printf("type %s\n", typename[vp->v_type]);
 	printf("    usecount %d, writecount %d, refcount %d",
 	    vp->v_usecount, vp->v_writecount, vp->v_holdcnt);
 	switch (vp->v_type) {

Modified: head/sys/security/mac_veriexec/mac_veriexec.c
==============================================================================
--- head/sys/security/mac_veriexec/mac_veriexec.c	Tue Jan  7 04:27:40 2020	(r356431)
+++ head/sys/security/mac_veriexec/mac_veriexec.c	Tue Jan  7 04:29:34 2020	(r356432)
@@ -737,6 +737,22 @@ MAC_POLICY_SET(&mac_veriexec_ops, mac_veriexec, MAC_VE
     MPC_LOADTIME_FLAG_NOTLATE, &mac_veriexec_slot);
 MODULE_VERSION(mac_veriexec, 1);
 
+static struct vnode *
+mac_veriexec_bottom_vnode(struct vnode *vp)
+{
+	struct vnode *ldvp = NULL;
+
+	/*
+	 * XXX This code is bogus. nullfs is not the only stacking
+	 * filesystem. Less bogus code would add a VOP to reach bottom
+	 * vnode and would not make assumptions how to get there.
+	 */
+	if (vp->v_mount != NULL &&
+	    strcmp(vp->v_mount->mnt_vfc->vfc_name, "nullfs") == 0)
+		ldvp = NULLVPTOLOWERVP(vp);
+	return (ldvp);
+}
+
 /**
  * @brief Get the fingerprint status set on a vnode.
  *
@@ -748,6 +764,7 @@ fingerprint_status_t
 mac_veriexec_get_fingerprint_status(struct vnode *vp)
 {
 	fingerprint_status_t fps;
+	struct vnode *ldvp;
 
 	fps = SLOT(vp->v_label);
 	switch (fps) {
@@ -757,12 +774,9 @@ mac_veriexec_get_fingerprint_status(struct vnode *vp)
 		break;
 	default:
 		/* we may need to recurse */
-		if (strcmp(vp->v_tag, "null") == 0) {
-			struct vnode *ldvp;
-
-			ldvp = NULLVPTOLOWERVP(vp);
+		ldvp = mac_veriexec_bottom_vnode(vp);
+		if (ldvp != NULL)
 			return mac_veriexec_get_fingerprint_status(ldvp);
-		}
 		break;
 	}
 	return fps;
@@ -808,12 +822,11 @@ void
 mac_veriexec_set_fingerprint_status(struct vnode *vp,
     fingerprint_status_t fp_status)
 {
+	struct vnode *ldvp;
 
 	/* recurse until we find the real storage */
-	if (strcmp(vp->v_tag, "null") == 0) {
-		struct vnode *ldvp;
-
-		ldvp = NULLVPTOLOWERVP(vp);
+	ldvp = mac_veriexec_bottom_vnode(vp);
+	if (ldvp != NULL) {
 		mac_veriexec_set_fingerprint_status(ldvp, fp_status);
 		return;
 	}

Modified: head/sys/sys/vnode.h
==============================================================================
--- head/sys/sys/vnode.h	Tue Jan  7 04:27:40 2020	(r356431)
+++ head/sys/sys/vnode.h	Tue Jan  7 04:29:34 2020	(r356432)
@@ -174,7 +174,6 @@ struct vnode {
 	int	v_writecount;			/* I ref count of writers or
 						   (negative) text users */
 	u_int	v_hash;
-	const char *v_tag;			/* u type of underlying data */
 };
 
 #endif /* defined(_KERNEL) || defined(_KVM_VNODE) */


More information about the svn-src-all mailing list