Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf/core: Check kernel access for text poke and ksymbol events
@ 2026-10-06 22:52 Kyle Zeng
  2026-10-06 23:02 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Kyle Zeng @ 2026-10-06 22:52 UTC (permalink / raw)
  To: linux-perf-users
  Cc: linux-kernel, peterz, mingo, acme, namhyung, outbounddisclosures,
	Kyle Zeng

PERF_RECORD_TEXT_POKE contains kernel text addresses and the old and new
instruction bytes. PERF_RECORD_KSYMBOL similarly exposes kernel symbol
addresses. Both records are delivered independently of exclude_kernel,
but perf_event_open() does not check kernel access when their respective
attributes are requested.

With perf_event_paranoid=2, an unprivileged task can therefore open a
user-only software event with text_poke set and observe kernel text
patches. Opening and closing permitted counting-only tracepoint events
can produce these records through static-call updates, disclosing
relocated kernel text and branch targets.

Include ksymbol and text_poke in the existing perf_allow_kernel() check.
This authorizes the source event before allocation, also covering
inherited events and output redirection, while retaining the existing
sideband behavior for callers allowed to observe the kernel.

Fixes: e17d43b93e54 ("perf: Add perf text poke event")
Fixes: 76193a94522f ("perf, bpf: Introduce PERF_RECORD_KSYMBOL")
Assisted-by: Codex:gpt-6-astra
Signed-off-by: Kyle Zeng <kylebot@openai.com>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index db7b76d6b68a..7301b320f746 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -13946,7 +13946,7 @@ SYSCALL_DEFINE5(perf_event_open,
 	if (err)
 		return err;
 
-	if (!attr.exclude_kernel ||
+	if (!attr.exclude_kernel || attr.ksymbol || attr.text_poke ||
 	    ((attr.sample_type & PERF_SAMPLE_CALLCHAIN) &&
 	     !attr.exclude_callchain_kernel)) {
 		err = perf_allow_kernel();

base-commit: fd179f8a05be3ccae366b9b96e176b51fbe54aab
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf/core: Check kernel access for text poke and ksymbol events
  2026-10-06 22:52 [PATCH] perf/core: Check kernel access for text poke and ksymbol events Kyle Zeng
@ 2026-10-06 23:02 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-06 23:02 UTC (permalink / raw)
  To: Kyle Zeng; +Cc: linux-perf-users

> PERF_RECORD_TEXT_POKE contains kernel text addresses and the old and new
> instruction bytes. PERF_RECORD_KSYMBOL similarly exposes kernel symbol
> addresses. Both records are delivered independently of exclude_kernel,
> but perf_event_open() does not check kernel access when their respective
> attributes are requested.
> 
> With perf_event_paranoid=2, an unprivileged task can therefore open a
> user-only software event with text_poke set and observe kernel text
> patches. Opening and closing permitted counting-only tracepoint events
> can produce these records through static-call updates, disclosing
> relocated kernel text and branch targets.
> 
> Include ksymbol and text_poke in the existing perf_allow_kernel() check.
> This authorizes the source event before allocation, also covering
> inherited events and output redirection, while retaining the existing
> sideband behavior for callers allowed to observe the kernel.
> 
> Fixes: e17d43b93e54 ("perf: Add perf text poke event")
> Fixes: 76193a94522f ("perf, bpf: Introduce PERF_RECORD_KSYMBOL")
> Assisted-by: Codex:gpt-6-astra
> Signed-off-by: Kyle Zeng <kylebot@openai.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006225248.54708-1-kylebot@openai.com?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-06 23:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-06 22:52 [PATCH] perf/core: Check kernel access for text poke and ksymbol events Kyle Zeng
2026-10-06 23:02 ` sashiko-bot

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