From: Sumanth Korikkar <sumanthk@linux.ibm.com>
To: tip-bot2@linutronix.de
Cc: linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org,
namhyung@kernel.org, peterz@infradead.org, x86@kernel.org,
iii@linux.ibm.com, gor@linux.ibm.com, hca@linux.ibm.com,
svens@linux.ibm.com, tmricht@linux.ibm.com, bpf@vger.kernel.org,
Sumanth Korikkar <sumanthk@linux.ibm.com>
Subject: [PATCH] Re: [tip: perf/core] perf: Use sample_flags for raw_data
Date: Thu, 6 Oct 2022 18:00:44 +0200 [thread overview]
Message-ID: <20221006160044.3397237-1-sumanthk@linux.ibm.com> (raw)
In-Reply-To: <166434824149.401.4361243714612738808.tip-bot2@tip-bot2>
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
next prev parent reply other threads:[~2022-10-06 16:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-21 22:00 [PATCH 1/2] perf: Use sample_flags for addr Namhyung Kim
2022-09-21 22:00 ` [PATCH 2/2] perf: Use sample_flags for raw_data Namhyung Kim
2022-09-28 6:57 ` [tip: perf/core] " tip-bot2 for Namhyung Kim
2022-10-06 16:00 ` Sumanth Korikkar [this message]
2022-10-06 17:12 ` [PATCH] " Namhyung Kim
2022-10-06 18:58 ` Jiri Olsa
2022-10-07 8:13 ` [PATCH] bpf: fix sample_flags for bpf_perf_event_output Sumanth Korikkar
2022-10-07 9:45 ` Jiri Olsa
2022-10-07 15:18 ` Peter Zijlstra
2022-10-19 4:57 ` Alexei Starovoitov
2022-10-21 1:36 ` Alexei Starovoitov
2022-10-23 1:16 ` bpf+perf is still broken. Was: " Alexei Starovoitov
2022-10-23 16:55 ` Linus Torvalds
2022-10-23 17:19 ` Linus Torvalds
2022-10-23 17:28 ` Alexei Starovoitov
2022-10-17 14:45 ` [tip: perf/urgent] bpf: Fix " tip-bot2 for Sumanth Korikkar
2022-10-17 19:27 ` [PATCH] bpf: fix " SeongJae Park
2022-10-17 22:52 ` Namhyung Kim
2022-10-17 23:35 ` SeongJae Park
2022-10-19 10:44 ` [tip: perf/core] perf: Use sample_flags for raw_data Athira Rajeev
2022-09-22 14:48 ` [PATCH 1/2] perf: Use sample_flags for addr Peter Zijlstra
2022-09-22 16:32 ` Namhyung Kim
2022-09-22 20:55 ` [PATCH] perf: Change the layout of perf_sample_data Namhyung Kim
2022-09-23 7:45 ` [PATCH 1/2] perf: Use sample_flags for addr Peter Zijlstra
2022-09-28 6:57 ` [tip: perf/core] " tip-bot2 for Namhyung Kim
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=20221006160044.3397237-1-sumanthk@linux.ibm.com \
--to=sumanthk@linux.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=svens@linux.ibm.com \
--cc=tip-bot2@linutronix.de \
--cc=tmricht@linux.ibm.com \
--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