Skip to content

Commit 8a98ae1

Browse files
lmbborkmann
authored andcommitted
bpf: Exempt CAP_BPF from checks against bpf_jit_limit
When introducing CAP_BPF, bpf_jit_charge_modmem() was not changed to treat programs with CAP_BPF as privileged for the purpose of JIT memory allocation. This means that a program without CAP_BPF can block a program with CAP_BPF from loading a program. Fix this by checking bpf_capable() in bpf_jit_charge_modmem(). Fixes: 2c78ee8 ("bpf: Implement CAP_BPF") Signed-off-by: Lorenz Bauer <lmb@cloudflare.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210922111153.19843-1-lmb@cloudflare.com
1 parent 37cb28e commit 8a98ae1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎kernel/bpf/core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ int bpf_jit_charge_modmem(u32 pages)
827827
{
828828
if (atomic_long_add_return(pages, &bpf_jit_current) >
829829
(bpf_jit_limit >> PAGE_SHIFT)) {
830-
if (!capable(CAP_SYS_ADMIN)) {
830+
if (!bpf_capable()) {
831831
atomic_long_sub(pages, &bpf_jit_current);
832832
return -EPERM;
833833
}

0 commit comments

Comments
 (0)