]> git.ipfire.org Git - thirdparty/lxc.git/commit
bpf: bpf_devices_cgroup_supported() should check if bpf() is available 3909/head
authorPetr Malat <oss@malat.biz>
Mon, 19 Jul 2021 10:28:45 +0000 (12:28 +0200)
committerPetr Malat <oss@malat.biz>
Tue, 20 Jul 2021 15:51:23 +0000 (17:51 +0200)
commit7bf85dd20e986133324ef9d7232a2e70742d9d72
tree21d45ca70f85b19650ffdb21ab4c146fe80053dc
parent0a755306618f7f0aa450d439c34a86d8c8683682
bpf: bpf_devices_cgroup_supported() should check if bpf() is available

bpf_devices_cgroup_supported() tries to load a simple BPF program to
test if BPF works. This is problematic because the function used to load
the program - bpf_program_load_kernel() - emits an error to the log if
BPF is not enabled in the kernel although device controller is not
requested in the configuration. Users could interpret that as a problem.

Make bpf_devices_cgroup_supported() check if the BPF syscall is available
before calling bpf_program_load_kernel(). We can do it by passing a NULL
pointer instead of the syscall argument as the kernel returns either
ENOSYS, when the syscall is not implemented or EFAULT, when it is
implemented.

Signed-off-by: Petr Malat <oss@malat.biz>
src/lxc/cgroups/cgroup2_devices.c