Skip to contentSkip to conversation

tracing/kprobes: Add missing check for skipping symbol counting logic

PATCH In review Nikolay Kuratov 2 participants 2 messages Jul 4, 2024 – Jul 5, 2024 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing/kprobes: Add missing check for skipping symbol counting logic

In commit b022f0c7e404
("tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols") it was already done for symbol in __trace_kprobe_create(), but func in create_local_trace_kprobe() is also valid usage.
Not doing so leads to ENOENT for module_name:symbol_name constructions passed over perf_event_open().

Fixes b022f0c7e404 ("tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols")
---
 kernel/trace/trace_kprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_kprobe.c +1 -1
index 16383247bdbf..3f4c9195dc0d 100644
@@ -1834,7 +1834,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
 	int ret;
 	char *event;
 
-	if (func) {
+	if (func && !strchr(func, ':')) {
 		unsigned int count;
 
 		count = number_of_same_symbols(func);
Signature · 1 line
2.34.1
#1 lore raw

Hi Nikolay,

Thanks for the patch! But this remind me that I forgot to send a patch which can solve this issue more generically.

https://lore.kernel.org/all/171338679446.616570.14456856697191949345.stgit@devnote2/

Why I did not send it...? Anyway let me send the update.

Thank you,

Quoted 29 lines · On Thu, 4 Jul 2024 19:43:36 +0300 Nikolay Kuratov <[email protected]> wrote:

In commit b022f0c7e404
("tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols") it was already done for symbol in __trace_kprobe_create(), but func in create_local_trace_kprobe() is also valid usage.
Not doing so leads to ENOENT for module_name:symbol_name constructions passed over perf_event_open().

Fixes b022f0c7e404 ("tracing/kprobes: Return EADDRNOTAVAIL when func matches several symbols")
---
 kernel/trace/trace_kprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_kprobe.c +1 -1
index 16383247bdbf..3f4c9195dc0d 100644
@@ -1834,7 +1834,7 @@ create_local_trace_kprobe(char *func, void *addr, unsigned long offs,
 	int ret;
 	char *event;
 
-	if (func) {
+	if (func && !strchr(func, ':')) {
 		unsigned int count;
 
 		count = number_of_same_symbols(func);
Signature · 1 line
2.34.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>