All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body()
@ 2024-04-27  7:23 lumingyindetect
  2024-04-27  9:11 ` Markus Elfring
  2024-04-29 13:29 ` Masami Hiramatsu
  0 siblings, 2 replies; 5+ messages in thread
From: lumingyindetect @ 2024-04-27  7:23 UTC (permalink / raw)
  To: linux-trace-kernel, linux-kernel
  Cc: rostedt, mhiramat, mathieu.desnoyers, LuMingYin

From: LuMingYin <lumingyindetect@126.com>

If traceprobe_parse_probe_arg_body() failed to allocate 'parg->fmt',
it jumps to the label 'out' instead of 'fail' by mistake.In the result,
the buffer 'tmp' is not freed in this case and leaks its memory.

Thus jump to the label 'fail' in that error case.

Fixes: 032330abd08b ("tracing/probes: Cleanup probe argument parser")
Signed-off-by: LuMingYin <lumingyindetect@126.com>
---
 kernel/trace/trace_probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index c09fa6fc636e..81c319b92038 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -1466,7 +1466,7 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,
 		parg->fmt = kmalloc(len, GFP_KERNEL);
 		if (!parg->fmt) {
 			ret = -ENOMEM;
-			goto out;
+			goto fail;
 		}
 		snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype,
 			 parg->count);
-- 
2.25.1


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

* Re: [PATCH v3] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body()
  2024-04-27  7:23 [PATCH v3] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body() lumingyindetect
@ 2024-04-27  9:11 ` Markus Elfring
  2024-04-29 13:29 ` Masami Hiramatsu
  1 sibling, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2024-04-27  9:11 UTC (permalink / raw)
  To: LuMingYin, linux-trace-kernel, kernel-janitors, Masami Hiramatsu,
	Mathieu Desnoyers, Steven Rostedt
  Cc: LKML

>                                             … by mistake.In the result,
…

I propose once more to start the second sentence of this change description
on a subsequent line.

> ---
> kernel/trace/trace_probe.c | 2 +-
…

Unfortunately, you overlooked to add patch version descriptions behind the marker line.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc5#n713

Regards,
Markus

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

* Re: [PATCH v3] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body()
  2024-04-27  7:23 [PATCH v3] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body() lumingyindetect
  2024-04-27  9:11 ` Markus Elfring
@ 2024-04-29 13:29 ` Masami Hiramatsu
  2024-04-29 13:55   ` [v3] " Markus Elfring
  1 sibling, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2024-04-29 13:29 UTC (permalink / raw)
  To: lumingyindetect
  Cc: linux-trace-kernel, linux-kernel, rostedt, mhiramat, mathieu.desnoyers

Hi LuMing,

On Sat, 27 Apr 2024 08:23:47 +0100
lumingyindetect@126.com wrote:

> From: LuMingYin <lumingyindetect@126.com>
> 
> If traceprobe_parse_probe_arg_body() failed to allocate 'parg->fmt',
> it jumps to the label 'out' instead of 'fail' by mistake.In the result,
> the buffer 'tmp' is not freed in this case and leaks its memory.
> 
> Thus jump to the label 'fail' in that error case.
> 

Looks good to me.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>


Thank you!

> Fixes: 032330abd08b ("tracing/probes: Cleanup probe argument parser")
> Signed-off-by: LuMingYin <lumingyindetect@126.com>
> ---
>  kernel/trace/trace_probe.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index c09fa6fc636e..81c319b92038 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -1466,7 +1466,7 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size,
>  		parg->fmt = kmalloc(len, GFP_KERNEL);
>  		if (!parg->fmt) {
>  			ret = -ENOMEM;
> -			goto out;
> +			goto fail;
>  		}
>  		snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype,
>  			 parg->count);
> -- 
> 2.25.1
> 
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

* Re: [v3] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body()
  2024-04-29 13:29 ` Masami Hiramatsu
@ 2024-04-29 13:55   ` Markus Elfring
  2024-05-02  1:37     ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2024-04-29 13:55 UTC (permalink / raw)
  To: Masami Hiramatsu, LuMingYin, linux-trace-kernel
  Cc: LKML, kernel-janitors, Mathieu Desnoyers, Steven Rostedt

…
> > it jumps to the label 'out' instead of 'fail' by mistake.In the result,
>
> Looks good to me.

* Do you care for a typo in this change description?

* Would you like to read any improved (patch) version descriptions (or changelogs)?

Regards,
Markus

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

* Re: [v3] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body()
  2024-04-29 13:55   ` [v3] " Markus Elfring
@ 2024-05-02  1:37     ` Masami Hiramatsu
  0 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2024-05-02  1:37 UTC (permalink / raw)
  To: Markus Elfring
  Cc: LuMingYin, linux-trace-kernel, LKML, kernel-janitors,
	Mathieu Desnoyers, Steven Rostedt

On Mon, 29 Apr 2024 15:55:09 +0200
Markus Elfring <Markus.Elfring@web.de> wrote:

> …
> > > it jumps to the label 'out' instead of 'fail' by mistake.In the result,
> …
> >
> > Looks good to me.
> 
> * Do you care for a typo in this change description?
> 
> * Would you like to read any improved (patch) version descriptions (or changelogs)?

Thanks, but those are nitpicks and I don't mind it.

Thank you,

> 
> Regards,
> Markus


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

end of thread, other threads:[~2024-05-02  1:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-27  7:23 [PATCH v3] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body() lumingyindetect
2024-04-27  9:11 ` Markus Elfring
2024-04-29 13:29 ` Masami Hiramatsu
2024-04-29 13:55   ` [v3] " Markus Elfring
2024-05-02  1:37     ` Masami Hiramatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.