linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] debugfs: Fix debugfs_read_file_str()
@ 2021-05-27  9:11 Dietmar Eggemann
  2021-05-29  1:51 ` Steven Rostedt
  2021-06-04  8:39 ` Peter Zijlstra
  0 siblings, 2 replies; 4+ messages in thread
From: Dietmar Eggemann @ 2021-05-27  9:11 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: Juri Lelli, Vincent Guittot, Steven Rostedt, Greg Kroah-Hartman,
	Valentin Schneider, linux-kernel

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

Fixes: 9af0440ec86eb ("debugfs: Implement debugfs_create_str()")
Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
---
 fs/debugfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index e813acfaa6e8..ba7c01cd9a5d 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] debugfs: Fix debugfs_read_file_str()
  2021-05-27  9:11 [PATCH] debugfs: Fix debugfs_read_file_str() Dietmar Eggemann
@ 2021-05-29  1:51 ` Steven Rostedt
  2021-06-04  8:39 ` Peter Zijlstra
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2021-05-29  1:51 UTC (permalink / raw)
  To: Dietmar Eggemann
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Greg Kroah-Hartman, Valentin Schneider, linux-kernel

On Thu, 27 May 2021 11:11:05 +0200
Dietmar Eggemann <dietmar.eggemann@arm.com> wrote:

> +++ b/fs/debugfs/file.c
> @@ -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.

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] debugfs: Fix debugfs_read_file_str()
  2021-05-27  9:11 [PATCH] debugfs: Fix debugfs_read_file_str() Dietmar Eggemann
  2021-05-29  1:51 ` Steven Rostedt
@ 2021-06-04  8:39 ` Peter Zijlstra
  2021-06-04  8:41   ` Greg Kroah-Hartman
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2021-06-04  8:39 UTC (permalink / raw)
  To: Dietmar Eggemann
  Cc: Ingo Molnar, Juri Lelli, Vincent Guittot, Steven Rostedt,
	Greg Kroah-Hartman, Valentin Schneider, linux-kernel

On Thu, May 27, 2021 at 11:11:05AM +0200, Dietmar Eggemann wrote:
> 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
> 
> Fixes: 9af0440ec86eb ("debugfs: Implement debugfs_create_str()")
> Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>

Urgh.. so much for last minute changes :/

Greg, AFAICT that commit has since landed in Linus, will you take care
of this?

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] debugfs: Fix debugfs_read_file_str()
  2021-06-04  8:39 ` Peter Zijlstra
@ 2021-06-04  8:41   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-06-04  8:41 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Dietmar Eggemann, Ingo Molnar, Juri Lelli, Vincent Guittot,
	Steven Rostedt, Valentin Schneider, linux-kernel

On Fri, Jun 04, 2021 at 10:39:43AM +0200, Peter Zijlstra wrote:
> On Thu, May 27, 2021 at 11:11:05AM +0200, Dietmar Eggemann wrote:
> > 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
> > 
> > Fixes: 9af0440ec86eb ("debugfs: Implement debugfs_create_str()")
> > Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
> 
> Urgh.. so much for last minute changes :/
> 
> Greg, AFAICT that commit has since landed in Linus, will you take care
> of this?
> 
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

Yes, I'll pick it up now, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-04  8:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27  9:11 [PATCH] debugfs: Fix debugfs_read_file_str() Dietmar Eggemann
2021-05-29  1:51 ` Steven Rostedt
2021-06-04  8:39 ` Peter Zijlstra
2021-06-04  8:41   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).