Linux Trace Kernel
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: JunYoung Lee <ljyoung04@gmail.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-trace-kernel@vger.kernel.org,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: Require kallsyms permission for the .function filter modifier
Date: Thu, 19 Nov 2026 08:56:32 -0500	[thread overview]
Message-ID: <20261119085632.60cc7df3@gandalf.local.home> (raw)
In-Reply-To: <20261119025941.87102-1-ljyoung04@gmail.com>

On Thu, 19 Nov 2026 11:59:41 +0900
JunYoung Lee <ljyoung04@gmail.com> wrote:

> 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.
> 

The code in kernel/trace are all privileged commands. If perf is the one
allowing unprivileged users access to these commands then the checks need
to be done in the perf code. It's not up to the trace code to handle perf
permissions.

This fix should not touch any code in kernel/trace/*

So NAK on this approach.

-- Steve


      parent reply	other threads:[~2026-11-19 13:56 UTC|newest]

Thread overview: 3+ 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
2026-11-19 13:56 ` Steven Rostedt [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=20261119085632.60cc7df3@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=ljyoung04@gmail.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=peterz@infradead.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