diff options
author | Peter Zijlstra <peterz@infradead.org> | 2019-01-29 04:21:52 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-02-19 23:53:07 +0300 |
commit | 568f196756ad9fe2b49c46bbf6a9de1b190438b4 (patch) | |
tree | a8c84a1e56786296cd005d6c7ca7ad741c2367ea /include/linux/filter.h | |
parent | a5d9265e017f081f0dc133c0e2f45103d027b874 (diff) | |
download | linux-568f196756ad9fe2b49c46bbf6a9de1b190438b4.tar.xz |
bpf: check that BPF programs run with preemption disabled
Introduce cant_sleep() macro for annotation of functions that
cannot sleep.
Use it in BPF_PROG_RUN to catch execution of BPF programs in
preemptable context.
Suggested-by: Jann Horn <jannh@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'include/linux/filter.h')
-rw-r--r-- | include/linux/filter.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h index 95e2d7ebdf21..f32b3eca5a04 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -533,7 +533,7 @@ struct sk_filter { struct bpf_prog *prog; }; -#define BPF_PROG_RUN(filter, ctx) (*(filter)->bpf_func)(ctx, (filter)->insnsi) +#define BPF_PROG_RUN(filter, ctx) ({ cant_sleep(); (*(filter)->bpf_func)(ctx, (filter)->insnsi); }) #define BPF_SKB_CB_LEN QDISC_CB_PRIV_LEN |