Source-Changes-HG archive

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

[src/trunk]: src/sys/kern If built with DEBUG Limit the depth of file system ...



details:   https://anonhg.NetBSD.org/src/rev/b83bb0d61451
branches:  trunk
changeset: 372301:b83bb0d61451
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Nov 10 10:55:00 2022 +0000

description:
If built with DEBUG Limit the depth of file system stack so kernel sanitizers
may stress mount/unmount without exhausting the kernel stack.

diffstat:

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

diffs (39 lines):

diff -r cd3fc7d8eda2 -r b83bb0d61451 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Thu Nov 10 10:54:14 2022 +0000
+++ b/sys/kern/vfs_mount.c      Thu Nov 10 10:55:00 2022 +0000
@@ -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 @@
        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)



Home | Main Index | Thread Index | Old Index