[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CE965785-D811-4E37-8EFB-0FCF79F69A04@fb.com>
Date: Tue, 27 Sep 2022 21:50:36 +0000
From: Song Liu <songliubraving@...com>
To: Jiri Olsa <jolsa@...nel.org>
CC: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Kan Liang <kan.liang@...ux.intel.com>,
lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Mark Rutland <mark.rutland@....com>,
Namhyung Kim <namhyung@...nel.org>,
"bpf@...r.kernel.org" <bpf@...r.kernel.org>,
Daniel Xu <dxu@...uu.xyz>
Subject: Re: [PATCH -tip] bpf: Check flags for branch stack in
bpf_read_branch_records helper
> On Sep 27, 2022, at 2:49 PM, Song Liu <songliubraving@...com> wrote:
>
>
>
>> On Sep 27, 2022, at 1:32 PM, Jiri Olsa <jolsa@...nel.org> wrote:
>>
>> 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")
>>
>> Cc: Kan Liang <kan.liang@...ux.intel.com>
>> Fixes: a9a931e26668 ("perf: Use sample_flags for branch stack")
>> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Acked-by: Song Liu <song@...nel.org>
>
> Thanks for the fix! I noticed the issue last week, but haven't
> got time to look into it.
>
> Song
>
>> ---
>> NOTE sending on top of tip/master because [1] is not
>> merged in bpf-next/master yet
>>
>> 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 68e5cdd24cef..1fcd1234607e 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;
>>
>> --
>> 2.37.3
Powered by blists - more mailing lists