Skip to contentSkip to conversation

tracing: fprobe-event: Fix to check tracepoint event and return

PATCH Superseded Masami Hiramatsu (Google) 2 participants 5 messages Nov 3, 2023 – Nov 8, 2023 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Masami Hiramatsu (Google)

author maintainer
#0 lore raw

PATCH 1/1 tracing: fprobe-event: Fix to check tracepoint event and return

From: Masami Hiramatsu (Google) <[email protected]>

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")
---
 kernel/trace/trace_fprobe.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/trace/trace_fprobe.c +5 -4
index 8bfe23af9c73..7d2ddbcfa377 100644
@@ -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;
 		}
 	}
maintainer
#1 lore raw
Quoted 7 lines · On Sat, 4 Nov 2023 01:05:34 +0900 "Masami Hiramatsu (Google)"…

From: Masami Hiramatsu (Google) <[email protected]>

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

Quoted 29 lines
Fixes 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval")
---
 kernel/trace/trace_fprobe.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/trace/trace_fprobe.c +5 -4
index 8bfe23af9c73..7d2ddbcfa377 100644
@@ -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;
 		}
 	}
author maintainer
#2 lore raw
Quoted 5 lines · On Mon, 6 Nov 2023 17:28:11 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 2 lines · On Sat, 4 Nov 2023 01:05:34 +0900 "Masami Hiramatsu (Google)"…

From: Masami Hiramatsu (Google) <[email protected]>

Quoted 7 lines
Quoted 5 lines

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,

Quoted 33 lines

-- Steve

Quoted 29 lines
Fixes 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval")
---
 kernel/trace/trace_fprobe.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/trace/trace_fprobe.c +5 -4
index 8bfe23af9c73..7d2ddbcfa377 100644
@@ -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;
 		}
 	}
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
author maintainer
#3 lore raw
Quoted 14 lines · On Tue, 7 Nov 2023 09:40:45 +0900 Masami Hiramatsu (Google)…
Quoted 11 lines · On Mon, 6 Nov 2023 17:28:11 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 7 lines · On Sat, 4 Nov 2023 01:05:34 +0900 "Masami Hiramatsu (Google)"…

From: Masami Hiramatsu (Google) <[email protected]>

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.

Quoted 5 lines
Quoted 1 line

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,

Quoted 45 lines

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,

Quoted 33 lines

-- Steve

Quoted 29 lines
Fixes 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval")
---
 kernel/trace/trace_fprobe.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/trace/trace_fprobe.c +5 -4
index 8bfe23af9c73..7d2ddbcfa377 100644
@@ -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;
 		}
 	}
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
author maintainer
#4 lore raw
Quoted 17 lines · On Wed, 8 Nov 2023 20:01:50 +0900 Masami Hiramatsu (Google)…
Quoted 14 lines · On Tue, 7 Nov 2023 09:40:45 +0900 Masami Hiramatsu (Google)…
Quoted 11 lines · On Mon, 6 Nov 2023 17:28:11 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 7 lines · On Sat, 4 Nov 2023 01:05:34 +0900 "Masami Hiramatsu (Google)"…

From: Masami Hiramatsu (Google) <[email protected]>

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.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

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,

Quoted 52 lines

Thank you,

Quoted 45 lines

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,

Quoted 33 lines

-- Steve

Quoted 29 lines
Fixes 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval")
---
 kernel/trace/trace_fprobe.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/trace/trace_fprobe.c +5 -4
index 8bfe23af9c73..7d2ddbcfa377 100644
@@ -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;
 		}
 	}
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>