Skip to contentSkip to conversation

debugfs: Add access restriction option

PATCH Superseded Peter Enderborg 2 participants 2 messages Jun 11, 2020

Subsystems (3)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 debugfs: Add access restriction option

Since debugfs include sensitive information it need to be treated carefully. But it also has many very useful debug functions for userspace. With this option we can have same configuration for system with need of debugfs and a way to turn it off. This gives a extra protection for exposure on systems where user-space services with system access are attacked.

When enabled it is needed a kernel command line parameter to be activated.

It can be on or off, but also internally on but not seen from user-space. This no-fs mode do not register a debugfs as filesystem, but client can register their parts in the internal structures. This data can be readed with a debugger or saved with a crashkernel. When it is off clients get EPERM error when accessing the functions for registering their components.

---
 .../admin-guide/kernel-parameters.txt         | 11 +++++
 fs/debugfs/inode.c                            | 47 +++++++++++++++++++
 lib/Kconfig.debug                             | 10 ++++
 3 files changed, 68 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +11 -0
index 4379c6ac3265..b1c1446aa90d 100644
@@ -827,6 +827,17 @@
 			useful to also enable the page_owner functionality.
 			on: enable the feature
 
+	debugfs=    	[KNL] When CONFIG_DEBUG_FS_RESTRICTED is set, this parameter
+			enable what is exposed to userspace.
+			Format: { on, no_fs, off }
+			on: 	All functions are enabled.
+			no_fs: 	Filesystem is not registered but kernel clients can
+			        access apis and a crashkernel can be used to read
+				it's content. There is noting to mount.
+			off: 	(default) Filesystem is not registered and clients
+			        get a -EPERM as result when trying to register files
+				or directory’s within debugfs.
+
 	debugpat	[X86] Enable PAT debugging
 
 	decnet.addr=	[HW,NET]
fs/debugfs/inode.c +47 -0

91 lines not on this page · raw message

lib/Kconfig.debug +10 -0
index 0217ed126f77..a10b03c20439 100644
@@ -448,6 +448,16 @@ config DEBUG_FS
 
 	  If unsure, say N.
 
+config DEBUG_FS_RESTRICTED
+	bool "Debug Filesystem restricted"
+	depends on DEBUG_FS
+	help
+	  This is an additional restriction for mounting debugfs. It allows
+	  the kernel to have debugfs compiled, but requires that kernel command
+	  line has a debugfs parameter to register as a filesystem.
+
+	  If unsure, say N.
+
 source "lib/Kconfig.kgdb"
 
 source "lib/Kconfig.ubsan"
Signature · 1 line
2.17.1
reviewer
#1 lore raw

Hi,
Please fix typos:

Documentation/admin-guide/kernel-parameters.txt line 831

Quoted 10 lines · Peter Enderborg
Documentation/admin-guide/kernel-parameters.txt +2 -0
index 4379c6ac3265..b1c1446aa90d 100644
@@ -827,6 +827,17 @@
 			useful to also enable the page_owner functionality.
 			on: enable the feature
 
+	debugfs=    	[KNL] When CONFIG_DEBUG_FS_RESTRICTED is set, this parameter
+			enable what is exposed to userspace.

enables

Documentation/admin-guide/kernel-parameters.txt line 835

Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +4 -0
+			Format: { on, no_fs, off }
+			on: 	All functions are enabled.
+			no_fs: 	Filesystem is not registered but kernel clients can
+			        access apis and a crashkernel can be used to read

APIs

Documentation/admin-guide/kernel-parameters.txt line 836

Quoted 1 line
Documentation/admin-guide/kernel-parameters.txt +1 -0
+				it's content. There is noting to mount.

its nothing

Documentation/admin-guide/kernel-parameters.txt line 839

Quoted 3 lines
Documentation/admin-guide/kernel-parameters.txt +3 -0
+			off: 	(default) Filesystem is not registered and clients
+			        get a -EPERM as result when trying to register files
+				or directory’s within debugfs.

or directories

Documentation/admin-guide/kernel-parameters.txt line 843

Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +1 -0
+
 	debugpat	[X86] Enable PAT debugging
 
 	decnet.addr=	[HW,NET]

thanks.

Signature · 1 line
~Randy