Skip to contentSkip to conversation

tracing/probe: Fix same probe event argument matching

PATCH In review Srikar Dronamraju 2 participants 2 messages Sep 24, 2019 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing/probe: Fix same probe event argument matching

Commit fe60b0ce8e73 ("tracing/probe: Reject exactly same probe event") tries to reject a event which matches an already existing probe.

However it currently continues to match arguments and rejects adding a probe even when the arguments don't match. Fix this by only rejecting a probe if and only if all the arguments match.

Fixes fe60b0ce8e73 ("tracing/probe: Reject exactly same probe event")
---
 kernel/trace/trace_kprobe.c | 5 +++--
 kernel/trace/trace_uprobe.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
kernel/trace/trace_kprobe.c +3 -2
index a6697e28ddda..402dc3ce88d3 100644
@@ -549,10 +549,11 @@ static bool trace_kprobe_has_same_kprobe(struct trace_kprobe *orig,
 		for (i = 0; i < orig->tp.nr_args; i++) {
 			if (strcmp(orig->tp.args[i].comm,
 				   comp->tp.args[i].comm))
-				continue;
+				break;
 		}
 
-		return true;
+		if (i == orig->tp.nr_args)
+			return true;
 	}
 
 	return false;
kernel/trace/trace_uprobe.c +3 -2
index 34dd6d0016a3..dd884341f5c5 100644
@@ -431,10 +431,11 @@ static bool trace_uprobe_has_same_uprobe(struct trace_uprobe *orig,
 		for (i = 0; i < orig->tp.nr_args; i++) {
 			if (strcmp(orig->tp.args[i].comm,
 				   comp->tp.args[i].comm))
-				continue;
+				break;
 		}
 
-		return true;
+		if (i == orig->tp.nr_args)
+			return true;
 	}
 
 	return false;
Signature · 1 line
2.18.1
maintainer Acked-by on v1 1/1
#1 lore raw

Hi Srikar,

Quoted 6 lines · On Tue, 24 Sep 2019 17:19:06 +0530 Srikar Dronamraju…

Commit fe60b0ce8e73 ("tracing/probe: Reject exactly same probe event") tries to reject a event which matches an already existing probe.

However it currently continues to match arguments and rejects adding a probe even when the arguments don't match. Fix this by only rejecting a probe if and only if all the arguments match.

Thank you for fixing!
This looks good to me.

Quoted 47 lines
Fixes fe60b0ce8e73 ("tracing/probe: Reject exactly same probe event")
---
 kernel/trace/trace_kprobe.c | 5 +++--
 kernel/trace/trace_uprobe.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
kernel/trace/trace_kprobe.c +3 -2
index a6697e28ddda..402dc3ce88d3 100644
@@ -549,10 +549,11 @@ static bool trace_kprobe_has_same_kprobe(struct trace_kprobe *orig,
 		for (i = 0; i < orig->tp.nr_args; i++) {
 			if (strcmp(orig->tp.args[i].comm,
 				   comp->tp.args[i].comm))
-				continue;
+				break;
 		}
 
-		return true;
+		if (i == orig->tp.nr_args)
+			return true;
 	}
 
 	return false;
kernel/trace/trace_uprobe.c +3 -2
index 34dd6d0016a3..dd884341f5c5 100644
@@ -431,10 +431,11 @@ static bool trace_uprobe_has_same_uprobe(struct trace_uprobe *orig,
 		for (i = 0; i < orig->tp.nr_args; i++) {
 			if (strcmp(orig->tp.args[i].comm,
 				   comp->tp.args[i].comm))
-				continue;
+				break;
 		}
 
-		return true;
+		if (i == orig->tp.nr_args)
+			return true;
 	}
 
 	return false;
Signature · 1 line
2.18.1
Signature · 1 line
Masami Hiramatsu <[email protected]>