From nobody Mon Jan 09 15:01:44 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NrHGJ3sNlz2sG09; Mon, 9 Jan 2023 15:01:44 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NrHGJ3Lcmz3s61; Mon, 9 Jan 2023 15:01:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673276504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kZS3eC5qTcGq829qZ4ms6vqh5Zrjx6i3f/LkoncITSU=; b=YZpvEgsYmgI2WYPdkj5BqjRHnf2/Nd2mPlSce4VqP77LPT49XHJQqGRhw6XwzVxeWaYMdq UCCf3rK4Wln+nK5jJ82xR7Sf8AXCJNGUKZ5hvWkuxR9bxhhz2tR93rP+OiMLpwsLOEh2yX 88Q0WtSKQ3MtnhCulW7GVCzew7NB3WS2M1pkcE+Kx9eH/43JU0TTOKQVvYdBFVHjj2Yn24 F7xfCZxFtGl3Qm/jVA4HKIqhQzOa1U24eLdgei7oTwXziXSo6Wf5zlzSYZ3zTWD5UwO9vQ nCXrJ/QYetU7KVopElC3sIWsdJ2f6GyjPIL/IdPC9ilfPf6cFjWcvj30EGh9xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673276504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kZS3eC5qTcGq829qZ4ms6vqh5Zrjx6i3f/LkoncITSU=; b=lnHcEzZ9dzn6K7+xBtwvlSMty/72Bq4k5OgpTyN3ymcnUqnj/PW5LLLtfWKG7xsbb8+QiA G6ELDgluB2dPwjRXQTZ2eIGWfto09jsK6i6oYZp0rMHm+c0G8QKdK4tmkU+C5i14xmT/tD JeGhKZstI6+X2WLYTnCQYd5XJZW4yIyQY2qBC9vybSx6Qer1DF66LePTVYNqml0CUZEMYS bblQikIB2iJSN/qU1L11btqqfkxkPe9NFIADuKoAr8FVoWqGzulX8IDS2Ml0nDw7H0/2Hq Pe2rKW3cBrro1M1DL1C7/FgB3OOJIaE70VfO6h6uFt4j9RPaEsF/fJF8aV1Uxg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673276504; a=rsa-sha256; cv=none; b=sJ/l+YT97ZM/ZlX4CKDF/QmDB0rBoAF6s9OfnCvgoEEDRVaxBvyG6f9kfKJgKuwgdXtW4J /dsqh2TMOVwI6tNuMHjVK9YqTXvnYIQi6sb0tDrCgU3W7ZGa/HiNtcI5dH+h4lYTlu1+Sb WKmE2Djd50A7zlxfccGJDuc96PE/ky0iDhZrav+/TxA6jT38RXCHEXqXaRU0DYI3jtc7hk 2zC44pGwJwYHpnroRiUp9FrEW9nWP0ZHtnxbQfBvQ8VsMJ4eacnxp1mrgAIo3+2L+JkyVa 4TA7EwP3W0DiTdbIXqxf1q3nEsKPjdPpFUBZWpBSHU+f0IEU8Eev4QmwMgKsvg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NrHGJ2QkPzXxs; Mon, 9 Jan 2023 15:01:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 309F1ilK033430; Mon, 9 Jan 2023 15:01:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 309F1iaQ033429; Mon, 9 Jan 2023 15:01:44 GMT (envelope-from git) Date: Mon, 9 Jan 2023 15:01:44 GMT Message-Id: <202301091501.309F1iaQ033429@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 04f8674aa748 - stable/13 - unionfs: implement VOP_SET_TEXT/VOP_UNSET_TEXT List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 04f8674aa7486ec2d73d60c2247fe5e33b5399c5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=04f8674aa7486ec2d73d60c2247fe5e33b5399c5 commit 04f8674aa7486ec2d73d60c2247fe5e33b5399c5 Author: Jason A. Harmening AuthorDate: 2021-12-21 23:51:51 +0000 Commit: Ed Maste CommitDate: 2023-01-09 02:31:15 +0000 unionfs: implement VOP_SET_TEXT/VOP_UNSET_TEXT The implementation simply passes the text ref to the appropriate underlying vnode. Without this, the default [un]set_text implementation will only manage the text ref on the unionfs vnode, causing it to be out of sync with the underlying filesystems and potentially allowing corruption of executable file contents. On INVARIANTS kernels, it also readily produces a panic on process termination because the VM object representing the executable mapping is backed by the underlying vnode, not the unionfs vnode. PR: 251342 Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D33611 (cherry picked from commit 9e891d43f586e91541bd61fb12550de296d76fd9) --- sys/fs/unionfs/union_vnops.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 09fbccb3d7ff..331235ab93d5 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -2503,6 +2503,38 @@ unionfs_add_writecount(struct vop_add_writecount_args *ap) return (error); } +static int +unionfs_set_text(struct vop_set_text_args *ap) +{ + struct vnode *tvp; + struct unionfs_node *unp; + int error; + + /* + * We assume text refs are managed against lvp/uvp through the + * executable mapping backed by its VM object. We therefore don't + * need to track leased text refs in the case of a forcible unmount. + */ + unp = VTOUNIONFS(ap->a_vp); + ASSERT_VOP_LOCKED(ap->a_vp, __func__); + tvp = unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp; + error = VOP_SET_TEXT(tvp); + return (error); +} + +static int +unionfs_unset_text(struct vop_unset_text_args *ap) +{ + struct vnode *tvp; + struct unionfs_node *unp; + + ASSERT_VOP_LOCKED(ap->a_vp, __func__); + unp = VTOUNIONFS(ap->a_vp); + tvp = unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp; + VOP_UNSET_TEXT_CHECKED(tvp); + return (0); +} + struct vop_vector unionfs_vnodeops = { .vop_default = &default_vnodeops, @@ -2553,5 +2585,7 @@ struct vop_vector unionfs_vnodeops = { .vop_write = unionfs_write, .vop_vptofh = unionfs_vptofh, .vop_add_writecount = unionfs_add_writecount, + .vop_set_text = unionfs_set_text, + .vop_unset_text = unionfs_unset_text, }; VFS_VOP_VECTOR_REGISTER(unionfs_vnodeops);