Skip to content

Commit f278809

Browse files
dev-aaront-orggregkh
authored andcommitted
debugfs: Remove broken no-mount mode
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] a24c6f7 ("debugfs: Add access restriction option") [2] bc6de80 ("debugfs: be more robust at handling improper input in debugfs_lookup()") 5634856 ("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>
1 parent 3ae94a5 commit f278809

4 files changed

Lines changed: 13 additions & 33 deletions

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,12 +1113,8 @@
11131113

11141114
debugfs= [KNL,EARLY] This parameter enables what is exposed to
11151115
userspace and debugfs internal clients.
1116-
Format: { on, no-mount, off }
1116+
Format: { on, off }
11171117
on: All functions are enabled.
1118-
no-mount:
1119-
Filesystem is not registered but kernel clients can
1120-
access APIs and a crashkernel can be used to read
1121-
its content. There is nothing to mount.
11221118
off: Filesystem is not registered and clients
11231119
get a -EPERM as result when trying to register files
11241120
or directories within debugfs.

fs/debugfs/inode.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
static struct vfsmount *debugfs_mount;
3636
static int debugfs_mount_count;
3737
static bool debugfs_registered;
38-
static unsigned int debugfs_allow __ro_after_init = DEFAULT_DEBUGFS_ALLOW_BITS;
38+
static bool debugfs_enabled __ro_after_init = IS_ENABLED(DEBUG_FS_ALLOW_ALL);
3939

4040
/*
4141
* 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,
365365
struct dentry *dentry;
366366
int error;
367367

368-
if (!(debugfs_allow & DEBUGFS_ALLOW_API))
368+
if (!debugfs_enabled)
369369
return ERR_PTR(-EPERM);
370370

371371
if (!debugfs_initialized())
@@ -885,21 +885,25 @@ static int __init debugfs_kernel(char *str)
885885
{
886886
if (str) {
887887
if (!strcmp(str, "on"))
888-
debugfs_allow = DEBUGFS_ALLOW_API | DEBUGFS_ALLOW_MOUNT;
889-
else if (!strcmp(str, "no-mount"))
890-
debugfs_allow = DEBUGFS_ALLOW_API;
888+
debugfs_enabled = true;
891889
else if (!strcmp(str, "off"))
892-
debugfs_allow = 0;
890+
debugfs_enabled = false;
891+
else if (!strcmp(str, "no-mount")) {
892+
pr_notice("debugfs=no-mount is a deprecated alias "
893+
"for debugfs=off\n");
894+
debugfs_enabled = false;
895+
}
893896
}
894897

895898
return 0;
896899
}
897900
early_param("debugfs", debugfs_kernel);
901+
898902
static int __init debugfs_init(void)
899903
{
900904
int retval;
901905

902-
if (!(debugfs_allow & DEBUGFS_ALLOW_MOUNT))
906+
if (!debugfs_enabled)
903907
return -EPERM;
904908

905909
retval = sysfs_create_mount_point(kernel_kobj, "debug");

fs/debugfs/internal.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,4 @@ enum {
5555
HAS_IOCTL = 16
5656
};
5757

58-
#define DEBUGFS_ALLOW_API BIT(0)
59-
#define DEBUGFS_ALLOW_MOUNT BIT(1)
60-
61-
#ifdef CONFIG_DEBUG_FS_ALLOW_ALL
62-
#define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_MOUNT | DEBUGFS_ALLOW_API)
63-
#endif
64-
#ifdef CONFIG_DEBUG_FS_DISALLOW_MOUNT
65-
#define DEFAULT_DEBUGFS_ALLOW_BITS (DEBUGFS_ALLOW_API)
66-
#endif
67-
#ifdef CONFIG_DEBUG_FS_ALLOW_NONE
68-
#define DEFAULT_DEBUGFS_ALLOW_BITS (0)
69-
#endif
70-
7158
#endif /* _DEBUGFS_INTERNAL_H_ */

lib/Kconfig.debug

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ choice
679679
help
680680
This selects the default access restrictions for debugfs.
681681
It can be overridden with kernel command line option
682-
debugfs=[on,no-mount,off]. The restrictions apply for API access
682+
debugfs=[on,off]. The restrictions apply for API access
683683
and filesystem registration.
684684

685685
config DEBUG_FS_ALLOW_ALL
@@ -688,13 +688,6 @@ config DEBUG_FS_ALLOW_ALL
688688
No restrictions apply. Both API and filesystem registration
689689
is on. This is the normal default operation.
690690

691-
config DEBUG_FS_DISALLOW_MOUNT
692-
bool "Do not register debugfs as filesystem"
693-
help
694-
The API is open but filesystem is not loaded. Clients can still do
695-
their work and read with debug tools that do not need
696-
debugfs filesystem.
697-
698691
config DEBUG_FS_ALLOW_NONE
699692
bool "No access"
700693
help

0 commit comments

Comments
 (0)