bpf: Handle bpf_mprog_query with NULL entry
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 6 Oct 2023 22:06:50 +0000 (00:06 +0200)
committerMartin KaFai Lau <martin.lau@kernel.org>
Sat, 7 Oct 2023 00:11:20 +0000 (17:11 -0700)
commitedfa9af0a73ecc2000d7bb81d0b0fd3158cc9a65
tree2fa48698f2b0cfb93be08203381e12cc6b5c4c03
parenta4fe78386afb94780f8e6fcd10a67c4d4dfe4da8
bpf: Handle bpf_mprog_query with NULL entry

Improve consistency for bpf_mprog_query() API and let the latter also handle
a NULL entry as can be the case for tcx. Instead of returning -ENOENT, we
copy a count of 0 and revision of 1 to user space, so that this can be fed
into a subsequent bpf_mprog_attach() call as expected_revision. A BPF self-
test as part of this series has been added to assert this case.

Suggested-by: Lorenz Bauer <lmb@isovalent.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20231006220655.1653-2-daniel@iogearbox.net
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
kernel/bpf/mprog.c
kernel/bpf/tcx.c