Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH] tracing: check kallsyms_show_value() for numeric addresses in .function filter
@ 2026-11-19 19:22 Dominik Maier
  0 siblings, 0 replies; only message in thread
From: Dominik Maier @ 2026-11-19 19:22 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu
  Cc: Mathieu Desnoyers, linux-trace-kernel, dmnk+artist, Dominik Maier

In parse_pred(), the .function filter modifier accepts either a symbol
name or a raw numeric kernel address (such as 0xffffffff81000000) and
resolves it through kallsyms_lookup_size_offset().

While tracefs defaults to mode 0700, task-scoped counting tracepoint
events can be opened via perf_event_open() under default
perf_event_paranoid = 2 and configured via PERF_EVENT_IOC_SET_FILTER.
Allowing raw numeric addresses in .function predicates without checking
kallsyms_show_value(current_cred()) lets callers without kallsyms
address visibility test whether candidate kernel addresses fall within a
valid symbol despite kptr_restrict.

Gate raw numeric address parsing in the .function branch of parse_pred()
on kallsyms_show_value(current_cred()), matching other tracing paths
such as trace_kprobe and bpf_trace while keeping symbol-name filtering
unchanged.

This issue was discovered with an AI-assisted code review tool (ARTIST)
and reproduced in QEMU/KVM on an unmodified v7.4-rc3 kernel without
kernel modifications or error injection. The fix was verified against
the reproducer in QEMU/KVM, compile-tested with -Werror, and checked
with checkpatch.pl --strict.

Fixes: e6745a4da964 ("tracing: Add a way to filter function addresses to function names")
Signed-off-by: Dominik Maier <dmnk@google.com>
---
 kernel/trace/trace_events_filter.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index c10951b..9192f3e 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -8,6 +8,7 @@
 #include <linux/uaccess.h>
 #include <linux/module.h>
 #include <linux/ctype.h>
+#include <linux/kallsyms.h>
 #include <linux/mutex.h>
 #include <linux/perf_event.h>
 #include <linux/slab.h>
@@ -1760,6 +1761,10 @@ static int parse_pred(const char *str, void *data,
 		}
 
 		if (isdigit(str[i])) {
+			if (!kallsyms_show_value(current_cred())) {
+				parse_error(pe, FILT_ERR_INVALID_VALUE, pos + i);
+				goto err_free;
+			}
 			/* We allow 0xDEADBEEF */
 			while (isalnum(str[i]))
 				i++;
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-19 19:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 19:22 [PATCH] tracing: check kallsyms_show_value() for numeric addresses in .function filter Dominik Maier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox