diff mbox series

[bpf] bpf: exempt CAP_BPF from checks against bpf_jit_limit

Message ID 20210922111153.19843-1-lmb@cloudflare.com (mailing list archive)
State Accepted
Commit 7c3a00911b3d179e54d139d5354caf53e8c7ed33
Delegated to: BPF
Headers show
Series [bpf] bpf: exempt CAP_BPF from checks against bpf_jit_limit | expand

Checks

Context Check Description
bpf/vmtest-bpf success VM_Test
bpf/vmtest-bpf-PR success PR summary
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf
netdev/subject_prefix success Link
netdev/cc_maintainers warning 6 maintainers not CCed: kpsingh@kernel.org john.fastabend@gmail.com yhs@fb.com andrii@kernel.org songliubraving@fb.com kafai@fb.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 10 this patch: 10
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 10 this patch: 10
netdev/header_inline success Link

Commit Message

Lorenz Bauer Sept. 22, 2021, 11:11 a.m. UTC
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: 2c78ee898d8f ("bpf: Implement CAP_BPF")
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
 kernel/bpf/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org Sept. 22, 2021, 9:40 p.m. UTC | #1
Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

On Wed, 22 Sep 2021 12:11:52 +0100 you wrote:
> 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.
> 
> [...]

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
diff mbox series

Patch

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 6fddc13fe67f..ea8a468dbded 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -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;
 		}