[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240710100521.15061-2-vbabka@suse.cz>
Date: Wed, 10 Jul 2024 12:05:22 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: andrii@...nel.org,
ast@...nel.org,
bpf@...r.kernel.org,
daniel@...earbox.net,
eddyz87@...il.com,
haoluo@...gle.com,
javier.carrasco.cruz@...il.com,
john.fastabend@...il.com,
jolsa@...nel.org,
kent.overstreet@...ux.dev,
kpsingh@...nel.org,
linux-kernel@...r.kernel.org,
lists@...dbynature.de,
lstoakes@...il.com,
martin.lau@...ux.dev,
peter.ujfalusi@...el.com,
regressions@...ts.linux.dev,
sdf@...gle.com,
sheharyaar48@...il.com,
song@...nel.org,
surenb@...gle.com,
vbabka@...e.cz,
yonghong.song@...ux.dev
Subject: [PATCH for 6.10] bpf: fix order of args in call to bpf_map_kvcalloc
From: Mohammad Shehar Yaar Tausif <sheharyaar48@...il.com>
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@...nel.org>
Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@...il.com>
Signed-off-by: Vlastimil Babka <vbabka@...e.cz>
---
kernel/bpf/bpf_local_storage.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c
index 976cb258a0ed..c938dea5ddbf 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;
--
2.45.2
Powered by blists - more mailing lists