lkml.org 
[lkml]   [2020]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.4 210/312] bpf, trace: check event type in bpf_perf_event_read
    Date
    From: Alexei Starovoitov <ast@fb.com>

    commit ad572d174787daa59e24b8b5c83028c09cdb5ddb upstream.

    similar to bpf_perf_event_output() the bpf_perf_event_read() helper
    needs to check the type of the perf_event before reading the counter.

    Fixes: a43eec304259 ("bpf: introduce bpf_perf_event_output() helper")
    Reported-by: Daniel Borkmann <daniel@iogearbox.net>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Acked-by: Daniel Borkmann <daniel@iogearbox.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    kernel/trace/bpf_trace.c | 4 ++++
    1 file changed, 4 insertions(+)

    --- a/kernel/trace/bpf_trace.c
    +++ b/kernel/trace/bpf_trace.c
    @@ -206,6 +206,10 @@ static u64 bpf_perf_event_read(u64 r1, u
    event->pmu->count)
    return -EINVAL;

    + if (unlikely(event->attr.type != PERF_TYPE_HARDWARE &&
    + event->attr.type != PERF_TYPE_RAW))
    + return -EINVAL;
    +
    /*
    * we don't know if the function is run successfully by the
    * return value. It can be judged in other places, such as

    \
     
     \ /
      Last update: 2020-05-08 15:17    [W:4.028 / U:0.176 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site