* [PATCH RESEND] bpf: fix order of args in call to bpf_map_kvcalloc
@ 2024-06-12 9:51 Mohammad Shehar Yaar Tausif
2024-06-12 14:53 ` Alexei Starovoitov
0 siblings, 1 reply; 10+ messages in thread
From: Mohammad Shehar Yaar Tausif @ 2024-06-12 9:51 UTC (permalink / raw)
To: Martin KaFai Lau, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
Cc: bpf, linux-kernel, Javier Carrasco, Mohammad Shehar Yaar Tausif
The original function call passed size of smap->bucket before the number of
buckets which raises the error 'calloc-transposed-args' on compilation.
Fixes: 62827d612ae5 ("bpf: Remove __bpf_local_storage_map_alloc")
Reviewed-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
---
- already merged in linux-next
- [1] suggested sending as a fix for 6.10 cycle
[1] https://lore.kernel.org/all/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
---
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;
---
base-commit: 2ef5971ff345d3c000873725db555085e0131961
change-id: 20240612-master-fe9e63ab5c95
Best regards,
--
Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH RESEND] bpf: fix order of args in call to bpf_map_kvcalloc
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)
0 siblings, 1 reply; 10+ messages in thread
From: Alexei Starovoitov @ 2024-06-12 14:53 UTC (permalink / raw)
To: Mohammad Shehar Yaar Tausif
Cc: Martin KaFai Lau, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
bpf, LKML, Javier Carrasco
On Wed, Jun 12, 2024 at 2:51 AM Mohammad Shehar Yaar Tausif
<sheharyaar48@gmail.com> wrote:
>
> The original function call passed size of smap->bucket before the number of
> buckets which raises the error 'calloc-transposed-args' on compilation.
>
> Fixes: 62827d612ae5 ("bpf: Remove __bpf_local_storage_map_alloc")
> Reviewed-by: Andrii Nakryiko <andrii@kernel.org>
> Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
> ---
> - already merged in linux-next
> - [1] suggested sending as a fix for 6.10 cycle
No. It's not a fix.
pw-bot: cr
>
> [1] https://lore.kernel.org/all/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
> ---
> 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;
>
> ---
> base-commit: 2ef5971ff345d3c000873725db555085e0131961
> change-id: 20240612-master-fe9e63ab5c95
>
> Best regards,
> --
> Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RESEND] bpf: fix order of args in call to bpf_map_kvcalloc
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
0 siblings, 2 replies; 10+ messages in thread
From: Linux regression tracking (Thorsten Leemhuis) @ 2024-07-08 8:20 UTC (permalink / raw)
To: Alexei Starovoitov, Mohammad Shehar Yaar Tausif
Cc: Martin KaFai Lau, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
bpf, LKML, Javier Carrasco, Christian Kujau, Péter Ujfalusi,
Lorenzo Stoakes, Linux kernel regressions list
[CCing the regressions list and people mentioned below]
On 12.06.24 16:53, Alexei Starovoitov wrote:
> On Wed, Jun 12, 2024 at 2:51 AM Mohammad Shehar Yaar Tausif
> <sheharyaar48@gmail.com> wrote:
>>
>> The original function call passed size of smap->bucket before the number of
>> buckets which raises the error 'calloc-transposed-args' on compilation.
>>
>> Fixes: 62827d612ae5 ("bpf: Remove __bpf_local_storage_map_alloc")
>> Reviewed-by: Andrii Nakryiko <andrii@kernel.org>
>> Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
>> ---
>> - already merged in linux-next
>> - [1] suggested sending as a fix for 6.10 cycle
>
> No. It's not a fix.
If you have a minute, could you please explain why that is? From what I
can see a quite a few people run into build problems with 6.10-rc
recently that are fixed by the patch:
* Péter Ujfalusi
https://lore.kernel.org/bpf/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
* Christian Kujau
https://lore.kernel.org/bpf/48360912-b239-51f2-8f25-07a46516dc76@nerdbynature.de/
https://lore.kernel.org/lkml/d0dd2457-ab58-1b08-caa4-93eaa2de221e@nerdbynature.de/
* Lorenzo Stoakes
https://fosstodon.org/@ljs@social.kernel.org/112734050799590482
At the same time I see that the culprit mentioned above is from 6.4-rc1,
so I guess it there must be some other reason why a few people seem to
tun into this now. Did some other change expose this problem? Or are
updated compilers causing this?
Ciao, Thorsten
>> [1] https://lore.kernel.org/all/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
>> ---
>> 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;
>>
>> ---
>> base-commit: 2ef5971ff345d3c000873725db555085e0131961
>> change-id: 20240612-master-fe9e63ab5c95
>>
>> Best regards,
>> --
>> Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
>>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RESEND] bpf: fix order of args in call to bpf_map_kvcalloc
2024-07-08 8:20 ` Linux regression tracking (Thorsten Leemhuis)
@ 2024-07-08 8:41 ` Lorenzo Stoakes
2024-07-09 15:14 ` Vlastimil Babka
1 sibling, 0 replies; 10+ messages in thread
From: Lorenzo Stoakes @ 2024-07-08 8:41 UTC (permalink / raw)
To: Linux regressions mailing list
Cc: Alexei Starovoitov, Mohammad Shehar Yaar Tausif, Martin KaFai Lau,
Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Song Liu, Yonghong Song, John Fastabend,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf, LKML,
Javier Carrasco, Christian Kujau, Péter Ujfalusi,
Lorenzo Stoakes
On Mon, Jul 08, 2024 at 10:20:33AM GMT, Linux regression tracking (Thorsten Leemhuis) wrote:
> [CCing the regressions list and people mentioned below]
>
> On 12.06.24 16:53, Alexei Starovoitov wrote:
> > On Wed, Jun 12, 2024 at 2:51 AM Mohammad Shehar Yaar Tausif
> > <sheharyaar48@gmail.com> wrote:
> >>
> >> The original function call passed size of smap->bucket before the number of
> >> buckets which raises the error 'calloc-transposed-args' on compilation.
> >>
> >> Fixes: 62827d612ae5 ("bpf: Remove __bpf_local_storage_map_alloc")
> >> Reviewed-by: Andrii Nakryiko <andrii@kernel.org>
> >> Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
> >> ---
> >> - already merged in linux-next
> >> - [1] suggested sending as a fix for 6.10 cycle
> >
> > No. It's not a fix.
>
> If you have a minute, could you please explain why that is? From what I
> can see a quite a few people run into build problems with 6.10-rc
> recently that are fixed by the patch:
This is explicitly breaking my build in Linus's kernel (and subsequently
mm-unstable where I hit it first).
I have gcc 14.1.1, and can easily repro this with a defconfig on x86-64 with:
make mrproper && make defconfig && scripts/config --enable bpf_syscall && \
make olddefconfig && make -j $(nproc)
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 laterargument
[-Werror=calloc-transposed-args]
785 | smap->buckets = bpf_map_kvcalloc(&smap->map, sizeof(*smap->buckets),
It's kind of surprising no build bot caught this (maybe somebody needs to
look into that), but it's proactively causing problems right now, I have to
keep the kernel patched in order for it to build.
So a fix of some kind is needed, urgently.
>
> * Péter Ujfalusi
> https://lore.kernel.org/bpf/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
>
> * Christian Kujau
> https://lore.kernel.org/bpf/48360912-b239-51f2-8f25-07a46516dc76@nerdbynature.de/
> https://lore.kernel.org/lkml/d0dd2457-ab58-1b08-caa4-93eaa2de221e@nerdbynature.de/
>
> * Lorenzo Stoakes
> https://fosstodon.org/@ljs@social.kernel.org/112734050799590482
>
> At the same time I see that the culprit mentioned above is from 6.4-rc1,
> so I guess it there must be some other reason why a few people seem to
> tun into this now. Did some other change expose this problem? Or are
> updated compilers causing this?
I suspect the latter. It seems x86-64 defconfig unables CONFIG_WERROR by default.
>
> Ciao, Thorsten
>
> >> [1] https://lore.kernel.org/all/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
> >> ---
> >> 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;
> >>
> >> ---
> >> base-commit: 2ef5971ff345d3c000873725db555085e0131961
> >> change-id: 20240612-master-fe9e63ab5c95
> >>
> >> Best regards,
> >> --
> >> Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
> >>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RESEND] bpf: fix order of args in call to bpf_map_kvcalloc
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
1 sibling, 1 reply; 10+ messages in thread
From: Vlastimil Babka @ 2024-07-09 15:14 UTC (permalink / raw)
To: Linux regressions mailing list, Alexei Starovoitov,
Mohammad Shehar Yaar Tausif
Cc: Martin KaFai Lau, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
bpf, LKML, Javier Carrasco, Christian Kujau, Péter Ujfalusi,
Lorenzo Stoakes, Suren Baghdasaryan, Kent Overstreet
On 7/8/24 10:20 AM, Linux regression tracking (Thorsten Leemhuis) wrote:
> [CCing the regressions list and people mentioned below]
>
> On 12.06.24 16:53, Alexei Starovoitov wrote:
>> On Wed, Jun 12, 2024 at 2:51 AM Mohammad Shehar Yaar Tausif
>> <sheharyaar48@gmail.com> wrote:
>>>
>>> The original function call passed size of smap->bucket before the number of
>>> buckets which raises the error 'calloc-transposed-args' on compilation.
>>>
>>> Fixes: 62827d612ae5 ("bpf: Remove __bpf_local_storage_map_alloc")
>>> Reviewed-by: Andrii Nakryiko <andrii@kernel.org>
>>> Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
>>> ---
>>> - already merged in linux-next
>>> - [1] suggested sending as a fix for 6.10 cycle
>>
>> No. It's not a fix.
>
> If you have a minute, could you please explain why that is? From what I
> can see a quite a few people run into build problems with 6.10-rc
> recently that are fixed by the patch:
>
> * Péter Ujfalusi
> https://lore.kernel.org/bpf/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
>
> * Christian Kujau
> https://lore.kernel.org/bpf/48360912-b239-51f2-8f25-07a46516dc76@nerdbynature.de/
> https://lore.kernel.org/lkml/d0dd2457-ab58-1b08-caa4-93eaa2de221e@nerdbynature.de/
>
> * Lorenzo Stoakes
> https://fosstodon.org/@ljs@social.kernel.org/112734050799590482
>
> At the same time I see that the culprit mentioned above is from 6.4-rc1,
IIUC the order was wrong even before, but see below.
> so I guess it there must be some other reason why a few people seem to
> tun into this now. Did some other change expose this problem? Or are
> updated compilers causing this?
I think it's because of 2c321f3f70bc ("mm: change inlined allocation helpers
to account at the call site"), which was added in 6.10-rc1 and thus makes
this technically a 6.10 regression after all. So what triggers the bug is
AFAICS the following together:
- gcc-14 (didn't see it with gcc-13)
- commit 2c321f3f70bc that makes bpf_map_kvcalloc a macro that does
kvcalloc() directly instead of static inline function wrapping it for
!CONFIG_MEMCG
- CONFIG_MEMCG=n in .config
The fix is so trivial, it's better to include it in 6.10 even this late.
> Ciao, Thorsten
>
>>> [1] https://lore.kernel.org/all/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
>>> ---
>>> 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;
>>>
>>> ---
>>> base-commit: 2ef5971ff345d3c000873725db555085e0131961
>>> change-id: 20240612-master-fe9e63ab5c95
>>>
>>> Best regards,
>>> --
>>> Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
>>>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RESEND] bpf: fix order of args in call to bpf_map_kvcalloc
2024-07-09 15:14 ` Vlastimil Babka
@ 2024-07-09 15:39 ` Suren Baghdasaryan
2024-07-09 18:11 ` Alexei Starovoitov
0 siblings, 1 reply; 10+ messages in thread
From: Suren Baghdasaryan @ 2024-07-09 15:39 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Linux regressions mailing list, Alexei Starovoitov,
Mohammad Shehar Yaar Tausif, Martin KaFai Lau, Alexei Starovoitov,
Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, bpf, LKML, Javier Carrasco, Christian Kujau,
Péter Ujfalusi, Lorenzo Stoakes, Kent Overstreet
On Tue, Jul 9, 2024 at 8:14 AM Vlastimil Babka <vbabka@suse.cz> wrote:
>
> On 7/8/24 10:20 AM, Linux regression tracking (Thorsten Leemhuis) wrote:
> > [CCing the regressions list and people mentioned below]
> >
> > On 12.06.24 16:53, Alexei Starovoitov wrote:
> >> On Wed, Jun 12, 2024 at 2:51 AM Mohammad Shehar Yaar Tausif
> >> <sheharyaar48@gmail.com> wrote:
> >>>
> >>> The original function call passed size of smap->bucket before the number of
> >>> buckets which raises the error 'calloc-transposed-args' on compilation.
> >>>
> >>> Fixes: 62827d612ae5 ("bpf: Remove __bpf_local_storage_map_alloc")
> >>> Reviewed-by: Andrii Nakryiko <andrii@kernel.org>
> >>> Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
> >>> ---
> >>> - already merged in linux-next
> >>> - [1] suggested sending as a fix for 6.10 cycle
> >>
> >> No. It's not a fix.
> >
> > If you have a minute, could you please explain why that is? From what I
> > can see a quite a few people run into build problems with 6.10-rc
> > recently that are fixed by the patch:
> >
> > * Péter Ujfalusi
> > https://lore.kernel.org/bpf/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
> >
> > * Christian Kujau
> > https://lore.kernel.org/bpf/48360912-b239-51f2-8f25-07a46516dc76@nerdbynature.de/
> > https://lore.kernel.org/lkml/d0dd2457-ab58-1b08-caa4-93eaa2de221e@nerdbynature.de/
> >
> > * Lorenzo Stoakes
> > https://fosstodon.org/@ljs@social.kernel.org/112734050799590482
> >
> > At the same time I see that the culprit mentioned above is from 6.4-rc1,
>
> IIUC the order was wrong even before, but see below.
>
> > so I guess it there must be some other reason why a few people seem to
> > tun into this now. Did some other change expose this problem? Or are
> > updated compilers causing this?
>
> I think it's because of 2c321f3f70bc ("mm: change inlined allocation helpers
> to account at the call site"), which was added in 6.10-rc1 and thus makes
> this technically a 6.10 regression after all.
IIUC the above mentioned change reveals a problem that was there
before the change. So, it's a build regression in 6.10 because the bug
got exposed but the bug was introduced much earlier. The fix should be
marked as:
Fixes: ddef81b5fd1d ("bpf: use bpf_map_kvcalloc in bpf_local_storage")
> So what triggers the bug is
> AFAICS the following together:
>
> - gcc-14 (didn't see it with gcc-13)
> - commit 2c321f3f70bc that makes bpf_map_kvcalloc a macro that does
> kvcalloc() directly instead of static inline function wrapping it for
> !CONFIG_MEMCG
> - CONFIG_MEMCG=n in .config
>
> The fix is so trivial, it's better to include it in 6.10 even this late.
>
> > Ciao, Thorsten
> >
> >>> [1] https://lore.kernel.org/all/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
> >>> ---
> >>> 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;
> >>>
> >>> ---
> >>> base-commit: 2ef5971ff345d3c000873725db555085e0131961
> >>> change-id: 20240612-master-fe9e63ab5c95
> >>>
> >>> Best regards,
> >>> --
> >>> Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
> >>>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RESEND] bpf: fix order of args in call to bpf_map_kvcalloc
2024-07-09 15:39 ` Suren Baghdasaryan
@ 2024-07-09 18:11 ` Alexei Starovoitov
2024-07-10 10:05 ` [PATCH for 6.10] " Vlastimil Babka
0 siblings, 1 reply; 10+ messages in thread
From: Alexei Starovoitov @ 2024-07-09 18:11 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: Vlastimil Babka, Linux regressions mailing list,
Mohammad Shehar Yaar Tausif, Martin KaFai Lau, Alexei Starovoitov,
Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, bpf, LKML, Javier Carrasco, Christian Kujau,
Péter Ujfalusi, Lorenzo Stoakes, Kent Overstreet
On Tue, Jul 9, 2024 at 8:39 AM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Tue, Jul 9, 2024 at 8:14 AM Vlastimil Babka <vbabka@suse.cz> wrote:
> >
> > On 7/8/24 10:20 AM, Linux regression tracking (Thorsten Leemhuis) wrote:
> > > [CCing the regressions list and people mentioned below]
> > >
> > > On 12.06.24 16:53, Alexei Starovoitov wrote:
> > >> On Wed, Jun 12, 2024 at 2:51 AM Mohammad Shehar Yaar Tausif
> > >> <sheharyaar48@gmail.com> wrote:
> > >>>
> > >>> The original function call passed size of smap->bucket before the number of
> > >>> buckets which raises the error 'calloc-transposed-args' on compilation.
> > >>>
> > >>> Fixes: 62827d612ae5 ("bpf: Remove __bpf_local_storage_map_alloc")
> > >>> Reviewed-by: Andrii Nakryiko <andrii@kernel.org>
> > >>> Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com>
> > >>> ---
> > >>> - already merged in linux-next
> > >>> - [1] suggested sending as a fix for 6.10 cycle
> > >>
> > >> No. It's not a fix.
> > >
> > > If you have a minute, could you please explain why that is? From what I
> > > can see a quite a few people run into build problems with 6.10-rc
> > > recently that are fixed by the patch:
> > >
> > > * Péter Ujfalusi
> > > https://lore.kernel.org/bpf/363ad8d1-a2d2-4fca-b66a-3d838eb5def9@intel.com/
> > >
> > > * Christian Kujau
> > > https://lore.kernel.org/bpf/48360912-b239-51f2-8f25-07a46516dc76@nerdbynature.de/
> > > https://lore.kernel.org/lkml/d0dd2457-ab58-1b08-caa4-93eaa2de221e@nerdbynature.de/
> > >
> > > * Lorenzo Stoakes
> > > https://fosstodon.org/@ljs@social.kernel.org/112734050799590482
> > >
> > > At the same time I see that the culprit mentioned above is from 6.4-rc1,
> >
> > IIUC the order was wrong even before, but see below.
> >
> > > so I guess it there must be some other reason why a few people seem to
> > > tun into this now. Did some other change expose this problem? Or are
> > > updated compilers causing this?
> >
> > I think it's because of 2c321f3f70bc ("mm: change inlined allocation helpers
> > to account at the call site"), which was added in 6.10-rc1 and thus makes
> > this technically a 6.10 regression after all.
>
> IIUC the above mentioned change reveals a problem that was there
> before the change. So, it's a build regression in 6.10 because the bug
> got exposed but the bug was introduced much earlier. The fix should be
> marked as:
>
> Fixes: ddef81b5fd1d ("bpf: use bpf_map_kvcalloc in bpf_local_storage")
Not really. The order was flipped before that patch.
> > So what triggers the bug is
> > AFAICS the following together:
> >
> > - gcc-14 (didn't see it with gcc-13)
> > - commit 2c321f3f70bc that makes bpf_map_kvcalloc a macro that does
> > kvcalloc() directly instead of static inline function wrapping it for
> > !CONFIG_MEMCG
> > - CONFIG_MEMCG=n in .config
Can somebody respin the patch with above details?
tbh I don't think it qualifies as a "bug".
Plenty of code places mix up size/n arguments to calloc.
Erroring the build in such cases is imo wrong.
Not sure what makes gcc-14 produce such warn/error.
But since the patch is trivial we can get that in quickly.
Pls respin with all details.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH for 6.10] bpf: fix order of args in call to bpf_map_kvcalloc
2024-07-09 18:11 ` Alexei Starovoitov
@ 2024-07-10 10:05 ` Vlastimil Babka
2024-07-10 10:27 ` Christian Kujau
0 siblings, 1 reply; 10+ messages in thread
From: Vlastimil Babka @ 2024-07-10 10:05 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: andrii, ast, bpf, daniel, eddyz87, haoluo, javier.carrasco.cruz,
john.fastabend, jolsa, kent.overstreet, kpsingh, linux-kernel,
lists, lstoakes, martin.lau, peter.ujfalusi, regressions, sdf,
sheharyaar48, song, surenb, vbabka, yonghong.song
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH for 6.10] bpf: fix order of args in call to bpf_map_kvcalloc
2024-07-10 10:05 ` [PATCH for 6.10] " Vlastimil Babka
@ 2024-07-10 10:27 ` Christian Kujau
2024-07-10 22:36 ` Alexei Starovoitov
0 siblings, 1 reply; 10+ messages in thread
From: Christian Kujau @ 2024-07-10 10:27 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Alexei Starovoitov, andrii, ast, bpf, daniel, eddyz87, haoluo,
javier.carrasco.cruz, john.fastabend, jolsa, kent.overstreet,
kpsingh, linux-kernel, lstoakes, martin.lau, peter.ujfalusi,
regressions, sdf, sheharyaar48, song, surenb, yonghong.song
On Wed, 10 Jul 2024, Vlastimil Babka wrote:
> Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage")
Thanks for not forgetting about this! If this matters, just tested this
against today's mainline:
Tested-by: Christian Kujau <lists@nerdbynature.de>
C.
--
BOFH excuse #418:
Sysadmins busy fighting SPAM.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH for 6.10] bpf: fix order of args in call to bpf_map_kvcalloc
2024-07-10 10:27 ` Christian Kujau
@ 2024-07-10 22:36 ` Alexei Starovoitov
0 siblings, 0 replies; 10+ messages in thread
From: Alexei Starovoitov @ 2024-07-10 22:36 UTC (permalink / raw)
To: Christian Kujau
Cc: Vlastimil Babka, Andrii Nakryiko, Alexei Starovoitov, bpf,
Daniel Borkmann, Eddy Z, Hao Luo, Javier Carrasco, John Fastabend,
Jiri Olsa, Kent Overstreet, KP Singh, LKML, Lorenzo Stoakes,
Martin KaFai Lau, Péter Ujfalusi, Linux Regressions,
Stanislav Fomichev, Mohammad Shehar Yaar Tausif, Song Liu,
Suren Baghdasaryan, Yonghong Song
On Wed, Jul 10, 2024 at 3:27 AM Christian Kujau <lists@nerdbynature.de> wrote:
>
> On Wed, 10 Jul 2024, Vlastimil Babka wrote:
> > Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage")
>
> Thanks for not forgetting about this! If this matters, just tested this
> against today's mainline:
>
> Tested-by: Christian Kujau <lists@nerdbynature.de>
Thanks everyone. Applied to bpf tree.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-07-10 22:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH for 6.10] " Vlastimil Babka
2024-07-10 10:27 ` Christian Kujau
2024-07-10 22:36 ` Alexei Starovoitov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox