Skip to contentSkip to conversation

tracing: react to error return from traceprobe_parse_event_name()

PATCH Superseded Lukas Bulwahn 2 participants 3 messages Aug 10, 2022 – Aug 11, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: react to error return from traceprobe_parse_event_name()

The function traceprobe_parse_event_name() may set the first two function arguments to a non-null value and still return -EINVAL to indicate an unsuccessful completion of the function. Hence, it is not sufficient to just check the result of the two function arguments for being not null, but the return value also needs to be checked.

Commit 95c104c378dc ("tracing: Auto generate event name when creating a group of events") changed the error-return-value checking of the second traceprobe_parse_event_name() invocation in __trace_eprobe_create() and removed checking the return value to jump to the error handling case.

Reinstate using the return value in the error-return-value checking.

---
 kernel/trace/trace_eprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_eprobe.c +1 -1
index 4a0e9d927443..460d3ec8a256 100644
@@ -883,7 +883,7 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 	trace_probe_log_set_index(1);
 	sys_event = argv[1];
 	ret = traceprobe_parse_event_name(&sys_event, &sys_name, buf2, 0);
-	if (!sys_event || !sys_name) {
+	if (!ret || !sys_event || !sys_name) {
 		trace_probe_log_err(0, NO_EVENT_INFO);
 		goto parse_error;
 	}
Signature · 1 line
2.17.1
#1 lore raw

hi Lukas,

Quoted 23 lines · Lukas Bulwahn

The function traceprobe_parse_event_name() may set the first two function arguments to a non-null value and still return -EINVAL to indicate an unsuccessful completion of the function. Hence, it is not sufficient to just check the result of the two function arguments for being not null, but the return value also needs to be checked.

Commit 95c104c378dc ("tracing: Auto generate event name when creating a group of events") changed the error-return-value checking of the second traceprobe_parse_event_name() invocation in __trace_eprobe_create() and removed checking the return value to jump to the error handling case.

Reinstate using the return value in the error-return-value checking.

---
  kernel/trace/trace_eprobe.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_eprobe.c +0 -0
index 4a0e9d927443..460d3ec8a256 100644

kernel/trace/trace_eprobe.c static int __trace_eprobe_create(int argc, const char *argv[]) · line 886

Quoted 5 lines
kernel/trace/trace_eprobe.c +1 -1
@@ -883,7 +883,7 @@ static int __trace_eprobe_create(int argc, const char *argv[])
  	trace_probe_log_set_index(1);
  	sys_event = argv[1];
  	ret = traceprobe_parse_event_name(&sys_event, &sys_name, buf2, 0);
-	if (!sys_event || !sys_name) {
+	if (!ret || !sys_event || !sys_name) {

that's right, miss case sys_event and sys_name are not null, but invalid.

it should be  if (ret || ...)  ?

Quoted 3 lines
kernel/trace/trace_eprobe.c +0 -0
  		trace_probe_log_err(0, NO_EVENT_INFO);
  		goto parse_error;
  	}
#2 lore raw
Quoted 35 lines · Linyu Yuan

hi Lukas,

Quoted 23 lines · Lukas Bulwahn

The function traceprobe_parse_event_name() may set the first two function arguments to a non-null value and still return -EINVAL to indicate an unsuccessful completion of the function. Hence, it is not sufficient to just check the result of the two function arguments for being not null, but the return value also needs to be checked.

Commit 95c104c378dc ("tracing: Auto generate event name when creating a group of events") changed the error-return-value checking of the second traceprobe_parse_event_name() invocation in __trace_eprobe_create() and removed checking the return value to jump to the error handling case.

Reinstate using the return value in the error-return-value checking.

---
  kernel/trace/trace_eprobe.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_eprobe.c +0 -0
index 4a0e9d927443..460d3ec8a256 100644

kernel/trace/trace_eprobe.c static int __trace_eprobe_create(int argc, const char *argv[]) · line 886

Quoted 5 lines
kernel/trace/trace_eprobe.c +1 -1
@@ -883,7 +883,7 @@ static int __trace_eprobe_create(int argc, const char *argv[])
      trace_probe_log_set_index(1);
      sys_event = argv[1];
      ret = traceprobe_parse_event_name(&sys_event, &sys_name, buf2, 0);
-     if (!sys_event || !sys_name) {
+     if (!ret || !sys_event || !sys_name) {

that's right, miss case sys_event and sys_name are not null, but invalid.

Quoted 2 lines

it should be if (ret || ...) ?

Linyu, you are right. The visual symmetry tricked me into believing the line above was right, but it is clearly wrong if you think about it and look at the other invocation.

I send out a corrected patch v2:

https://lore.kernel.org/all/[email protected]/

Please review, ack and pick the patch v2. Thanks.

Lukas