* [PATCH] perf/x86/amd/ibs: Don't leak stack contents through PERF_SAMPLE_WEIGHT_STRUCT
@ 2026-11-23 16:23 Usama Arif
0 siblings, 0 replies; only message in thread
From: Usama Arif @ 2026-11-23 16:23 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, james.clark, tglx, bp,
dave.hansen, x86, hpa, ravi.bangoria, linux-perf-users,
linux-kernel, rkeilty, atish.patra, dgreid, riel, shakeel.butt,
kernel-team
Cc: Usama Arif, stable
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>
---
arch/x86/events/amd/ibs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
index 66e67e27224f18..9aa47751b37f6c 100644
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -1376,6 +1376,7 @@ static void perf_ibs_parse_ld_st_data(__u64 sample_type,
if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) {
data->weight.var1_dw = op_data3.dc_miss_lat;
data->weight.var2_w = op_data.tag_to_ret_ctr;
+ data->weight.var3_w = 0;
} else if (sample_type & PERF_SAMPLE_WEIGHT) {
data->weight.full = op_data3.dc_miss_lat;
}
--
2.53.1-Meta
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-23 16:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 16:23 [PATCH] perf/x86/amd/ibs: Don't leak stack contents through PERF_SAMPLE_WEIGHT_STRUCT Usama Arif
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®