]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
debugfs: Remove broken no-mount mode
authorAaron Thompson <dev@aaront.org>
Thu, 20 Nov 2025 10:26:33 +0000 (10:26 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Nov 2025 09:45:20 +0000 (10:45 +0100)
debugfs access modes were added in Linux 5.10 (Dec 2020) [1], but the
no-mount mode has behaved effectively the same as the off mode since
Linux 5.12 (Apr 2021) [2]. The only difference is the specific error
code returned by the debugfs_create_* functions, which is -ENOENT in
no-mount mode and -EPERM in off mode.

Given that no-mount hasn't worked for several years with no complaints,
just remove it.

[1] a24c6f7bc923 ("debugfs: Add access restriction option")

[2] bc6de804d36b ("debugfs: be more robust at handling improper input in debugfs_lookup()")
    56348560d495 ("debugfs: do not attempt to create a new file before the filesystem is initalized")

Signed-off-by: Aaron Thompson <dev@aaront.org>
Link: https://patch.msgid.link/20251120102222.18371-3-dev@null.aaront.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/admin-guide/kernel-parameters.txt
fs/debugfs/inode.c
fs/debugfs/internal.h
lib/Kconfig.debug

index 6c42061ca20e581b5192b66c6f25aba38d4f8ff8..847a17efe2899969a03c2ba06e95cf5ee6ad8007 100644 (file)
 
        debugfs=        [KNL,EARLY] This parameter enables what is exposed to
                        userspace and debugfs internal clients.
-                       Format: { on, no-mount, off }
+                       Format: { on, off }
                        on:     All functions are enabled.
-                       no-mount:
-                               Filesystem is not registered but kernel clients can
-                               access APIs and a crashkernel can be used to read
-                               its content. There is nothing to mount.
                        off:    Filesystem is not registered and clients
                                get a -EPERM as result when trying to register files
                                or directories within debugfs.
index b6e401c46b6b7b6312b4dd948979b215a6f5477d..0284b02561955dbc2cc49e0c1f423031e403a189 100644 (file)
@@ -35,7 +35,7 @@
 static struct vfsmount *debugfs_mount;
 static int debugfs_mount_count;
 static bool debugfs_registered;
-static unsigned int debugfs_allow __ro_after_init = DEFAULT_DEBUGFS_ALLOW_BITS;
+static bool debugfs_enabled __ro_after_init = IS_ENABLED(DEBUG_FS_ALLOW_ALL);
 
 /*
  * Don't allow access attributes to be changed whilst the kernel is locked down
@@ -365,7 +365,7 @@ static struct dentry *debugfs_start_creating(const char *name,
        struct dentry *dentry;
        int error;
 
-       if (!(debugfs_allow & DEBUGFS_ALLOW_API))
+       if (!debugfs_enabled)
                return ERR_PTR(-EPERM);
 
        if (!debugfs_initialized())
@@ -885,21 +885,25 @@ static int __init debugfs_kernel(char *str)
 {
        if (str) {
                if (!strcmp(str, "on"))
-                       debugfs_allow = DEBUGFS_ALLOW_API | DEBUGFS_ALLOW_MOUNT;
-               else if (!strcmp(str, "no-mount"))
-                       debugfs_allow = DEBUGFS_ALLOW_API;
+                       debugfs_enabled = true;
                else if (!strcmp(str, "off"))
-                       debugfs_allow = 0;
+                       debugfs_enabled = false;
+               else if (!strcmp(str, "no-mount")) {
+                       pr_notice("debugfs=no-mount is a deprecated alias "
+                                 "for debugfs=off\n");
+                       debugfs_enabled = false;
+               }
        }
 
        return 0;
 }
 early_param("debugfs", debugfs_kernel);
+
 static int __init debugfs_init(void)
 {
        int retval;
 
-       if (!(debugfs_allow & DEBUGFS_ALLOW_MOUNT))
+       if (!debugfs_enabled)
                return -EPERM;
 
        retval = sysfs_create_mount_point(kernel_kobj, "debug");
index 427987f815713e66d509a3c45fde04dab43f1432..c95699b27a561f4d613026af465a28a19d51f8c0 100644 (file)
@@ -55,17 +55,4 @@ enum {
        HAS_IOCTL = 16
 };
 
-#define DEBUGFS_ALLOW_API      BIT(0)
-#define DEBUGFS_ALLOW_MOUNT    BIT(1)
-
-#ifdef CONFIG_DEBUG_FS_ALLOW_ALL
-#define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_MOUNT | DEBUGFS_ALLOW_API)
-#endif
-#ifdef CONFIG_DEBUG_FS_DISALLOW_MOUNT
-#define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_API)
-#endif
-#ifdef CONFIG_DEBUG_FS_ALLOW_NONE
-#define DEFAULT_DEBUGFS_ALLOW_BITS (0)
-#endif
-
 #endif /* _DEBUGFS_INTERNAL_H_ */
index 3034e294d50df55c4003c5fa5df442f59e711bd8..d9ab42916143e13d434709dc29832e55a9cfdb2d 100644 (file)
@@ -679,7 +679,7 @@ choice
        help
          This selects the default access restrictions for debugfs.
          It can be overridden with kernel command line option
-         debugfs=[on,no-mount,off]. The restrictions apply for API access
+         debugfs=[on,off]. The restrictions apply for API access
          and filesystem registration.
 
 config DEBUG_FS_ALLOW_ALL
@@ -688,13 +688,6 @@ config DEBUG_FS_ALLOW_ALL
          No restrictions apply. Both API and filesystem registration
          is on. This is the normal default operation.
 
-config DEBUG_FS_DISALLOW_MOUNT
-       bool "Do not register debugfs as filesystem"
-       help
-         The API is open but filesystem is not loaded. Clients can still do
-         their work and read with debug tools that do not need
-         debugfs filesystem.
-
 config DEBUG_FS_ALLOW_NONE
        bool "No access"
        help