]> git.baikalelectronics.ru Git - kernel.git/commit
tools: bpftool: Allow unprivileged users to probe features
authorQuentin Monnet <quentin@isovalent.com>
Wed, 29 Apr 2020 14:45:05 +0000 (15:45 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 29 Apr 2020 21:25:11 +0000 (23:25 +0200)
commitf0d14b8f22570c3fb56e705f1e9be7ac18671cca
treef2890e332ccafa9c1130f91b1aae9b17f01dc2de
parent2daa197bc7b1ebcacd95967099b0d430ce1c5b47
tools: bpftool: Allow unprivileged users to probe features

There is demand for a way to identify what BPF helper functions are
available to unprivileged users. To do so, allow unprivileged users to
run "bpftool feature probe" to list BPF-related features. This will only
show features accessible to those users, and may not reflect the full
list of features available (to administrators) on the system.

To avoid the case where bpftool is inadvertently run as non-root and
would list only a subset of the features supported by the system when it
would be expected to list all of them, running as unprivileged is gated
behind the "unprivileged" keyword passed to the command line. When used
by a privileged user, this keyword allows to drop the CAP_SYS_ADMIN and
to list the features available to unprivileged users. Note that this
addsd a dependency on libpcap for compiling bpftool.

Note that there is no particular reason why the probes were restricted
to root, other than the fact I did not need them for unprivileged and
did not bother with the additional checks at the time probes were added.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200429144506.8999-3-quentin@isovalent.com
tools/bpf/bpftool/Documentation/bpftool-feature.rst
tools/bpf/bpftool/Makefile
tools/bpf/bpftool/bash-completion/bpftool
tools/bpf/bpftool/feature.c