linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing: fprobe-event: Fix to check tracepoint event and return
@ 2023-11-03 16:05 Masami Hiramatsu (Google)
  2023-11-06 22:28 ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu (Google) @ 2023-11-03 16:05 UTC (permalink / raw)
  To: linux-trace-kernel, Steven Rostedt; +Cc: linux-kernel, mhiramat

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

Fix to check the tracepoint event is not valid with $retval.
The commit 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is
a return event by $retval") introduced automatic return probe
conversion with $retval. But since tracepoint event does not
support return probe, $retval is not acceptable.

Fixes: 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 kernel/trace/trace_fprobe.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c
index 8bfe23af9c73..7d2ddbcfa377 100644
--- a/kernel/trace/trace_fprobe.c
+++ b/kernel/trace/trace_fprobe.c
@@ -927,11 +927,12 @@ static int parse_symbol_and_return(int argc, const char *argv[],
 	for (i = 2; i < argc; i++) {
 		tmp = strstr(argv[i], "$retval");
 		if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') {
+			if (is_tracepoint) {
+				trace_probe_log_set_index(i);
+				trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
+				return -EINVAL;
+			}
 			*is_return = true;
-			/*
-			 * NOTE: Don't check is_tracepoint here, because it will
-			 * be checked when the argument is parsed.
-			 */
 			break;
 		}
 	}


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

* Re: [PATCH] tracing: fprobe-event: Fix to check tracepoint event and return
  2023-11-03 16:05 [PATCH] tracing: fprobe-event: Fix to check tracepoint event and return Masami Hiramatsu (Google)
@ 2023-11-06 22:28 ` Steven Rostedt
  2023-11-07  0:40   ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2023-11-06 22:28 UTC (permalink / raw)
  To: Masami Hiramatsu (Google); +Cc: linux-trace-kernel, linux-kernel

On Sat,  4 Nov 2023 01:05:34 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Fix to check the tracepoint event is not valid with $retval.
> The commit 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is
> a return event by $retval") introduced automatic return probe
> conversion with $retval. But since tracepoint event does not
> support return probe, $retval is not acceptable.

Can you add the command that causes this to fail.

-- Steve

> 
> Fixes: 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval")
> Cc: stable@vger.kernel.org
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
>  kernel/trace/trace_fprobe.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c
> index 8bfe23af9c73..7d2ddbcfa377 100644
> --- a/kernel/trace/trace_fprobe.c
> +++ b/kernel/trace/trace_fprobe.c
> @@ -927,11 +927,12 @@ static int parse_symbol_and_return(int argc, const char *argv[],
>  	for (i = 2; i < argc; i++) {
>  		tmp = strstr(argv[i], "$retval");
>  		if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') {
> +			if (is_tracepoint) {
> +				trace_probe_log_set_index(i);
> +				trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
> +				return -EINVAL;
> +			}
>  			*is_return = true;
> -			/*
> -			 * NOTE: Don't check is_tracepoint here, because it will
> -			 * be checked when the argument is parsed.
> -			 */
>  			break;
>  		}
>  	}


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

* Re: [PATCH] tracing: fprobe-event: Fix to check tracepoint event and return
  2023-11-06 22:28 ` Steven Rostedt
@ 2023-11-07  0:40   ` Masami Hiramatsu
  2023-11-08 11:01     ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2023-11-07  0:40 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-kernel, linux-kernel

On Mon, 6 Nov 2023 17:28:11 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Sat,  4 Nov 2023 01:05:34 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> 
> > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > 
> > Fix to check the tracepoint event is not valid with $retval.
> > The commit 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is
> > a return event by $retval") introduced automatic return probe
> > conversion with $retval. But since tracepoint event does not
> > support return probe, $retval is not acceptable.
> 
> Can you add the command that causes this to fail.

Actually this doesn't command fail but it expected to fail.

$ echo "t kfree $retval" >> dynamic_events

This should be rejected because 't' (tracepoint) should not be
a return probe. Without this fix, this is accepted.
(But it traces a random return value because the tracepoint function
will return 'void'.)

Thank you,

> 
> -- Steve
> 
> > 
> > Fixes: 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > ---
> >  kernel/trace/trace_fprobe.c |    9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c
> > index 8bfe23af9c73..7d2ddbcfa377 100644
> > --- a/kernel/trace/trace_fprobe.c
> > +++ b/kernel/trace/trace_fprobe.c
> > @@ -927,11 +927,12 @@ static int parse_symbol_and_return(int argc, const char *argv[],
> >  	for (i = 2; i < argc; i++) {
> >  		tmp = strstr(argv[i], "$retval");
> >  		if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') {
> > +			if (is_tracepoint) {
> > +				trace_probe_log_set_index(i);
> > +				trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
> > +				return -EINVAL;
> > +			}
> >  			*is_return = true;
> > -			/*
> > -			 * NOTE: Don't check is_tracepoint here, because it will
> > -			 * be checked when the argument is parsed.
> > -			 */
> >  			break;
> >  		}
> >  	}
> 


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

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

* Re: [PATCH] tracing: fprobe-event: Fix to check tracepoint event and return
  2023-11-07  0:40   ` Masami Hiramatsu
