Patch "bpf: fix order of args in call to bpf_map_kvcalloc" has been added to the 6.9-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 order of args in call to bpf_map_kvcalloc

to the 6.9-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-order-of-args-in-call-to-bpf_map_kvcalloc.patch
and it can be found in the queue-6.9 subdirectory.

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



commit ef52e72bd5b015852a4640b3d6f20921e7f2a716
Author: Mohammad Shehar Yaar Tausif <sheharyaar48@xxxxxxxxx>
Date:   Wed Jul 10 12:05:22 2024 +0200

    bpf: fix order of args in call to bpf_map_kvcalloc
    
    [ Upstream commit af253aef183a31ce62d2e39fc520b0ebfb562bb9 ]
    
    The original function call passed size of smap->bucket before the number of
    buckets which raises the error 'calloc-transposed-args' on compilation.
    
    Vlastimil Babka added:
    
    The order of parameters can be traced back all the way to 6ac99e8f23d4
    ("bpf: Introduce bpf sk local storage") accross several refactorings,
    and that's why the commit is used as a Fixes: tag.
    
    In v6.10-rc1, a different commit 2c321f3f70bc ("mm: change inlined
    allocation helpers to account at the call site") however exposed the
    order of args in a way that gcc-14 has enough visibility to start
    warning about it, because (in !CONFIG_MEMCG case) bpf_map_kvcalloc is
    then a macro alias for kvcalloc instead of a static inline wrapper.
    
    To sum up the warning happens when the following conditions are all met:
    
    - gcc-14 is used (didn't see it with gcc-13)
    - commit 2c321f3f70bc is present
    - CONFIG_MEMCG is not enabled in .config
    - CONFIG_WERROR turns this from a compiler warning to error
    
    Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage")
    Reviewed-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Tested-by: Christian Kujau <lists@xxxxxxxxxxxxxxx>
    Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@xxxxxxxxx>
    Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx>
    Link: https://lore.kernel.org/r/20240710100521.15061-2-vbabka@xxxxxxx
    Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c
index bdea1a459153c..bea5873d96d15 100644
--- a/kernel/bpf/bpf_local_storage.c
+++ b/kernel/bpf/bpf_local_storage.c
@@ -782,8 +782,8 @@ bpf_local_storage_map_alloc(union bpf_attr *attr,
 	nbuckets = max_t(u32, 2, nbuckets);
 	smap->bucket_log = ilog2(nbuckets);
 
-	smap->buckets = bpf_map_kvcalloc(&smap->map, sizeof(*smap->buckets),
-					 nbuckets, GFP_USER | __GFP_NOWARN);
+	smap->buckets = bpf_map_kvcalloc(&smap->map, nbuckets,
+					 sizeof(*smap->buckets), GFP_USER | __GFP_NOWARN);
 	if (!smap->buckets) {
 		err = -ENOMEM;
 		goto free_smap;




[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