Patch "bpf: Exempt CAP_BPF from checks against bpf_jit_limit" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bpf: Exempt CAP_BPF from checks against bpf_jit_limit

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bpf-exempt-cap_bpf-from-checks-against-bpf_jit_limit.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1c0b35735d11c241f3f67b3883cb51addc81ca6c
Author: Lorenz Bauer <lmb@xxxxxxxxxxxxxx>
Date:   Wed Sep 22 12:11:52 2021 +0100

    bpf: Exempt CAP_BPF from checks against bpf_jit_limit
    
    [ Upstream commit 8a98ae12fbefdb583a7696de719a1d57e5e940a2 ]
    
    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@xxxxxxxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20210922111153.19843-1-lmb@xxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index d12efb2550d3..2e4a658d65d6 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -831,7 +831,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;
 		}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux