* [PATCH bpf] bpf: exempt CAP_BPF from checks against bpf_jit_limit
@ 2021-09-22 11:11 Lorenz Bauer
2021-09-22 21:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Lorenz Bauer @ 2021-09-22 11:11 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann
Cc: kernel-team, Lorenz Bauer, netdev, bpf, linux-kernel
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(-)
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;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf] bpf: exempt CAP_BPF from checks against bpf_jit_limit
2021-09-22 11:11 [PATCH bpf] bpf: exempt CAP_BPF from checks against bpf_jit_limit Lorenz Bauer
@ 2021-09-22 21:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-09-22 21:40 UTC (permalink / raw)
To: Lorenz Bauer; +Cc: ast, daniel, kernel-team, netdev, bpf, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-22 21:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 11:11 [PATCH bpf] bpf: exempt CAP_BPF from checks against bpf_jit_limit Lorenz Bauer
2021-09-22 21:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).