From nobody Wed Oct 19 03:04:38 2022 X-Original-To: dev-commits-src-all@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 4MsbDk3PP7z4gXlT; Wed, 19 Oct 2022 03:04:38 +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 4MsbDk2mDWz3b5h; Wed, 19 Oct 2022 03:04:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666148678; 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=R/Sql8BbgT8d9d2bBQ73P7Xst9u9HHrc/TLHYmEM0kM=; b=JvoShovvpW891c0B464FYkGcLBaLH2ZhgXf9X+vrEC39pXrN2Mg71A+W214w2kfBYzOzKI /+J3WNXlBvMDQjw/vUj7J2LWB99L6JK8jzV358g6JaTWaJzHeRZwoB7i7wqcqh1ifE0Nz3 RhnoyRRoSkW1DmyNHal+K86K0WNzhvl5BofOAEPkYyfsFK2hrgxiZMH4RO+Wb5aUuOzLfw 9cUGzkfZj6TUjiwIo+PFW8/sppktTbEemPni/9QMb3ibUkNsw5RCyikwyeK5sDCpUfmOSy W2MH1gUPCbZ9oMIgTFg51Yek8EeAJmVbBoEortaWug+1jfbdYBn1G+l2wGzMdQ== 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 4MsbDk1qPXzNxq; Wed, 19 Oct 2022 03:04:38 +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 29J34c8E067552; Wed, 19 Oct 2022 03:04:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29J34c5a067551; Wed, 19 Oct 2022 03:04:38 GMT (envelope-from git) Date: Wed, 19 Oct 2022 03:04:38 GMT Message-Id: <202210190304.29J34c5a067551@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: c76461e064b6 - stable/12 - Fix a vnode locking bug in fuse_vnop_advlock. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: c76461e064b675c8edd3b1d9bb917905a885a860 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666148678; 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=R/Sql8BbgT8d9d2bBQ73P7Xst9u9HHrc/TLHYmEM0kM=; b=dkIMyYgNFyZPmehj8H5QhjmkcIHiqpWTV/wiZV1eo4w7y4y0BC7f2Ee8NSw8NpoH07V1nz 4ygJO+x7vVAb8OT9rasqvWpaLqSM6dJhuXDleRLgSYhoPSk9Sfu/xKsWEOnMFsYjJBc8rN 8sAw7d3c6+DT4VfbCG7eYMe12DFJXlPGjbxAS0QrR94gQxifcb/L1IR8DP5pRLiXODURIP x4V9OZP9wUN4/jXU74U0adhYQjLDhhapzaim4sjiEO5Nyu7EMvxn39O+PLB1jSipbaRerw lIO2hKhnQERcMWHiQY+ZJNPKJ/od4bOlVNC4oKEiqVtlMlgjS8SeK1cKLLav6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666148678; a=rsa-sha256; cv=none; b=S7rqmL5C2oagcq3ltjs0RK67ngt0LPZIURpVUn0WryGQbDHtktnXxs5OeKBJi3Mo/IqoO2 //Y3Dwk2+7+a6UxLRKrs4xOvMThPwuKbEonQFRYw2CUFtaN8tInUrIcNMVwGq36lkhj+8w 906bmVF3Gx9DxIfXLEutf7sUMqrX5MYcTVpJc+CEMRe2Qfr6jNVO+9pFK5F811GHgWK8Rp SuflsV4FTYi6hA31IonFdGzB3bckQFj04K4lr5YLzTZx+dFmOgZ++oBkZ12YtKnsEoLvs1 rnXzKXud1J7kTDdorEetFHsVy3iSO+T10ZtrFJ1viWWo8pgVo2b4aW7odl5IVQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=c76461e064b675c8edd3b1d9bb917905a885a860 commit c76461e064b675c8edd3b1d9bb917905a885a860 Author: Alan Somers AuthorDate: 2020-12-30 23:50:35 +0000 Commit: Alan Somers CommitDate: 2022-10-19 02:58:01 +0000 Fix a vnode locking bug in fuse_vnop_advlock. Must lock the vnode before accessing the fufh table. Also, check for invalid parameters earlier. Bug introduced by r346170. MFC after: 2 weeks Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D27936 (cherry picked from commit 542711e52079f65647ac1daadf0c9e74cb221f3e) --- sys/fs/fuse/fuse_vnops.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index d28c869e5248..311ea8a049ef 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -395,18 +395,6 @@ fuse_vnop_advlock(struct vop_advlock_args *ap) return ENXIO; } - if (!(dataflags & FSESS_POSIX_LOCKS)) - return vop_stdadvlock(ap); - /* FUSE doesn't properly support flock until protocol 7.17 */ - if (flags & F_FLOCK) - return vop_stdadvlock(ap); - - err = fuse_filehandle_get_anyflags(vp, &fufh, cred, pid); - if (err) - return err; - - fdisp_init(&fdi, sizeof(*fli)); - switch(ap->a_op) { case F_GETLK: op = FUSE_GETLK; @@ -424,6 +412,20 @@ fuse_vnop_advlock(struct vop_advlock_args *ap) return EINVAL; } + if (!(dataflags & FSESS_POSIX_LOCKS)) + return vop_stdadvlock(ap); + /* FUSE doesn't properly support flock until protocol 7.17 */ + if (flags & F_FLOCK) + return vop_stdadvlock(ap); + + vn_lock(vp, LK_SHARED | LK_RETRY); + + err = fuse_filehandle_get_anyflags(vp, &fufh, cred, pid); + if (err) + goto out; + + fdisp_init(&fdi, sizeof(*fli)); + fdisp_make_vp(&fdi, op, vp, td, cred); fli = fdi.indata; fli->fh = fufh->fh_id; @@ -453,6 +455,8 @@ fuse_vnop_advlock(struct vop_advlock_args *ap) } } +out: + VOP_UNLOCK(vp); return err; }