[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221006160044.3397237-1-sumanthk@linux.ibm.com>
Date: Thu, 6 Oct 2022 18:00:44 +0200
From: Sumanth Korikkar <sumanthk@...ux.ibm.com>
To: tip-bot2@...utronix.de
Cc: linux-kernel@...r.kernel.org, linux-tip-commits@...r.kernel.org,
namhyung@...nel.org, peterz@...radead.org, x86@...nel.org,
iii@...ux.ibm.com, gor@...ux.ibm.com, hca@...ux.ibm.com,
svens@...ux.ibm.com, tmricht@...ux.ibm.com, bpf@...r.kernel.org,
Sumanth Korikkar <sumanthk@...ux.ibm.com>
Subject: [PATCH] Re: [tip: perf/core] perf: Use sample_flags for raw_data
Hi,
This causes segfaults.
Steps to recreate:
* Run ./samples/bpf/trace_output
BUG pid 9 cookie 1001000000004 sized 4
BUG pid 9 cookie 1001000000004 sized 4
BUG pid 9 cookie 1001000000004 sized 4
Segmentation fault (core dumped)
Problem:
* The following commit sets data->raw to NULL, when the raw data is not filled
by PMU driver. This leads to stale data.
* raw data could also be filled by bpf_perf_event_output(), bpf_event_output()
...
686 perf_sample_data_init(sd, 0, 0);
687 sd->raw = &raw;
688
689 err = __bpf_perf_event_output(regs, map, flags, sd);
...
* The below patch eliminates segfaults. However, contradicts with
the description mentioned in this commit (Filled by only PMU driver).
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 49fb9ec8366d..1ed08967fb97 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -687,6 +687,7 @@ BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, map,
perf_sample_data_init(sd, 0, 0);
sd->raw = &raw;
+ sd->sample_flags |= PERF_SAMPLE_RAW;
err = __bpf_perf_event_output(regs, map, flags, sd);
@@ -745,6 +746,7 @@ u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
perf_fetch_caller_regs(regs);
perf_sample_data_init(sd, 0, 0);
sd->raw = &raw;
+ sd->sample_flags |= PERF_SAMPLE_RAW;
ret = __bpf_perf_event_output(regs, map, flags, sd);
out:
--
Thanks,
Sumanth
Powered by blists - more mailing lists