bpf: Allow usage of BPF ringbuffer in sleepable programs
authorKP Singh <kpsingh@kernel.org>
Thu, 4 Feb 2021 19:36:21 +0000 (19:36 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 5 Feb 2021 00:35:00 +0000 (16:35 -0800)
commitba90c2cc0231124d6de63576e8bdf371e92c8fd3
treed73401b0c9eb95ec9c8d8a9fccdaedaed62e6496
parentec45c5faa2f4b3d53d6c04a334eb51d37d90cb56
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 <kpsingh@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210204193622.3367275-2-kpsingh@kernel.org
kernel/bpf/verifier.c