From: Dominik Maier <dmnk@google.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org, dmnk+artist@google.com,
Dominik Maier <dmnk@google.com>
Subject: [PATCH] tracing: check kallsyms_show_value() for numeric addresses in .function filter
Date: Thu, 19 Nov 2026 20:22:33 +0100 [thread overview]
Message-ID: <20261119192233.2664654-1-dmnk@google.com> (raw)
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
reply other threads:[~2026-11-19 19:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119192233.2664654-1-dmnk@google.com \
--to=dmnk@google.com \
--cc=dmnk+artist@google.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).