git: 3f5894cec67c - stable/13 - vn_open_vnode(): fix locking around VOP_CLOSE() on advisory lock error

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 01 May 2023 06:46:10 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f5894cec67cd437bce5b8941ebfb4095d98e01c

commit 3f5894cec67cd437bce5b8941ebfb4095d98e01c
Author:     Olivier Certner <olce.freebsd@certner.fr>
AuthorDate: 2023-04-24 09:36:09 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-05-01 06:45:29 +0000

    vn_open_vnode(): fix locking around VOP_CLOSE() on advisory lock error
    
    (cherry picked from commit 6a5e61401502288ec10629beb28be048c1cce34a)
---
 sys/kern/vfs_vnops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 566b781098ad..215c9d1cc0cc 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -478,8 +478,8 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred,
 			 * If there is no fp, due to kernel-mode open,
 			 * we can call VOP_CLOSE() now.
 			 */
-			if (vp->v_type != VFIFO && (fmode & FWRITE) != 0 &&
-			    !MNT_EXTENDED_SHARED(vp->v_mount) &&
+			if ((vp->v_type == VFIFO || (fmode & FWRITE) != 0 ||
+			    !MNT_EXTENDED_SHARED(vp->v_mount)) &&
 			    VOP_ISLOCKED(vp) != LK_EXCLUSIVE)
 				vn_lock(vp, LK_UPGRADE | LK_RETRY);
 			(void)VOP_CLOSE(vp, fmode & (FREAD | FWRITE | FEXEC),