linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] function_graph: Fix off-by-one error in buffer size
@ 2025-06-17 11:19 Artem Sadovnikov
  2025-06-17 15:00 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Artem Sadovnikov @ 2025-06-17 11:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: Artem Sadovnikov, Steven Rostedt, Masami Hiramatsu, lvc-project

The comment above buffer mentions sign, 10 bytes width for number and null
terminator, but buffer itself isn't large enough to hold that much data.

This is a cosmetic change, since PID cannot be negative, other than -1.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Artem Sadovnikov <a.sadovnikov@ispras.ru>
---
 kernel/trace/trace_functions_graph.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index a8c1f56340680..d789d308ab1de 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -344,7 +344,7 @@ static void print_graph_proc(struct trace_seq *s, pid_t pid)
 {
 	char comm[TASK_COMM_LEN];
 	/* sign + log10(MAX_INT) + '\0' */
-	char pid_str[11];
+	char pid_str[12];
 	int spaces = 0;
 	int len;
 	int i;
-- 
2.43.0


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

* Re: [PATCH] function_graph: Fix off-by-one error in buffer size
  2025-06-17 11:19 [PATCH] function_graph: Fix off-by-one error in buffer size Artem Sadovnikov
@ 2025-06-17 15:00 ` Steven Rostedt
  2025-06-17 15:02   ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2025-06-17 15:00 UTC (permalink / raw)
  To: Artem Sadovnikov; +Cc: linux-kernel, Masami Hiramatsu, lvc-project

On Tue, 17 Jun 2025 11:19:06 +0000
Artem Sadovnikov <a.sadovnikov@ispras.ru> wrote:

> The comment above buffer mentions sign, 10 bytes width for number and null
> terminator, but buffer itself isn't large enough to hold that much data.
> 
> This is a cosmetic change, since PID cannot be negative, other than -1.

Right, where I'll change the subject as that makes it look like this is a
real bug.

And it is likely that "pid_str" will be allocated as 12 anyway, just for
alignment reasons. But I'll take your patch.

-- Steve


> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Artem Sadovnikov <a.sadovnikov@ispras.ru>
> ---
>  kernel/trace/trace_functions_graph.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
> index a8c1f56340680..d789d308ab1de 100644
> --- a/kernel/trace/trace_functions_graph.c
> +++ b/kernel/trace/trace_functions_graph.c
> @@ -344,7 +344,7 @@ static void print_graph_proc(struct trace_seq *s, pid_t pid)
>  {
>  	char comm[TASK_COMM_LEN];
>  	/* sign + log10(MAX_INT) + '\0' */
> -	char pid_str[11];
> +	char pid_str[12];
>  	int spaces = 0;
>  	int len;
>  	int i;


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

* Re: [PATCH] function_graph: Fix off-by-one error in buffer size
  2025-06-17 15:00 ` Steven Rostedt
@ 2025-06-17 15:02   ` Steven Rostedt
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2025-06-17 15:02 UTC (permalink / raw)
  To: Artem Sadovnikov; +Cc: linux-kernel, Masami Hiramatsu, lvc-project

On Tue, 17 Jun 2025 11:00:17 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Tue, 17 Jun 2025 11:19:06 +0000
> Artem Sadovnikov <a.sadovnikov@ispras.ru> wrote:
> 
> > The comment above buffer mentions sign, 10 bytes width for number and null
> > terminator, but buffer itself isn't large enough to hold that much data.
> > 
> > This is a cosmetic change, since PID cannot be negative, other than -1.  
> 
> Right, where I'll change the subject as that makes it look like this is a
> real bug.

Can your resend and Cc linux-trace-kernel@vger.kernel.org otherwise it will
not get into the patchwork queue.

Rename the Subject to:

 fgraph: Make pid_str size match the comment

Thanks!

-- Steve


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

end of thread, other threads:[~2025-06-17 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 11:19 [PATCH] function_graph: Fix off-by-one error in buffer size Artem Sadovnikov
2025-06-17 15:00 ` Steven Rostedt
2025-06-17 15:02   ` Steven Rostedt

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).