Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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] 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>

authored by

Aaron Thompson and committed by
Greg Kroah-Hartman
f2788094 3ae94a55

+13 -33
+1 -5
Documentation/admin-guide/kernel-parameters.txt
··· 1113 1113 1114 1114 debugfs= [KNL,EARLY] This parameter enables what is exposed to 1115 1115 userspace and debugfs internal clients. 1116 - Format: { on, no-mount, off } 1116 + Format: { on, off } 1117 1117 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. 1122 1118 off: Filesystem is not registered and clients 1123 1119 get a -EPERM as result when trying to register files 1124 1120 or directories within debugfs.
+11 -7
fs/debugfs/inode.c
··· 35 35 static struct vfsmount *debugfs_mount; 36 36 static int debugfs_mount_count; 37 37 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); 39 39 40 40 /* 41 41 * Don't allow access attributes to be changed whilst the kernel is locked down ··· 365 365 struct dentry *dentry; 366 366 int error; 367 367 368 - if (!(debugfs_allow & DEBUGFS_ALLOW_API)) 368 + if (!debugfs_enabled) 369 369 return ERR_PTR(-EPERM); 370 370 371 371 if (!debugfs_initialized()) ··· 885 885 { 886 886 if (str) { 887 887 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; 891 889 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 + } 893 896 } 894 897 895 898 return 0; 896 899 } 897 900 early_param("debugfs", debugfs_kernel); 901 + 898 902 static int __init debugfs_init(void) 899 903 { 900 904 int retval; 901 905 902 - if (!(debugfs_allow & DEBUGFS_ALLOW_MOUNT)) 906 + if (!debugfs_enabled) 903 907 return -EPERM; 904 908 905 909 retval = sysfs_create_mount_point(kernel_kobj, "debug");
-13
fs/debugfs/internal.h
··· 55 55 HAS_IOCTL = 16 56 56 }; 57 57 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 - 71 58 #endif /* _DEBUGFS_INTERNAL_H_ */
+1 -8
lib/Kconfig.debug
··· 679 679 help 680 680 This selects the default access restrictions for debugfs. 681 681 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 683 683 and filesystem registration. 684 684 685 685 config DEBUG_FS_ALLOW_ALL ··· 687 687 help 688 688 No restrictions apply. Both API and filesystem registration 689 689 is on. This is the normal default operation. 690 - 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 690 698 691 config DEBUG_FS_ALLOW_NONE 699 692 bool "No access"