diff options
author | Song Liu <songliubraving@fb.com> | 2020-07-23 11:06:45 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-07-25 20:16:34 -0700 |
commit | 5d99cb2c86775b4780c02a339a9578bf9471ead9 (patch) | |
tree | 25c9829e8b83c8066b286c414821fac40a4e3c04 /include/linux/filter.h | |
parent | 7b04d6d60fcfb5b2200ffebb9cfb90927bdfeec7 (diff) | |
download | linux-stable-5d99cb2c86775b4780c02a339a9578bf9471ead9.tar.gz linux-stable-5d99cb2c86775b4780c02a339a9578bf9471ead9.tar.bz2 linux-stable-5d99cb2c86775b4780c02a339a9578bf9471ead9.zip |
bpf: Fail PERF_EVENT_IOC_SET_BPF when bpf_get_[stack|stackid] cannot work
bpf_get_[stack|stackid] on perf_events with precise_ip uses callchain
attached to perf_sample_data. If this callchain is not presented, do not
allow attaching BPF program that calls bpf_get_[stack|stackid] to this
event.
In the error case, -EPROTO is returned so that libbpf can identify this
error and print proper hint message.
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200723180648.1429892-3-songliubraving@fb.com
Diffstat (limited to 'include/linux/filter.h')
-rw-r--r-- | include/linux/filter.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h index d07a6e973a7d..0a355b005bf4 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -533,7 +533,8 @@ struct bpf_prog { is_func:1, /* program is a bpf function */ kprobe_override:1, /* Do we override a kprobe? */ has_callchain_buf:1, /* callchain buffer allocated? */ - enforce_expected_attach_type:1; /* Enforce expected_attach_type checking at attach time */ + enforce_expected_attach_type:1, /* Enforce expected_attach_type checking at attach time */ + call_get_stack:1; /* Do we call bpf_get_stack() or bpf_get_stackid() */ enum bpf_prog_type type; /* Type of BPF program */ enum bpf_attach_type expected_attach_type; /* For some prog types */ u32 len; /* Number of filter blocks */ |