Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern vfs(9): Add missing vnode lock around VOP_CLOSE in ...



details:   https://anonhg.NetBSD.org/src/rev/e38d55c10bce
branches:  trunk
changeset: 364434:e38d55c10bce
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 24 12:59:56 2022 +0000

description:
vfs(9): Add missing vnode lock around VOP_CLOSE in vfs_mountroot.

Maybe vnode_if.c should be taught to KASSERT the vnode lock now that
locks always work.

diffstat:

 sys/kern/vfs_mount.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 122a7a91a27c -r e38d55c10bce sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Thu Mar 24 12:58:56 2022 +0000
+++ b/sys/kern/vfs_mount.c      Thu Mar 24 12:59:56 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_mount.c,v 1.90 2022/03/19 13:50:28 hannken Exp $   */
+/*     $NetBSD: vfs_mount.c,v 1.91 2022/03/24 12:59:56 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.90 2022/03/19 13:50:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.91 2022/03/24 12:59:56 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1246,7 +1246,9 @@
 
 done:
        if (error && device_class(root_device) == DV_DISK) {
+               vn_lock(rootvp, LK_EXCLUSIVE | LK_RETRY);
                VOP_CLOSE(rootvp, FREAD, FSCRED);
+               VOP_UNLOCK(rootvp);
                vrele(rootvp);
        }
        if (error == 0) {



Home | Main Index | Thread Index | Old Index