From: Bradley Morgan <hidden> Date: 2026-08-18 01:49:22
This enabled knob is a disgusting terrible hack. It has rolled its
own read/write pair since 2007, writing '1' or '0' into a three byte
buffer by hand just to print a single character, with an XXX comment
begging debugfs for write callbacks on bool files.
DEFINE_DEBUGFS_ATTRIBUTE showed up in 2016 and does exactly that, so
the disgusting terrible hack has outlived its excuse for nine years.
Kill it, and the stale comment with it.
The behavior does not change, except the write only accepts 0/1 now
instead of y/n/on/off, and nothing uses anything else.
---
kernel/kprobes.c | 43 +++++++++----------------------------------
1 file changed, 9 insertions(+), 34 deletions(-)
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The 'enabled' debugfs file is created using `debugfs_create_file()` instead of `debugfs_create_file_unsafe()` with a `DEFINE_DEBUGFS_ATTRIBUTE` struct, leading to redundant proxying and overhead.
--
--- Patch [1]: [PATCH] kprobes: use DEFINE_DEBUGFS_ATTRIBUTE for the enabled knob ---
commit f5babbd146ccf4194f28506d04f5cbfb2c40150a
Author: Bradley Morgan [off-list ref]
kprobes: use DEFINE_DEBUGFS_ATTRIBUTE for the enabled knob
This commit replaces the custom read/write handlers for the debugfs enabled
file with the standard DEFINE_DEBUGFS_ATTRIBUTE macro. It simplifies the
implementation and accepts integer inputs rather than characters.
[Severity: Low]
Will this lead to double-proxying for the debugfs file?
Since DEFINE_DEBUGFS_ATTRIBUTE natively provides debugfs_attr_read and
debugfs_attr_write operations that already include debugfs_file_get() and
debugfs_file_put() protection, passing fops_kp to debugfs_create_file()
in debugfs_kprobe_init() will cause the debugfs core to wrap it again:
kernel/kprobes.c:debugfs_kprobe_init() {
...
debugfs_create_file("enabled", 0600, dir, NULL, &fops_kp);
...
}
Could this use debugfs_create_file_unsafe() instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260818014920.23870-1-include@grrlz.net?part=1
From: Bradley Morgan <hidden> Date: 2026-08-18 15:17:28
On 18 August 2026 03:01:18 BST, sashiko-bot@kernel.org wrote:
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
- [Low] The 'enabled' debugfs file is created using `debugfs_create_file()` instead of `debugfs_create_file_unsafe()` with a `DEFINE_DEBUGFS_ATTRIBUTE` struct, leading to redundant proxying and overhead.
+akpm@linux-foundation.org
I hate sashiko so damn much, best to wait for review!
quoted hunk
--
--- Patch [1]: [PATCH] kprobes: use DEFINE_DEBUGFS_ATTRIBUTE for the enabled knob ---
commit f5babbd146ccf4194f28506d04f5cbfb2c40150a
Author: Bradley Morgan [off-list ref]
kprobes: use DEFINE_DEBUGFS_ATTRIBUTE for the enabled knob
This commit replaces the custom read/write handlers for the debugfs
enabled
file with the standard DEFINE_DEBUGFS_ATTRIBUTE macro. It simplifies the
implementation and accepts integer inputs rather than characters.
[Severity: Low]
Will this lead to double-proxying for the debugfs file?
Since DEFINE_DEBUGFS_ATTRIBUTE natively provides debugfs_attr_read and
debugfs_attr_write operations that already include debugfs_file_get() and
debugfs_file_put() protection, passing fops_kp to debugfs_create_file()
in debugfs_kprobe_init() will cause the debugfs core to wrap it again:
kernel/kprobes.c:debugfs_kprobe_init() {
...
debugfs_create_file("enabled", 0600, dir, NULL, &fops_kp);
...
}
Could this use debugfs_create_file_unsafe() instead?
From: Steven Rostedt <rostedt@goodmis.org> Date: 2026-08-18 16:10:38
On Tue, 18 Aug 2026 16:17:20 +0100
Bradley Morgan [off-list ref] wrote:
On 18 August 2026 03:01:18 BST, sashiko-bot@kernel.org wrote:
quoted
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
- [Low] The 'enabled' debugfs file is created using `debugfs_create_file()` instead of `debugfs_create_file_unsafe()` with a `DEFINE_DEBUGFS_ATTRIBUTE` struct, leading to redundant proxying and overhead.
+akpm@linux-foundation.org
I hate sashiko so damn much, best to wait for review!
It is even saying this is of "low priority". That means it's more of an "FYI".
quoted
Will this lead to double-proxying for the debugfs file?
Since DEFINE_DEBUGFS_ATTRIBUTE natively provides debugfs_attr_read and
debugfs_attr_write operations that already include debugfs_file_get() and
debugfs_file_put() protection, passing fops_kp to debugfs_create_file()
in debugfs_kprobe_init() will cause the debugfs core to wrap it again:
kernel/kprobes.c:debugfs_kprobe_init() {
...
debugfs_create_file("enabled", 0600, dir, NULL, &fops_kp);
...
}
Could this use debugfs_create_file_unsafe() instead?
As this isn't a critical path, I don't think we really care here if
it's wrapped or not. But it's nice to know that it is.
Anyway, I'll let others review this, but it looks fine to me.
-- Steve
From: Bradley Morgan <hidden> Date: 2026-08-18 16:41:17
On 18 August 2026 17:10:25 BST, Steven Rostedt [off-list ref] wrote:
On Tue, 18 Aug 2026 16:17:20 +0100
Bradley Morgan [off-list ref] wrote:
quoted
On 18 August 2026 03:01:18 BST, sashiko-bot@kernel.org wrote:
quoted
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
- [Low] The 'enabled' debugfs file is created using
`debugfs_create_file()` instead of `debugfs_create_file_unsafe()` with a
`DEFINE_DEBUGFS_ATTRIBUTE` struct, leading to redundant proxying and
overhead.
quoted
+akpm@linux-foundation.org
I hate sashiko so damn much, best to wait for review!
It is even saying this is of "low priority". That means it's more of an
"FYI".
quoted
quoted
Will this lead to double-proxying for the debugfs file?
Since DEFINE_DEBUGFS_ATTRIBUTE natively provides debugfs_attr_read and
debugfs_attr_write operations that already include debugfs_file_get()
and
quoted
quoted
debugfs_file_put() protection, passing fops_kp to debugfs_create_file()
in debugfs_kprobe_init() will cause the debugfs core to wrap it again:
kernel/kprobes.c:debugfs_kprobe_init() {
...
debugfs_create_file("enabled", 0600, dir, NULL, &fops_kp);
...
}
Could this use debugfs_create_file_unsafe() instead?
As this isn't a critical path, I don't think we really care here if
it's wrapped or not. But it's nice to know that it is.
Anyway, I'll let others review this, but it looks fine to me.
-- Steve
the fix is a couple of years in the making, heh
Thanks!
On Tue, 18 Aug 2026 01:49:20 +0000
Bradley Morgan [off-list ref] wrote:
This enabled knob is a disgusting terrible hack. It has rolled its
own read/write pair since 2007, writing '1' or '0' into a three byte
buffer by hand just to print a single character, with an XXX comment
begging debugfs for write callbacks on bool files.
DEFINE_DEBUGFS_ATTRIBUTE showed up in 2016 and does exactly that, so
the disgusting terrible hack has outlived its excuse for nine years.
Kill it, and the stale comment with it.
Hm, OK, but please calm down. Just describe the technical reason here.
The behavior does not change, except the write only accepts 0/1 now
instead of y/n/on/off, and nothing uses anything else.
I think this comment is needed.
Please add Signed-off-by.
The code looks good to me.
Thanks,
From: Bradley Morgan <hidden> Date: 2026-08-18 22:56:41
On 18 August 2026 23:52:21 BST, Masami Hiramatsu [off-list ref]
wrote:
On Tue, 18 Aug 2026 01:49:20 +0000
Bradley Morgan [off-list ref] wrote:
quoted
This enabled knob is a disgusting terrible hack. It has rolled its
own read/write pair since 2007, writing '1' or '0' into a three byte
buffer by hand just to print a single character, with an XXX comment
begging debugfs for write callbacks on bool files.
DEFINE_DEBUGFS_ATTRIBUTE showed up in 2016 and does exactly that, so
the disgusting terrible hack has outlived its excuse for nine years.
Kill it, and the stale comment with it.
Hm, OK, but please calm down. Just describe the technical reason here.
quoted
The behavior does not change, except the write only accepts 0/1 now
instead of y/n/on/off, and nothing uses anything else.
I think this comment is needed.
What do you suggest?
I'm saying
/* Let's kill this hack */
(I love using the word hack!)