]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Allow bpf_user_ringbuf_drain() callbacks to return 1
authorDavid Vernet <void@manifault.com>
Wed, 12 Oct 2022 23:20:14 +0000 (18:20 -0500)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 13 Oct 2022 15:27:37 +0000 (08:27 -0700)
commit6fa86f66d73c5d7c96343846bcfa04dead4be24a
treed5c701b0b956aa03464e0714ec7dbbcb537d15b6
parentfbec4f635a5c55a2bf6122528a4a93a6a5ad7b9c
bpf: Allow bpf_user_ringbuf_drain() callbacks to return 1

The bpf_user_ringbuf_drain() helper function allows a BPF program to
specify a callback that is invoked when draining entries from a
BPF_MAP_TYPE_USER_RINGBUF ring buffer map. The API is meant to allow the
callback to return 0 if it wants to continue draining samples, and 1 if
it's done draining. Unfortunately, bpf_user_ringbuf_drain() landed shortly
after commit 6ec39f76ece6 ("bpf: Add verifier support for custom
callback return range"), which changed the default behavior of callbacks
to only support returning 0.

This patch corrects that oversight by allowing bpf_user_ringbuf_drain()
callbacks to return 0 or 1. A follow-on patch will update the
user_ringbuf selftests to also return 1 from a bpf_user_ringbuf_drain()
callback to prevent this from regressing in the future.

Fixes: 63de7fba60cc ("bpf: Add bpf_user_ringbuf_drain() helper")
Signed-off-by: David Vernet <void@manifault.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221012232015.1510043-2-void@manifault.com
kernel/bpf/verifier.c