debugfs: Fix debugfs_read_file_str()
PATCH 1/1 debugfs: Fix debugfs_read_file_str()
Read the entire size of the buffer, including the trailing new line character.
Discovered while reading the sched domain names of CPU0:
before:
cat /sys/kernel/debug/sched/domains/cpu0/domain*/name SMTMCDIE
after:
cat /sys/kernel/debug/sched/domains/cpu0/domain*/name SMT
MC
DIE
--- fs/debugfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/debugfs/file.c +1 -1
@@ -893,7 +893,7 @@ ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf, copy[copy_len] ='\n' ; - ret =simple_read_from_buffer (user_buf, count, ppos, copy, copy_len); + ret =simple_read_from_buffer (user_buf, count, ppos, copy, len);kfree (copy);return ret;
Signature · 1 line
2.25.1
fs/debugfs/file.c ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf, · line 897
Quoted 8 lines · On Thu, 27 May 2021 11:11:05 +0200 Dietmar Eggemann <[email protected]>…
+++
b/fs/debugfs/file.cfs/debugfs/file.c +1
-1@@ -893,7 +893,7 @@ ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf, copy[copy_len] ='\n' ; - ret =simple_read_from_buffer (user_buf, count, ppos, copy, copy_len); + ret =simple_read_from_buffer (user_buf, count, ppos, copy, len);kfree (copy);
As we have:
len = strlen(str) + 1; [..] copy_len = strscpy(copy, str, len);
I can't think of any situation that len is not equal to copy_len + 1. :-/
Anyway, either "len" or "copy_len + 1" would work.
-- Steve
Quoted 11 lines · Dietmar Eggemann
Read the entire size of the buffer, including the trailing new line character.
Discovered while reading the sched domain names of CPU0:before:
cat
/sys/kernel/debug/sched/domains/cpu0/domain*/nameSMTMCDIEafter:
Quoted 7 lines
cat
/sys/kernel/debug/sched/domains/cpu0/domain*/nameSMT
MC
DIEFixes 9af0440ec86eb ("debugfs: Implement debugfs_create_str()")Signed-off-by Dietmar Eggemann <[email protected]>
Urgh.. so much for last minute changes :/
Greg, AFAICT that commit has since landed in Linus, will you take care of this?
Greg Kroah-Hartman
maintainerQuoted 20 lines · Peter Zijlstra
Quoted 11 lines · Dietmar Eggemann
Read the entire size of the buffer, including the trailing new line character.
Discovered while reading the sched domain names of CPU0:before:
cat
/sys/kernel/debug/sched/domains/cpu0/domain*/nameSMTMCDIEafter:
Quoted 7 lines
cat
/sys/kernel/debug/sched/domains/cpu0/domain*/nameSMT
MC
DIEFixes 9af0440ec86eb ("debugfs: Implement debugfs_create_str()")Signed-off-by Dietmar Eggemann <[email protected]>
Quoted 6 lines
Urgh.. so much for last minute changes :/
Greg, AFAICT that commit has since landed in Linus, will you take care of this?
Yes, I'll pick it up now, thanks.
greg k-h