From nobody Mon Jan 03 03:45:25 2022 X-Original-To: dev-commits-src-main@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 95588192B3CA; Mon, 3 Jan 2022 03:45:25 +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 4JS1q929R2z3Kkp; Mon, 3 Jan 2022 03:45:25 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 20D121E3C7; Mon, 3 Jan 2022 03:45:25 +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 2033jP6O052712; Mon, 3 Jan 2022 03:45:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2033jP6T052711; Mon, 3 Jan 2022 03:45:25 GMT (envelope-from git) Date: Mon, 3 Jan 2022 03:45:25 GMT Message-Id: <202201030345.2033jP6T052711@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: 9e891d43f586 - main - unionfs: implement VOP_SET_TEXT/VOP_UNSET_TEXT List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e891d43f586e91541bd61fb12550de296d76fd9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641181525; 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=pPKHatmS8Sas8cuVIzPQV1QN3yzwseivv85+WG0WpIc=; b=cO3or2qAazGzgDGV8gG+uR0pR98voEVod3fjIXoheODYGnyP8vkm4CQKsNuYSnYsUDfCo4 K+kUrQ80+PyrbmpODKpaMseNySkUEdRUwb9/v3ZPHZ3CW8lcog2Njnoi+Ai+9BAywhpwpw f3oAkLUyRRRKz7SE+ShcUQ1ya4TF3hYtSVy0pmNygblzvg4hUopyOLtNldLhYQuwHhGuez NAlgQa3jxksGXnWsAkrntmlRIGgYkMcxtCCBQDOah2gfIvgTvg8/O3XhlCiUdeJm1s5wrV sa6UX5+MIElS4muQ0IqaidP+/Ntj9N9TeGK5n7hnWSpIfP4IQEo9g3e4wi3PVA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641181525; a=rsa-sha256; cv=none; b=ssVokIqGtdbwdNevfZHE691JBxI9Nkhh62/N9UzSiWYb3VGO1BupgAnXjO1bUEsdNXdXgt G0i5OERV2mdAYiGZTblHBs0nzY0LNLbiiFUbEwgjhmiO1JlSLJMv2UkiW3tFlYHBRyHoYN xpOvLl5zYxfzyiooECCkm1T4Wt44KIOficp5HpePtVudHH5nEXOyqrjduhvo2baRiZgUt/ Yp2f3QmU6o8eFhuK47jSQw2c/bkpOtwfm4mf2LhuJXS3k91+QHEQrIQTeSVWiXidJnpQYq l2yt2c+gJi+TNi3rQSP2g/M5xl2epuRI54c78TRf0zP80Q+LKe374PGSXHNw9A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=9e891d43f586e91541bd61fb12550de296d76fd9 commit 9e891d43f586e91541bd61fb12550de296d76fd9 Author: Jason A. Harmening AuthorDate: 2021-12-21 23:51:51 +0000 Commit: Jason A. Harmening CommitDate: 2022-01-03 03:52:58 +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 --- 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 dc02e20f376f..43cf415ca755 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -2671,6 +2671,38 @@ unionfs_vput_pair(struct vop_vput_pair_args *ap) return (res); } +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, @@ -2722,5 +2754,7 @@ struct vop_vector unionfs_vnodeops = { .vop_vptofh = unionfs_vptofh, .vop_add_writecount = unionfs_add_writecount, .vop_vput_pair = unionfs_vput_pair, + .vop_set_text = unionfs_set_text, + .vop_unset_text = unionfs_unset_text, }; VFS_VOP_VECTOR_REGISTER(unionfs_vnodeops);