Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Usama Arif" <usama.arif@linux.dev>, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/3] perf/core: Don't let BPF programs read an uninitialized sample address
Date: Thu, 19 Nov 2026 21:18:35 +0000	[thread overview]
Message-ID: <sashiko-outbox-224087@kernel.org> (raw)
In-Reply-To: <20261119211235.99805-3-usama.arif@linux.dev>

> A BPF program attached to a perf event gets a struct
> bpf_perf_event_data, and reading its addr field turns into a load from
> the perf_sample_data the sample is being assembled in. The verifier
> allows that load no matter which fields the event samples.
> 
> perf_sample_data_init() used to store the address unconditionally, so
> the program read 0 when there was none. To touch fewer cachelines, it
> now stores the address only when it is non-zero, and
> perf_prepare_sample() fills it in only when the event samples it
> (PERF_SAMPLE_ADDR, PHYS_ADDR or DATA_PAGE_SIZE). For all other events,
> including context switches, cpu-clock and hardware counters like
> cycles, the program reads whatever was left in that stack slot, often a
> kernel pointer.
> 
> Kernels built with CONFIG_INIT_STACK_ALL_ZERO, the default when the
> compiler supports it, mostly hide this by clearing the struct on
> function entry. With INIT_STACK_ALL_PATTERN the program reads the fill
> pattern instead.
> 
> Clear the address before running the program if nobody filled it in,
> the same way the SIGTRAP path already checks PERF_SAMPLE_ADDR before
> using it. Events without a BPF program are not affected.
> 
> Fixes: 7b0846301531 ("perf: Use sample_flags for addr")
> Cc: stable@vger.kernel.org
> Signed-off-by: Usama Arif <usama.arif@linux.dev>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119211235.99805-1-usama.arif@linux.dev?part=2


  reply	other threads:[~2026-11-19 21:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 21:10 [PATCH 0/3] perf/core: Fix software event sample data, then stop zeroing it Usama Arif
2026-11-19 21:10 ` [PATCH 1/3] perf/core: Fix perf_sample_data reuse across software events Usama Arif
2026-11-19 21:16   ` sashiko-bot
2026-11-19 21:10 ` [PATCH 2/3] perf/core: Don't let BPF programs read an uninitialized sample address Usama Arif
2026-11-19 21:18   ` sashiko-bot [this message]
2026-11-19 21:10 ` [PATCH 3/3] perf/core: Don't zero perf_sample_data in do_perf_sw_event() Usama Arif
2026-11-19 21:19   ` sashiko-bot

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-224087@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=usama.arif@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