git: 6a5e61401502 - main - vn_open_vnode(): fix locking around VOP_CLOSE() on advisory lock error
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 24 Apr 2023 22:39:31 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=6a5e61401502288ec10629beb28be048c1cce34a
commit 6a5e61401502288ec10629beb28be048c1cce34a
Author: Olivier Certner <olce.freebsd@certner.fr>
AuthorDate: 2023-04-24 09:36:09 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-04-24 22:37:58 +0000
vn_open_vnode(): fix locking around VOP_CLOSE() on advisory lock error
In the case of a FIFO or if trying to open a file for writing, an
exclusive lock is necessary.
Reviewed by: kib
MFC after: 1 week
---
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 52242cce0692..e42d17ec2478 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -483,8 +483,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),