bpf: exempt CAP_BPF from checks against bpf_jit_limit
Subsystems (4)
PATCH 1/1 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.
--- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/core.c +1 -1
@@ -827,7 +827,7 @@ int bpf_jit_charge_modmem(u32 pages) {if (atomic_long_add_return (pages, &bpf_jit_current) > (bpf_jit_limit >>PAGE_SHIFT )) { -if (!capable (CAP_SYS_ADMIN )) { +if (!bpf_capable ()) {atomic_long_sub (pages, &bpf_jit_current);return -EPERM ; }
Signature · 1 line
2.30.2
This patch was applied to bpf/bpf.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf.git (refs/heads/master):
Quoted 8 lines · On Wed, 22 Sep 2021 12:11:52 +0100 you wrote:
When introducing
CAP_BPF,bpf_jit_charge_modmemwas not changed to treat programs withCAP_BPFas privileged for the purpose of JIT memory allocation. This means that a program withoutCAP_BPFcan block a program withCAP_BPFfrom loading a program.Fix this by checking
bpf_capableinbpf_jit_charge_modmem.[...]
Here is the summary with links:
- [bpf] bpf: exempt CAP_BPF from checks against bpf_jit_limit
https://git.kernel.org/bpf/bpf/c/7c3a00911b3d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html