From: sashiko-bot@kernel.org
To: "JunYoung Lee" <ljyoung04@gmail.com>
Cc: linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] tracing: Require kallsyms permission for the .function filter modifier
Date: Thu, 19 Nov 2026 03:12:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-222370@kernel.org> (raw)
In-Reply-To: <20261119025941.87102-1-ljyoung04@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] tracing: unstripped cover letter and scissors line in commit
message
--
commit 8240d9570c52f6cf2edfd9796cbc32ecb0f181af
Author: JunYoung Lee <ljyoung04@gmail.com>
> tracing: Require kallsyms permission for the .function filter modifier
>
> Hi Steven, Masami,
>
> An unprivileged user can locate the kernel image (KASLR bypass) with
> PERF_EVENT_IOC_SET_FILTER at the default perf_event_paranoid=2.
> parse_pred() accepts "<field>.function == <addr>" only if the address
> resolves in kallsyms, and the perf path has no permission check, so the
> ioctl result tells whether an address is kernel text. The details and
> the fix are in the patch below.
>
> Affected (reproduced as uid 65534, KASLR on), since e6745a4da964 (v6.3):
> - mainline 4405c18c95d2 (v7.4-rc3-230)
> - stable 6.12.118
>
> Example on mainline: a counting event on ftrace:print (field "ip") and
> 561 probes return image_start=0xffffffffa1000000 and
> image_end=0xffffffffaae30000. These equal _stext and _end in
> /proc/kallsyms as read by root; the same user sees zeros there. No
> tracefs and no capabilities are needed. Not affected:
> perf_event_paranoid > 2, or perf_event_open blocked.
>
> A C reproducer is available privately on request.
>
> Testing of the patch on mainline with KASAN: for an unprivileged user
> every .function form now fails with -EINVAL, and ordinary filters still
> work. Root keeps .function via perf and tracefs (it is refused under
> kptr_restrict=2, like kallsyms values). ftrace selftests test.d/filter
> pass 4/4. checkpatch --strict and W=1 are clean. A 6.12.y backport is
> available.
>
> A separate issue seen while testing: as root, a .function filter on the
> perf function event (ftrace:function) crashes the kernel with a NULL
> dereference in ftrace_function_set_filter_pred(), because pred->regex
> is not set on the .function path. It needs CAP_PERFMON. I can send
> details if useful.
>
> Found with AI-assisted code analysis. All results come from test runs.
>
> Thanks,
> JunYoung Lee
>
> -- >8 --
> "<field>.function == <operand>" resolves the operand to a kernel symbol
> range. parse_pred() accepts the predicate only if
> kallsyms_lookup_size_offset() succeeds, so the result of setting the
> filter tells whether an address lies inside the kernel image (or a
> module).
>
> perf_event_open() allows any user to open a tracepoint event for
> counting at the default perf_event_paranoid=2, and
> PERF_EVENT_IOC_SET_FILTER passes the string to the same parser without
> a permission check. An unprivileged user can therefore probe addresses
> one ioctl at a time and recover _stext and _end exactly (about 560
> ioctls on x86-64, under two seconds), while /proc/kallsyms shows that
> user zeros.
>
> Apply the rule that /proc/kallsyms uses, kallsyms_show_value() on the
> current credentials, before the operand is looked at, so both the
> numeric and the symbol name form are refused to callers who may not
> see kernel addresses. Root and CAP_SYSLOG keep the modifier under the
> default kptr_restrict. With kptr_restrict=2 it is refused to everyone,
> the same as kallsyms values are hidden from everyone.
>
> Fixes: e6745a4da964 ("tracing: Add a way to filter function addresses to function names")
> Cc: stable@vger.kernel.org
> Signed-off-by: JunYoung Lee <ljyoung04@gmail.com>
[Severity: Low]
This isn't a bug, but the commit message retains the email greeting, notes
for the maintainers, and the "-- >8 --" scissors line above the actual
changelog. Transient commentary intended for maintainers belongs below the
"---" separator after the Signed-off-by trailer (or should be stripped with
"git am --scissors") so it does not end up in permanent git history.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119025941.87102-1-ljyoung04@gmail.com?part=1
prev parent reply other threads:[~2026-11-19 3:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 2:59 [PATCH] tracing: Require kallsyms permission for the .function filter modifier JunYoung Lee
2026-11-19 3:12 ` sashiko-bot [this message]
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=sashiko-outbox-222370@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=ljyoung04@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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