@ 2023-11-08 11:01     ` Masami Hiramatsu
  2023-11-08 12:06       ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2023-11-08 11:01 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Steven Rostedt, linux-trace-kernel, linux-kernel

On Tue, 7 Nov 2023 09:40:45 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> On Mon, 6 Nov 2023 17:28:11 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > On Sat,  4 Nov 2023 01:05:34 +0900
> > "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> > 
> > > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > > 
> > > Fix to check the tracepoint event is not valid with $retval.
> > > The commit 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is
> > > a return event by $retval") introduced automatic return probe
> > > conversion with $retval. But since tracepoint event does not
> > > support return probe, $retval is not acceptable.
> > 
> > Can you add the command that causes this to fail.
> 
> Actually this doesn't command fail but it expected to fail.
> 
> $ echo "t kfree $retval" >> dynamic_events

Wait, with some configuration, this doesn't cause a problem.
Let me try to reproduce the issue...

Thank you,

> 
> This should be rejected because 't' (tracepoint) should not be
> a return probe. Without this fix, this is accepted.
> (But it traces a random return value because the tracepoint function
> will return 'void'.)
> 
> Thank you,
> 
> > 
> > -- Steve
> > 
> > > 
> > > Fixes: 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval")
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > > ---
> > >  kernel/trace/trace_fprobe.c |    9 +++++----
> > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c
> > > index 8bfe23af9c73..7d2ddbcfa377 100644
> > > --- a/kernel/trace/trace_fprobe.c
> > > +++ b/kernel/trace/trace_fprobe.c
> > > @@ -927,11 +927,12 @@ static int parse_symbol_and_return(int argc, const char *argv[],
> > >  	for (i = 2; i < argc; i++) {
> > >  		tmp = strstr(argv[i], "$retval");
> > >  		if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') {
> > > +			if (is_tracepoint) {
> > > +				trace_probe_log_set_index(i);
> > > +				trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
> > > +				return -EINVAL;
> > > +			}
> > >  			*is_return = true;
> > > -			/*
> > > -			 * NOTE: Don't check is_tracepoint here, because it will
> > > -			 * be checked when the argument is parsed.
> > > -			 */
> > >  			break;
> > >  		}
> > >  	}
> > 
> 
> 
> -- 
> Masami Hiramatsu (Google) <mhiramat@kernel.org>


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

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

* Re: [PATCH] tracing: fprobe-event: Fix to check tracepoint event and return
  2023-11-08 11:01     ` Masami Hiramatsu
@ 2023-11-08 12:06       ` Masami Hiramatsu
  0 siblings, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2023-11-08 12:06 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Steven Rostedt, linux-trace-kernel, linux-kernel

On Wed, 8 Nov 2023 20:01:50 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> On Tue, 7 Nov 2023 09:40:45 +0900
> Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> 
> > On Mon, 6 Nov 2023 17:28:11 -0500
> > Steven Rostedt <rostedt@goodmis.org> wrote:
> > 
> > > On Sat,  4 Nov 2023 01:05:34 +0900
> > > "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> > > 
> > > > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > > > 
> > > > Fix to check the tracepoint event is not valid with $retval.
> > > > The commit 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is
> > > > a return event by $retval") introduced automatic return probe
> > > > conversion with $retval. But since tracepoint event does not
> > > > support return probe, $retval is not acceptable.
> > > 
> > > Can you add the command that causes this to fail.
> > 
> > Actually this doesn't command fail but it expected to fail.
> > 
> > $ echo "t kfree $retval" >> dynamic_events
> 
> Wait, with some configuration, this doesn't cause a problem.
> Let me try to reproduce the issue...

OK, I confirmed that probes/fixes branch fails without this fix.

[22] Tracepoint probe event parser error log check      [FAIL]

Let me update the description.

Thank you,

> 
> Thank you,
> 
> > 
> > This should be rejected because 't' (tracepoint) should not be
> > a return probe. Without this fix, this is accepted.
> > (But it traces a random return value because the tracepoint function
> > will return 'void'.)
> > 
> > Thank you,
> > 
> > > 
> > > -- Steve
> > > 
> > > > 
> > > > Fixes: 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval")
> > > > Cc: stable@vger.kernel.org
> > > > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > > > ---
> > > >  kernel/trace/trace_fprobe.c |    9 +++++----
> > > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c
> > > > index 8bfe23af9c73..7d2ddbcfa377 100644
> > > > --- a/kernel/trace/trace_fprobe.c
> > > > +++ b/kernel/trace/trace_fprobe.c
> > > > @@ -927,11 +927,12 @@ static int parse_symbol_and_return(int argc, const char *argv[],
> > > >  	for (i = 2; i < argc; i++) {
> > > >  		tmp = strstr(argv[i], "$retval");
> > > >  		if (tmp && !isalnum(tmp[7]) && tmp[7] != '_') {
> > > > +			if (is_tracepoint) {
> > > > +				trace_probe_log_set_index(i);
> > > > +				trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
> > > > +				return -EINVAL;
> > > > +			}
> > > >  			*is_return = true;
> > > > -			/*
> > > > -			 * NOTE: Don't check is_tracepoint here, because it will
> > > > -			 * be checked when the argument is parsed.
> > > > -			 */
> > > >  			break;
> > > >  		}
> > > >  	}
> > > 
> > 
> > 
> > -- 
> > Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> 
> -- 
> Masami Hiramatsu (Google) <mhiramat@kernel.org>


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

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

end of thread, other threads:[~2023-11-08 12:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-03 16:05 [PATCH] tracing: fprobe-event: Fix to check tracepoint event and return Masami Hiramatsu (Google)
2023-11-06 22:28 ` Steven Rostedt
2023-11-07  0:40   ` Masami Hiramatsu
2023-11-08 11:01     ` Masami Hiramatsu
2023-11-08 12:06       ` Masami Hiramatsu

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