kprobes: use DEFINE_DEBUGFS_ATTRIBUTE for the enabled knob
PATCH v2 1/1 kprobes: use DEFINE_DEBUGFS_ATTRIBUTE for the enabled knob
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.
---
Changes since v1:
- Added the missing Signed-off-by, sorry.
kernel/kprobes.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-)
kernel/kprobes.c +9 -34
@@ -3013,47 +3013,22 @@ static int disarm_all_kprobes(void)return ret; } -/* -* XXX: The debugfs bool file interface doesn't allow for callbacks -* when the bool state is switched. We can reuse that facility when -* available -*/ -static ssize_t read_enabled_file_bool (struct file *file, -char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_set (void *data,u64 val) { -char buf[3 ]; +if (val) +return arm_all_kprobes (); -if (!kprobes_all_disarmed) - buf[0 ] ='1' ; -else - buf[0 ] ='0' ; - buf[1 ] ='\n' ; - buf[2 ] =0x00 ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); +return disarm_all_kprobes (); } -static ssize_t write_enabled_file_bool (struct file *file, -const char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_get (void *data,u64 *val) { -bool enable; -int ret; - - ret =kstrtobool_from_user (user_buf, count, &enable); -if (ret) -return ret; - - ret = enable ?arm_all_kprobes () :disarm_all_kprobes (); -if (ret) -return ret; - -return count; + *val = !kprobes_all_disarmed; +return 0 ; } -static const struct file_operations fops_kp = { - .read = read_enabled_file_bool, - .write = write_enabled_file_bool, - .llseek = default_llseek, -}; +DEFINE_DEBUGFS_ATTRIBUTE (fops_kp, kprobes_enabled_get, + kprobes_enabled_set,"%llu\n" );static int __init debugfs_kprobe_init (void ) {
Signature · 1 line
2.47.3
Masami Hiramatsu (Google)
maintainerQuoted 7 lines · On Tue, 18 Aug 2026 01:53:18 +0000 Bradley Morgan <[email protected]> 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_ATTRIBUTEshowed 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.
In other words, does this mean something like the following?
This "enable" knob implemented custom read/write logic, manually writing "1" or "0" to a 3-byte buffer solely to output a single character. As suggested by comments calling for debugfs to support write callbacks for boolean files, using DEFINE_DEBUGFS_ATTRIBUTE eliminates the need for these callbacks.
Thanks,
Quoted 76 lines
The behavior does not change, except the write only accepts 0/1 now instead of y/n/on/off, and nothing uses anything else.
Signed-off-by Bradley Morgan <[email protected]>---
Changes since v1:
- Added the missing Signed-off-by, sorry.kernel/kprobes.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-)kernel/kprobes.c +9
-34@@ -3013,47 +3013,22 @@ static int disarm_all_kprobes(void)return ret; } -/* -* XXX: The debugfs bool file interface doesn't allow for callbacks -* when the bool state is switched. We can reuse that facility when -* available -*/ -static ssize_t read_enabled_file_bool (struct file *file, -char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_set (void *data,u64 val) { -char buf[3 ]; +if (val) +return arm_all_kprobes (); -if (!kprobes_all_disarmed) - buf[0 ] ='1' ; -else - buf[0 ] ='0' ; - buf[1 ] ='\n' ; - buf[2 ] =0x00 ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); +return disarm_all_kprobes (); } -static ssize_t write_enabled_file_bool (struct file *file, -const char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_get (void *data,u64 *val) { -bool enable; -int ret; - - ret =kstrtobool_from_user (user_buf, count, &enable); -if (ret) -return ret; - - ret = enable ?arm_all_kprobes () :disarm_all_kprobes (); -if (ret) -return ret; - -return count; + *val = !kprobes_all_disarmed; +return 0 ; } -static const struct file_operations fops_kp = { - .read = read_enabled_file_bool, - .write = write_enabled_file_bool, - .llseek = default_llseek, -}; +DEFINE_DEBUGFS_ATTRIBUTE (fops_kp, kprobes_enabled_get, + kprobes_enabled_set,"%llu\n" );static int __init debugfs_kprobe_init (void ) {Signature · 1 line
2.47.3
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 11 lines · Masami Hiramatsu
Quoted 7 lines · On Tue, 18 Aug 2026 01:53:18 +0000 Bradley Morgan <[email protected]> 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_ATTRIBUTEshowed 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.
Quoted 8 lines
In other words, does this mean something like the following?
This "enable" knob implemented custom read/write logic, manually writing "1" or "0" to a 3-byte buffer solely to output a single character. As suggested by comments calling for
debugfsto support write callbacks for boolean files, usingDEFINE_DEBUGFS_ATTRIBUTEeliminates the need for these callbacks.
ehhhhh, well, my description very well tells someone about why this is bad, and a hack, and everything.
Your description is good though... But I love to have my personality in my descriptions :(
Quoted 73 lines
Thanks,
Quoted 71 lines
The behavior does not change, except the write only accepts 0/1 now instead of y/n/on/off, and nothing uses anything else.
Signed-off-by Bradley Morgan <[email protected]>---
Changes since v1:
- Added the missing Signed-off-by, sorry.kernel/kprobes.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-)kernel/kprobes.c +9
-34@@ -3013,47 +3013,22 @@ static int disarm_all_kprobes(void)return ret; } -/* -* XXX: The debugfs bool file interface doesn't allow for callbacks -* when the bool state is switched. We can reuse that facility when -* available -*/ -static ssize_t read_enabled_file_bool (struct file *file, -char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_set (void *data,u64 val) { -char buf[3 ]; +if (val) +return arm_all_kprobes (); -if (!kprobes_all_disarmed) - buf[0 ] ='1' ; -else - buf[0 ] ='0' ; - buf[1 ] ='\n' ; - buf[2 ] =0x00 ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); +return disarm_all_kprobes (); } -static ssize_t write_enabled_file_bool (struct file *file, -const char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_get (void *data,u64 *val) { -bool enable; -int ret; - - ret =kstrtobool_from_user (user_buf, count, &enable); -if (ret) -return ret; - - ret = enable ?arm_all_kprobes () :disarm_all_kprobes (); -if (ret) -return ret; - -return count; + *val = !kprobes_all_disarmed; +return 0 ; } -static const struct file_operations fops_kp = { - .read = read_enabled_file_bool, - .write = write_enabled_file_bool, - .llseek = default_llseek, -}; +DEFINE_DEBUGFS_ATTRIBUTE (fops_kp, kprobes_enabled_get, + kprobes_enabled_set,"%llu\n" );
Quoted 8 lines
Quoted 5 lines
kernel/kprobes.c +0
-0static int __init debugfs_kprobe_init (void ) {Signature · 1 line
2.47.3
Thanks!
Quoted 22 lines · Bradley Morgan
Quoted 11 lines · Masami Hiramatsu
Quoted 7 lines · On Tue, 18 Aug 2026 01:53:18 +0000 Bradley Morgan <[email protected]> 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_ATTRIBUTEshowed 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.Quoted 8 lines
In other words, does this mean something like the following?
This "enable" knob implemented custom read/write logic, manually writing "1" or "0" to a 3-byte buffer solely to output a single character. As suggested by comments calling for
debugfsto support write callbacks for boolean files, usingDEFINE_DEBUGFS_ATTRIBUTEeliminates the need for these callbacks.
Quoted 6 lines
ehhhhh, well, my description very well tells someone about why this is bad, and a hack, and everything.
Your description is good though... But I love to have my personality in my descriptions :(
Masami, could you give a round down of your nits for V3?
Quoted 83 lines
Quoted 74 lines
Thanks,
Quoted 71 lines
The behavior does not change, except the write only accepts 0/1 now instead of y/n/on/off, and nothing uses anything else.
Signed-off-by Bradley Morgan <[email protected]>---
Changes since v1:
- Added the missing Signed-off-by, sorry.kernel/kprobes.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-)kernel/kprobes.c +9
-34@@ -3013,47 +3013,22 @@ static int disarm_all_kprobes(void)return ret; } -/* -* XXX: The debugfs bool file interface doesn't allow for callbacks -* when the bool state is switched. We can reuse that facility when -* available -*/ -static ssize_t read_enabled_file_bool (struct file *file, -char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_set (void *data,u64 val) { -char buf[3 ]; +if (val) +return arm_all_kprobes (); -if (!kprobes_all_disarmed) - buf[0 ] ='1' ; -else - buf[0 ] ='0' ; - buf[1 ] ='\n' ; - buf[2 ] =0x00 ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); +return disarm_all_kprobes (); } -static ssize_t write_enabled_file_bool (struct file *file, -const char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_get (void *data,u64 *val) { -bool enable; -int ret; - - ret =kstrtobool_from_user (user_buf, count, &enable); -if (ret) -return ret; - - ret = enable ?arm_all_kprobes () :disarm_all_kprobes (); -if (ret) -return ret; - -return count; + *val = !kprobes_all_disarmed; +return 0 ; } -static const struct file_operations fops_kp = { - .read = read_enabled_file_bool, - .write = write_enabled_file_bool, - .llseek = default_llseek, -}; +DEFINE_DEBUGFS_ATTRIBUTE (fops_kp, kprobes_enabled_get, + kprobes_enabled_set,"%llu\n" );Quoted 8 lines
Quoted 5 lines
kernel/kprobes.c +0
-0static int __init debugfs_kprobe_init (void ) {Signature · 1 line
2.47.3
Quoted 1 line
Thanks!
Thanks!
Masami Hiramatsu (Google)
maintainerQuoted 23 lines · On Thu, 20 Aug 2026 16:14:42 +0100 Bradley Morgan <[email protected]> wrote:
Quoted 22 lines · Bradley Morgan
Quoted 19 lines · Masami Hiramatsu
Quoted 7 lines · On Tue, 18 Aug 2026 01:53:18 +0000 Bradley Morgan <[email protected]> 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_ATTRIBUTEshowed 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.In other words, does this mean something like the following?
This "enable" knob implemented custom read/write logic, manually writing "1" or "0" to a 3-byte buffer solely to output a single character. As suggested by comments calling for
debugfsto support write callbacks for boolean files, usingDEFINE_DEBUGFS_ATTRIBUTEeliminates the need for these callbacks.
Quoted 8 lines
Quoted 6 lines
ehhhhh, well, my description very well tells someone about why this is bad, and a hack, and everything.
Your description is good though... But I love to have my personality in my descriptions :(
Masami, could you give a round down of your nits for V3?
Ah, OK. The phrasing aside, what you said wasn't wrong, so if you're happy with it, I'll pick it. (Let me pick it to probes/core)
Thanks.
Quoted 88 lines
Quoted 85 lines
Quoted 76 lines
Thanks,
Quoted 71 lines
The behavior does not change, except the write only accepts 0/1 now instead of y/n/on/off, and nothing uses anything else.
Signed-off-by Bradley Morgan <[email protected]>---
Changes since v1:
- Added the missing Signed-off-by, sorry.kernel/kprobes.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-)kernel/kprobes.c +9
-34@@ -3013,47 +3013,22 @@ static int disarm_all_kprobes(void)return ret; } -/* -* XXX: The debugfs bool file interface doesn't allow for callbacks -* when the bool state is switched. We can reuse that facility when -* available -*/ -static ssize_t read_enabled_file_bool (struct file *file, -char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_set (void *data,u64 val) { -char buf[3 ]; +if (val) +return arm_all_kprobes (); -if (!kprobes_all_disarmed) - buf[0 ] ='1' ; -else - buf[0 ] ='0' ; - buf[1 ] ='\n' ; - buf[2 ] =0x00 ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); +return disarm_all_kprobes (); } -static ssize_t write_enabled_file_bool (struct file *file, -const char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_get (void *data,u64 *val) { -bool enable; -int ret; - - ret =kstrtobool_from_user (user_buf, count, &enable); -if (ret) -return ret; - - ret = enable ?arm_all_kprobes () :disarm_all_kprobes (); -if (ret) -return ret; - -return count; + *val = !kprobes_all_disarmed; +return 0 ; } -static const struct file_operations fops_kp = { - .read = read_enabled_file_bool, - .write = write_enabled_file_bool, - .llseek = default_llseek, -}; +DEFINE_DEBUGFS_ATTRIBUTE (fops_kp, kprobes_enabled_get, + kprobes_enabled_set,"%llu\n" );Quoted 8 lines
Quoted 5 lines
kernel/kprobes.c +0
-0static int __init debugfs_kprobe_init (void ) {Signature · 1 line
2.47.3Quoted 1 line
Thanks!
Thanks!
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 33 lines · Masami Hiramatsu
Quoted 1 line · On Thu, 20 Aug 2026 16:14:42 +0100 Bradley Morgan <[email protected]> wrote:
On 19 August 2026 00:12:40 BST, Bradley Morgan <[email protected]>
Quoted 13 lines · wrote:
Quoted 13 lines
Quoted 11 lines · Masami Hiramatsu
Quoted 7 lines · On Tue, 18 Aug 2026 01:53:18 +0000 Bradley Morgan <[email protected]> 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_ATTRIBUTEshowed 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.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
In other words, does this mean something like the following?
This "enable" knob implemented custom read/write logic, manually
writing
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
"1" or "0" to a 3-byte buffer solely to output a single character. As suggested by comments calling for
debugfsto support write callbacks for boolean files, usingDEFINE_DEBUGFS_ATTRIBUTEeliminates theneed
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
for these callbacks.
ehhhhh, well, my description very well tells someone about why this is bad, and a hack, and everything.
Your description is good though... But I love to have my personality in
Quoted 9 lines
my
Quoted 4 lines
Quoted 2 lines
descriptions :(
Masami, could you give a round down of your nits for V3?
Ah, OK. The phrasing aside, what you said wasn't wrong, so if you're happy with it, I'll pick it. (Let me pick it to probes/core)
I'm happy with this patch as is, how accurate?
Do the roar! (Pick it, Shrek reference)
Quoted 95 lines
Thanks.
Quoted 88 lines
Quoted 85 lines
Quoted 76 lines
Thanks,
Quoted 71 lines
The behavior does not change, except the write only accepts 0/1 now instead of y/n/on/off, and nothing uses anything else.
Signed-off-by Bradley Morgan <[email protected]>---
Changes since v1:
- Added the missing Signed-off-by, sorry.kernel/kprobes.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-)kernel/kprobes.c +9
-34@@ -3013,47 +3013,22 @@ static int disarm_all_kprobes(void)return ret; } -/* -* XXX: The debugfs bool file interface doesn't allow for callbacks -* when the bool state is switched. We can reuse that facility when -* available -*/ -static ssize_t read_enabled_file_bool (struct file *file, -char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_set (void *data,u64 val) { -char buf[3 ]; +if (val) +return arm_all_kprobes (); -if (!kprobes_all_disarmed) - buf[0 ] ='1' ; -else - buf[0 ] ='0' ; - buf[1 ] ='\n' ; - buf[2 ] =0x00 ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); +return disarm_all_kprobes (); } -static ssize_t write_enabled_file_bool (struct file *file, -const char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_get (void *data,u64 *val) { -bool enable; -int ret; - - ret =kstrtobool_from_user (user_buf, count, &enable); -if (ret) -return ret; - - ret = enable ?arm_all_kprobes () :disarm_all_kprobes (); -if (ret) -return ret; - -return count; + *val = !kprobes_all_disarmed; +return 0 ; } -static const struct file_operations fops_kp = { - .read = read_enabled_file_bool, - .write = write_enabled_file_bool, - .llseek = default_llseek, -}; +DEFINE_DEBUGFS_ATTRIBUTE (fops_kp, kprobes_enabled_get, + kprobes_enabled_set,"%llu\n" );Quoted 8 lines
Quoted 5 lines
kernel/kprobes.c +0
-0static int __init debugfs_kprobe_init (void ) {Signature · 1 line
2.47.3Quoted 1 line
Thanks!
Thanks!
Thanks!
Masami Hiramatsu (Google)
maintainerQuoted 41 lines · On Fri, 21 Aug 2026 09:23:16 +0100 Bradley Morgan <[email protected]> wrote:
Quoted 39 lines · Masami Hiramatsu
Quoted 1 line · On Thu, 20 Aug 2026 16:14:42 +0100 Bradley Morgan <[email protected]> wrote:
On 19 August 2026 00:12:40 BST, Bradley Morgan <[email protected]>
Quoted 13 lines · wrote:
Quoted 13 lines
Quoted 11 lines · Masami Hiramatsu
Quoted 7 lines · On Tue, 18 Aug 2026 01:53:18 +0000 Bradley Morgan <[email protected]> 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_ATTRIBUTEshowed 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.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
In other words, does this mean something like the following?
This "enable" knob implemented custom read/write logic, manually
writing
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
"1" or "0" to a 3-byte buffer solely to output a single character. As suggested by comments calling for
debugfsto support write callbacks for boolean files, usingDEFINE_DEBUGFS_ATTRIBUTEeliminates theneed
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
for these callbacks.
ehhhhh, well, my description very well tells someone about why this is bad, and a hack, and everything.
Your description is good though... But I love to have my personality in
my
Quoted 4 lines
Quoted 2 lines
descriptions :(
Masami, could you give a round down of your nits for V3?
Quoted 7 lines
Quoted 3 lines
Ah, OK. The phrasing aside, what you said wasn't wrong, so if you're happy with it, I'll pick it. (Let me pick it to probes/core)
I'm happy with this patch as is, how accurate?
Do the roar! (Pick it, Shrek reference)
OK, I picked this to probes/core. (sorry for late notice)
Thanks,
Quoted 98 lines
Quoted 96 lines
Thanks.
Quoted 88 lines
Quoted 85 lines
Quoted 76 lines
Thanks,
Quoted 71 lines
The behavior does not change, except the write only accepts 0/1 now instead of y/n/on/off, and nothing uses anything else.
Signed-off-by Bradley Morgan <[email protected]>---
Changes since v1:
- Added the missing Signed-off-by, sorry.kernel/kprobes.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-)kernel/kprobes.c +9
-34@@ -3013,47 +3013,22 @@ static int disarm_all_kprobes(void)return ret; } -/* -* XXX: The debugfs bool file interface doesn't allow for callbacks -* when the bool state is switched. We can reuse that facility when -* available -*/ -static ssize_t read_enabled_file_bool (struct file *file, -char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_set (void *data,u64 val) { -char buf[3 ]; +if (val) +return arm_all_kprobes (); -if (!kprobes_all_disarmed) - buf[0 ] ='1' ; -else - buf[0 ] ='0' ; - buf[1 ] ='\n' ; - buf[2 ] =0x00 ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); +return disarm_all_kprobes (); } -static ssize_t write_enabled_file_bool (struct file *file, -const char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_get (void *data,u64 *val) { -bool enable; -int ret; - - ret =kstrtobool_from_user (user_buf, count, &enable); -if (ret) -return ret; - - ret = enable ?arm_all_kprobes () :disarm_all_kprobes (); -if (ret) -return ret; - -return count; + *val = !kprobes_all_disarmed; +return 0 ; } -static const struct file_operations fops_kp = { - .read = read_enabled_file_bool, - .write = write_enabled_file_bool, - .llseek = default_llseek, -}; +DEFINE_DEBUGFS_ATTRIBUTE (fops_kp, kprobes_enabled_get, + kprobes_enabled_set,"%llu\n" );Quoted 8 lines
Quoted 5 lines
kernel/kprobes.c +0
-0static int __init debugfs_kprobe_init (void ) {Signature · 1 line
2.47.3Quoted 1 line
Thanks!
Thanks!
Thanks!
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 99 lines · Masami Hiramatsu
Quoted 8 lines · On Fri, 21 Aug 2026 09:23:16 +0100 Bradley Morgan <[email protected]> wrote:
Quoted 6 lines · Masami Hiramatsu
Quoted 1 line · On Thu, 20 Aug 2026 16:14:42 +0100 Bradley Morgan <[email protected]> wrote:
On 19 August 2026 00:12:40 BST, Bradley Morgan <[email protected]>
Quoted 1 line · wrote:
Quoted 1 line
On 19 August 2026 00:08:13 BST, Masami Hiramatsu
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines · wrote:
Quoted 1 line · On Tue, 18 Aug 2026 01:53:18 +0000 Bradley Morgan <[email protected]> wrote:
This enabled knob is a disgusting terrible hack. It has rolled
its
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
own read/write pair since 2007, writing '1' or '0' into a three
byte
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
buffer by hand just to print a single character, with an XXX
comment
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
begging debugfs for write callbacks on bool files.
DEFINE_DEBUGFS_ATTRIBUTEshowed up in 2016 and does exactly that,so
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
the disgusting terrible hack has outlived its excuse for nine
years.
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Kill it, and the stale comment with it.
In other words, does this mean something like the following?
This "enable" knob implemented custom read/write logic, manually
writing
Quoted 1 line
Quoted 1 line
Quoted 1 line
"1" or "0" to a 3-byte buffer solely to output a single character.
As
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
suggested by comments calling for
debugfsto support writecallbacks
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
for boolean files, using
DEFINE_DEBUGFS_ATTRIBUTEeliminates theneed
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
for these callbacks.
ehhhhh, well, my description very well tells someone about why this
is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
bad, and a hack, and everything.
Your description is good though... But I love to have my personality
in
Quoted 7 lines
Quoted 7 lines
my
Quoted 4 lines
Quoted 2 lines
descriptions :(
Masami, could you give a round down of your nits for V3?
Ah, OK. The phrasing aside, what you said wasn't wrong, so if you're
happy
Quoted 6 lines
Quoted 2 lines
with it, I'll pick it. (Let me pick it to probes/core)
I'm happy with this patch as is, how accurate?
Do the roar! (Pick it, Shrek reference)
OK, I picked this to probes/core. (sorry for late notice)
Thanks,
Quoted 8 lines
Quoted 8 lines
Thanks.
Quoted 3 lines
Quoted 3 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Thanks,
Quoted 2 lines
The behavior does not change, except the write only accepts 0/1
now
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
instead of y/n/on/off, and nothing uses anything else.
Signed-off-by Bradley Morgan <[email protected]>---
Changes since v1:
- Added the missing Signed-off-by, sorry.kernel/kprobes.c | 43+++++++++----------------------------------
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
1 file changed, 9 insertions(+), 34 deletions(-)kernel/kprobes.c +0
-0@@ -3013,47 +3013,22 @@ static int disarm_all_kprobes(void)return ret; }
Quoted 73 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
kernel/kprobes.c static int disarm_all_kprobes(void) · line 3017
Quoted 2 lines
kernel/kprobes.c +0
-2-/* -* XXX: The debugfs bool file interface doesn't allow for callbacks
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
kernel/kprobes.c static int disarm_all_kprobes(void) · line 3018
Quoted 1 line
kernel/kprobes.c +0
-1-* when the bool state is switched. We can reuse that facility when
Quoted 65 lines
Quoted 57 lines
Quoted 57 lines
Quoted 57 lines
Quoted 56 lines
Quoted 53 lines
kernel/kprobes.c +9
-31-* available -*/ -static ssize_t read_enabled_file_bool (struct file *file, -char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_set (void *data,u64 val) { -char buf[3 ]; +if (val) +return arm_all_kprobes (); -if (!kprobes_all_disarmed) - buf[0 ] ='1' ; -else - buf[0 ] ='0' ; - buf[1 ] ='\n' ; - buf[2 ] =0x00 ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); +return disarm_all_kprobes (); } -static ssize_t write_enabled_file_bool (struct file *file, -const char __user *user_buf,size_t count,loff_t *ppos) +static int kprobes_enabled_get (void *data,u64 *val) { -bool enable; -int ret; - - ret =kstrtobool_from_user (user_buf, count, &enable); -if (ret) -return ret; - - ret = enable ?arm_all_kprobes () :disarm_all_kprobes (); -if (ret) -return ret; - -return count; + *val = !kprobes_all_disarmed; +return 0 ; } -static const struct file_operations fops_kp = { - .read = read_enabled_file_bool, - .write = write_enabled_file_bool, - .llseek = default_llseek, -}; +DEFINE_DEBUGFS_ATTRIBUTE (fops_kp, kprobes_enabled_get, + kprobes_enabled_set,"%llu\n" );static int __init debugfs_kprobe_init (void ) {Signature · 1 line
2.47.3Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Thanks!
Thanks!
Thanks!
Hey, can u change sob to this email if possible? Check lore link below for info
--- Thanks!
https://lore.kernel.org/all/[email protected]/
Masami Hiramatsu (Google)
maintainerQuoted 6 lines · On Tue, 08 Sep 2026 16:19:00 +0100 Bradley Morgan <[email protected]> wrote:
Quoted 2 lines
Hey, can u change sob to this email if possible? Check lore link below for info
--- Thanks!
https://lore.kernel.org/all/[email protected]/
No, but basically I can add your new email. Or can you resend this to replace the new one?
Thank you,
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>