Skip to content

Commit 21da747

Browse files
sumanthkorikkarPeter Zijlstra
authored andcommitted
bpf: Fix sample_flags for bpf_perf_event_output
* Raw data is also filled by bpf_perf_event_output. * Add sample_flags to indicate raw data. * This eliminates the segfaults as shown below: 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) Fixes: 838d9bb ("perf: Use sample_flags for raw_data") Signed-off-by: Sumanth Korikkar <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Namhyung Kim <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 23488ec commit 21da747

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/trace/bpf_trace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, map,
687687

688688
perf_sample_data_init(sd, 0, 0);
689689
sd->raw = &raw;
690+
sd->sample_flags |= PERF_SAMPLE_RAW;
690691

691692
err = __bpf_perf_event_output(regs, map, flags, sd);
692693

@@ -745,6 +746,7 @@ u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
745746
perf_fetch_caller_regs(regs);
746747
perf_sample_data_init(sd, 0, 0);
747748
sd->raw = &raw;
749+
sd->sample_flags |= PERF_SAMPLE_RAW;
748750

749751
ret = __bpf_perf_event_output(regs, map, flags, sd);
750752
out:

0 commit comments

Comments
 (0)