Module Name: src
Committed By: hannken
Date: Fri Aug 30 12:58:22 UTC 2013
Modified Files:
src/sys/kern: vfs_mount.c
Log Message:
Dounmount() violates the locking protocol for member v_mountedhere.
A vnode lock is required to access or modify this field.
Lock/unlock the vnode when clearing v_mountedhere.
Reviewed by: David Holland <[email protected]>
Should fix PR #48135 (Bad locking for umount)
To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/kern/vfs_mount.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.19 src/sys/kern/vfs_mount.c:1.20
--- src/sys/kern/vfs_mount.c:1.19 Sun Apr 28 21:34:31 2013
+++ src/sys/kern/vfs_mount.c Fri Aug 30 12:58:22 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_mount.c,v 1.19 2013/04/28 21:34:31 mlelstv Exp $ */
+/* $NetBSD: vfs_mount.c,v 1.20 2013/08/30 12:58:22 hannken Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.19 2013/04/28 21:34:31 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.20 2013/08/30 12:58:22 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -878,9 +878,12 @@ dounmount(struct mount *mp, int flags, s
mp->mnt_iflag |= IMNT_GONE;
mutex_exit(&mp->mnt_unmounting);
- mutex_enter(&mountlist_lock);
- if ((coveredvp = mp->mnt_vnodecovered) != NULLVP)
+ if ((coveredvp = mp->mnt_vnodecovered) != NULLVP) {
+ vn_lock(coveredvp, LK_EXCLUSIVE | LK_RETRY);
coveredvp->v_mountedhere = NULL;
+ VOP_UNLOCK(coveredvp);
+ }
+ mutex_enter(&mountlist_lock);
CIRCLEQ_REMOVE(&mountlist, mp, mnt_list);
mutex_exit(&mountlist_lock);
if (TAILQ_FIRST(&mp->mnt_vnodelist) != NULL)