Subject: [PATCH] bpf: fix order of args in call to bpf_map_kvcalloc

The original function call passed size of smap->bucket before the number of
buckets which raises the error 'calloc-transposed-args' on compilation.

Signed-off-by: Mohammad Shehar Yaar Tausif <[email protected]>
---
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.1



2024-05-17 03:10:47

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] bpf: fix order of args in call to bpf_map_kvcalloc

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <[email protected]>:

On Thu, 16 May 2024 12:54:11 +0530 you wrote:
> The original function call passed size of smap->bucket before the number of
> buckets which raises the error 'calloc-transposed-args' on compilation.
>
> Signed-off-by: Mohammad Shehar Yaar Tausif <[email protected]>
> ---
> kernel/bpf/bpf_local_storage.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
- bpf: fix order of args in call to bpf_map_kvcalloc
https://git.kernel.org/bpf/bpf-next/c/71ed6c266348

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



2024-06-12 05:20:37

by Péter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH] bpf: fix order of args in call to bpf_map_kvcalloc

Hi,

On 17/05/2024 06:10, [email protected] wrote:
> Hello:
>
> This patch was applied to bpf/bpf-next.git (master)

Can you send this patch for the current 6.10 cycle as a fix as well?

HEAD:
2ef5971ff345 Merge tag 'vfs-6.10-rc4.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

head -n 6 Makefile
# SPDX-License-Identifier: GPL-2.0
VERSION = 6
PATCHLEVEL = 10
SUBLEVEL = 0
EXTRAVERSION = -rc3
NAME = Baby Opossum Posse

gcc --version
gcc (GCC) 14.1.1 20240522

kernel/bpf/bpf_local_storage.c: In function ‘bpf_local_storage_map_alloc’:
kernel/bpf/bpf_local_storage.c:785:60: error: ‘kvmalloc_array_node_noprof’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
785 | smap->buckets = bpf_map_kvcalloc(&smap->map, sizeof(*smap->buckets),

Thank you,
Péter

> by Andrii Nakryiko <[email protected]>:
>
> On Thu, 16 May 2024 12:54:11 +0530 you wrote:
>> The original function call passed size of smap->bucket before the number of
>> buckets which raises the error 'calloc-transposed-args' on compilation.
>>
>> Signed-off-by: Mohammad Shehar Yaar Tausif <[email protected]>
>> ---
>> kernel/bpf/bpf_local_storage.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Here is the summary with links:
> - bpf: fix order of args in call to bpf_map_kvcalloc
> https://git.kernel.org/bpf/bpf-next/c/71ed6c266348
>
> You are awesome, thank you!
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.