Patch "bpf: Fix off-by-one error in bpf_mem_cache_idx()" has been added to the 6.1-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: Fix off-by-one error in bpf_mem_cache_idx()

to the 6.1-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-fix-off-by-one-error-in-bpf_mem_cache_idx.patch
and it can be found in the queue-6.1 subdirectory.

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



commit 17874deb379044d0d0e75b0e7d5ba9b8042c6be1
Author: Hou Tao <houtao1@xxxxxxxxxx>
Date:   Wed Jan 18 16:46:30 2023 +0800

    bpf: Fix off-by-one error in bpf_mem_cache_idx()
    
    [ Upstream commit 36024d023d139a0c8b552dc3b7f4dc7b4c139e8f ]
    
    According to the definition of sizes[NUM_CACHES], when the size passed
    to bpf_mem_cache_size() is 256, it should return 6 instead 7.
    
    Fixes: 7c8199e24fa0 ("bpf: Introduce any context BPF specific memory allocator.")
    Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx>
    Acked-by: Yonghong Song <yhs@xxxxxx>
    Link: https://lore.kernel.org/r/20230118084630.3750680-1-houtao@xxxxxxxxxxxxxxx
    Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/bpf/memalloc.c b/kernel/bpf/memalloc.c
index 4901fa1048cd..6187c28d266f 100644
--- a/kernel/bpf/memalloc.c
+++ b/kernel/bpf/memalloc.c
@@ -71,7 +71,7 @@ static int bpf_mem_cache_idx(size_t size)
 	if (size <= 192)
 		return size_index[(size - 1) / 8] - 1;
 
-	return fls(size - 1) - 1;
+	return fls(size - 1) - 2;
 }
 
 #define NUM_CACHES 11



[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