aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/kernel/bpf
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2020-07-23 11:06:45 -0700
committerAlexei Starovoitov <ast@kernel.org>2020-07-25 20:16:34 -0700
commit5d99cb2c86775b4780c02a339a9578bf9471ead9 (patch)
tree25c9829e8b83c8066b286c414821fac40a4e3c04 /kernel/bpf
parentbpf: Separate bpf_get_[stack|stackid] for perf events BPF (diff)
downloadwireguard-linux-5d99cb2c86775b4780c02a339a9578bf9471ead9.tar.xz
wireguard-linux-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 'kernel/bpf')
-rw-r--r--kernel/bpf/verifier.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 8d6979db48d8..cd14e70f2d07 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4962,6 +4962,9 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn
env->prog->has_callchain_buf = true;
}
+ if (func_id == BPF_FUNC_get_stackid || func_id == BPF_FUNC_get_stack)
+ env->prog->call_get_stack = true;
+
if (changes_data)
clear_all_pkt_pointers(env);
return 0;