[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <166434823927.401.13847148343207516601.tip-bot2@tip-bot2>
Date: Wed, 28 Sep 2022 06:57:19 -0000
From: "tip-bot2 for Jiri Olsa" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Jiri Olsa <jolsa@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Kan Liang <kan.liang@...ux.intel.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: perf/core] bpf: Check flags for branch stack in
bpf_read_branch_records helper
The following commit has been merged into the perf/core branch of tip:
Commit-ID: cce6a2d7e0e494c453ad73e1e78bd50684f20cca
Gitweb: https://git.kernel.org/tip/cce6a2d7e0e494c453ad73e1e78bd50684f20cca
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Tue, 27 Sep 2022 22:32:59 +02:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Tue, 27 Sep 2022 22:50:25 +02:00
bpf: Check flags for branch stack in bpf_read_branch_records helper
Recent commit [1] changed branch stack data indication from
br_stack pointer to sample_flags in perf_sample_data struct.
We need to check sample_flags for PERF_SAMPLE_BRANCH_STACK
bit for valid branch stack data.
[1] a9a931e26668 ("perf: Use sample_flags for branch stack")
Fixes: a9a931e26668 ("perf: Use sample_flags for branch stack")
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Kan Liang <kan.liang@...ux.intel.com>
Link: https://lore.kernel.org/r/20220927203259.590950-1-jolsa@kernel.org
---
kernel/trace/bpf_trace.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 68e5cdd..1fcd123 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1507,6 +1507,9 @@ BPF_CALL_4(bpf_read_branch_records, struct bpf_perf_event_data_kern *, ctx,
if (unlikely(flags & ~BPF_F_GET_BRANCH_RECORDS_SIZE))
return -EINVAL;
+ if (unlikely(!(ctx->data->sample_flags & PERF_SAMPLE_BRANCH_STACK)))
+ return -ENOENT;
+
if (unlikely(!br_stack))
return -ENOENT;
Powered by blists - more mailing lists