From owner-svn-src-head@freebsd.org Tue Jan 7 04:29:35 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9F2A01FAC00; Tue, 7 Jan 2020 04:29:35 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47sKCg3nBFz4fHR; Tue, 7 Jan 2020 04:29:35 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6477F215F9; Tue, 7 Jan 2020 04:29:35 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0074TZmf032434; Tue, 7 Jan 2020 04:29:35 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0074TYbQ032431; Tue, 7 Jan 2020 04:29:34 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202001070429.0074TYbQ032431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Tue, 7 Jan 2020 04:29:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356432 - in head/sys: kern security/mac_veriexec sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern security/mac_veriexec sys X-SVN-Commit-Revision: 356432 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2020 04:29:35 -0000 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) */