From: KP Singh Date: Thu, 4 Feb 2021 19:36:21 +0000 (+0000) Subject: bpf: Allow usage of BPF ringbuffer in sleepable programs X-Git-Tag: v5.15~1802^2~28^2~44^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba90c2cc0231124d6de63576e8bdf371e92c8fd3;p=platform%2Fkernel%2Flinux-starfive.git bpf: Allow usage of BPF ringbuffer in sleepable programs The BPF ringbuffer map is pre-allocated and the implementation logic does not rely on disabling preemption or per-cpu data structures. Using the BPF ringbuffer sleepable LSM and tracing programs does not trigger any warnings with DEBUG_ATOMIC_SLEEP, DEBUG_PREEMPT, PROVE_RCU and PROVE_LOCKING and LOCKDEP enabled. This allows helpers like bpf_copy_from_user and bpf_ima_inode_hash to write to the BPF ring buffer from sleepable BPF programs. Signed-off-by: KP Singh Signed-off-by: Andrii Nakryiko Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20210204193622.3367275-2-kpsingh@kernel.org --- diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 5e09632..9749081 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -10024,9 +10024,11 @@ static int check_map_prog_compatibility(struct bpf_verifier_env *env, return -EINVAL; } break; + case BPF_MAP_TYPE_RINGBUF: + break; default: verbose(env, - "Sleepable programs can only use array and hash maps\n"); + "Sleepable programs can only use array, hash, and ringbuf maps\n"); return -EINVAL; }