mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ravi Bangoria <ravi.bangoria@amd.com>
To: Usama Arif <usama.arif@linux.dev>
Cc: <stable@vger.kernel.org>, <peterz@infradead.org>,
	<mingo@redhat.com>, <acme@kernel.org>, <namhyung@kernel.org>,
	<mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>,
	<jolsa@kernel.org>, <irogers@google.com>,
	<adrian.hunter@intel.com>, <james.clark@linaro.org>,
	<tglx@kernel.org>, <bp@alien8.de>, <dave.hansen@linux.intel.com>,
	<x86@kernel.org>, <hpa@zytor.com>,
	<linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <rkeilty@meta.com>,
	<atish.patra@linux.dev>, <dgreid@meta.com>, <riel@surriel.com>,
	<shakeel.butt@linux.dev>, <kernel-team@meta.com>,
	Ravi Bangoria <ravi.bangoria@amd.com>
Subject: Re: [PATCH] perf/x86/amd/ibs: Don't leak stack contents through PERF_SAMPLE_WEIGHT_STRUCT
Date: Fri, 27 Nov 2026 17:46:55 +0530	[thread overview]
Message-ID: <78f43e25-7617-4b48-9e18-ca7be1011d54@amd.com> (raw)
In-Reply-To: <20261123162315.1142701-1-usama.arif@linux.dev>

> For a load that missed the data cache, perf_ibs_parse_ld_st_data()
> reports the miss latency as the sample weight and marks
> PERF_SAMPLE_WEIGHT_TYPE as done, so perf_prepare_sample() leaves the
> field alone. With PERF_SAMPLE_WEIGHT_STRUCT it writes only var1_dw and
> var2_w, but perf_output_sample() copies all 8 bytes of the union into
> the ring buffer. var3_w therefore carries whatever was left in the
> on-stack struct perf_sample_data in perf_ibs_handle_irq().
> 
> CONFIG_INIT_STACK_ALL_ZERO hides this by clearing the struct on entry.
> Without it, every such sample hands 2 bytes of kernel stack to user
> space. "perf mem record" asks for PERF_SAMPLE_WEIGHT_STRUCT on x86, and
> since v6.14 swfilt lets an unprivileged user sample their own tasks with
> IBS.
> 
> Write var3_w as well.
> 
> Fixes: 6b2ae4952ef8 ("perf/x86/amd: Support PERF_SAMPLE_{WEIGHT|WEIGHT_STRUCT}")
> Cc: stable@vger.kernel.org
> Signed-off-by: Usama Arif <usama.arif@linux.dev>

Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>

      reply	other threads:[~2026-11-27 12:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 16:23 Usama Arif
2026-11-27 12:16 ` Ravi Bangoria [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=78f43e25-7617-4b48-9e18-ca7be1011d54@amd.com \
    --to=ravi.bangoria@amd.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=atish.patra@linux.dev \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dgreid@meta.com \
    --cc=hpa@zytor.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=riel@surriel.com \
    --cc=rkeilty@meta.com \
    --cc=shakeel.butt@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=usama.arif@linux.dev \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®