Module Name: src
Committed By: hannken
Date: Thu Nov 10 10:55:01 UTC 2022
Modified Files:
src/sys/kern: vfs_mount.c
Log Message:
If built with DEBUG Limit the depth of file system stack so kernel sanitizers
may stress mount/unmount without exhausting the kernel stack.
To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 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.99 src/sys/kern/vfs_mount.c:1.100
--- src/sys/kern/vfs_mount.c:1.99 Fri Nov 4 11:20:39 2022
+++ src/sys/kern/vfs_mount.c Thu Nov 10 10:55:00 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_mount.c,v 1.99 2022/11/04 11:20:39 hannken Exp $ */
+/* $NetBSD: vfs_mount.c,v 1.100 2022/11/10 10:55:00 hannken 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.99 2022/11/04 11:20:39 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.100 2022/11/10 10:55:00 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -403,6 +403,20 @@ vfs_set_lowermount(struct mount *mp, str
struct mount *oldlowermp;
int error;
+#ifdef DEBUG
+ /*
+ * Limit the depth of file system stack so kernel sanitizers
+ * may stress mount/unmount without exhausting the kernel stack.
+ */
+ int depth;
+ struct mount *mp2;
+
+ for (depth = 0, mp2 = lowermp; mp2; depth++, mp2 = mp2->mnt_lower) {
+ if (depth == 23)
+ return EINVAL;
+ }
+#endif
+
if (lowermp) {
error = vfs_busy(lowermp);
if (error)