From: Vlastimil Babka <vbabka@suse.cz>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org,
daniel@iogearbox.net, eddyz87@gmail.com, haoluo@google.com,
javier.carrasco.cruz@gmail.com, john.fastabend@gmail.com,
jolsa@kernel.org, kent.overstreet@linux.dev, kpsingh@kernel.org,
linux-kernel@vger.kernel.org, lists@nerdbynature.de,
lstoakes@gmail.com, martin.lau@linux.dev,
peter.ujfalusi@intel.com, regressions@lists.linux.dev,
sdf@google.com, sheharyaar48@gmail.com, song@kernel.org,
surenb@google.com, vbabka@suse.cz, yonghong.song@linux.dev
Subject: [PATCH for 6.10] bpf: fix order of args in call to bpf_map_kvcalloc
Date: Wed, 10 Jul 2024 12:05:22 +0200 [thread overview]
Message-ID: <20240710100521.15061-2-vbabka@suse.cz> (raw)
In-Reply-To: <CAADnVQK_ftwe5Dxtc0bopeDg2ku=GrFYrMOUWHLnXaK1bqoXXA@mail.gmail.com>
From: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.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@kernel.org>
Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.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
next prev parent reply other threads:[~2024-07-10 10:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 9:51 [PATCH RESEND] bpf: fix order of args in call to bpf_map_kvcalloc Mohammad Shehar Yaar Tausif
2024-06-12 14:53 ` Alexei Starovoitov
2024-07-08 8:20 ` Linux regression tracking (Thorsten Leemhuis)
2024-07-08 8:41 ` Lorenzo Stoakes
2024-07-09 15:14 ` Vlastimil Babka
2024-07-09 15:39 ` Suren Baghdasaryan
2024-07-09 18:11 ` Alexei Starovoitov
2024-07-10 10:05 ` Vlastimil Babka [this message]
2024-07-10 10:27 ` [PATCH for 6.10] " Christian Kujau
2024-07-10 22:36 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240710100521.15061-2-vbabka@suse.cz \
--to=vbabka@suse.cz \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lists@nerdbynature.de \
--cc=lstoakes@gmail.com \
--cc=martin.lau@linux.dev \
--cc=peter.ujfalusi@intel.com \
--cc=regressions@lists.linux.dev \
--cc=sdf@google.com \
--cc=sheharyaar48@gmail.com \
--cc=song@kernel.org \
--cc=surenb@google.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox