Module Name:    src
Committed By:   hannken
Date:           Mon Mar  6 10:10:43 UTC 2017

Modified Files:
        src/sys/kern: vfs_mount.c

Log Message:
Deny unmounting file systems below layered file systems.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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.48 src/sys/kern/vfs_mount.c:1.49
--- src/sys/kern/vfs_mount.c:1.48	Wed Feb 22 09:50:13 2017
+++ src/sys/kern/vfs_mount.c	Mon Mar  6 10:10:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.48 2017/02/22 09:50:13 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.49 2017/03/06 10:10:43 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.48 2017/02/22 09:50:13 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.49 2017/03/06 10:10:43 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -817,6 +817,7 @@ err_unmounted:
 int
 dounmount(struct mount *mp, int flags, struct lwp *l)
 {
+	struct mount *cmp;
 	vnode_t *coveredvp;
 	int error, async, used_syncer, used_extattr;
 
@@ -827,6 +828,18 @@ dounmount(struct mount *mp, int flags, s
 #endif /* NVERIEXEC > 0 */
 
 	/*
+	 * No unmount below layered mounts.
+	 */
+	mutex_enter(&mountlist_lock);
+	TAILQ_FOREACH(cmp, &mountlist, mnt_list) {
+		if (cmp->mnt_lower == mp) {
+			mutex_exit(&mountlist_lock);
+			return EBUSY;
+		}
+	}
+	mutex_exit(&mountlist_lock);
+
+	/*
 	 * XXX Freeze syncer.  Must do this before locking the
 	 * mount point.  See dounmount() for details.
 	 */

Reply via email to