* [PATCH] mm/mremap: fix uninitialized return code
@ 2025-03-05 17:27 Arnd Bergmann
2025-03-05 17:29 ` Lorenzo Stoakes
2025-03-05 18:46 ` Yosry Ahmed
0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2025-03-05 17:27 UTC (permalink / raw)
To: Andrew Morton, Liam R. Howlett, Lorenzo Stoakes
Cc: Arnd Bergmann, Vlastimil Babka, Jann Horn, Pedro Falcato,
David Hildenbrand, Kefeng Wang, Jeff Xu, linux-mm, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
The 'err' variable is set in a conditinal branch and is not
set otherwise:
mm/mremap.c:1017:7: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
1017 | if (vma->vm_start != old_addr)
Set it to zero before the initial value is set.
Fixes: 3129f7896afb ("mm/mremap: initial refactor of move_vma()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
mm/mremap.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/mremap.c b/mm/mremap.c
index 456849b9e7bd..9c51a2360d84 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -1014,6 +1014,7 @@ static unsigned long prep_move_vma(struct vma_remap_struct *vrm)
return -ENOMEM;
if (vma->vm_ops && vma->vm_ops->may_split) {
+ err = 0;
if (vma->vm_start != old_addr)
err = vma->vm_ops->may_split(vma, old_addr);
if (!err && vma->vm_end != old_addr + old_len)
--
2.39.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/mremap: fix uninitialized return code
2025-03-05 17:27 [PATCH] mm/mremap: fix uninitialized return code Arnd Bergmann
@ 2025-03-05 17:29 ` Lorenzo Stoakes
2025-03-05 18:25 ` Arnd Bergmann
2025-03-05 18:46 ` Yosry Ahmed
1 sibling, 1 reply; 5+ messages in thread
From: Lorenzo Stoakes @ 2025-03-05 17:29 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Andrew Morton, Liam R. Howlett, Arnd Bergmann, Vlastimil Babka,
Jann Horn, Pedro Falcato, David Hildenbrand, Kefeng Wang,
Jeff Xu, linux-mm, linux-kernel
On Wed, Mar 05, 2025 at 06:27:56PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The 'err' variable is set in a conditinal branch and is not
> set otherwise:
>
> mm/mremap.c:1017:7: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> 1017 | if (vma->vm_start != old_addr)
>
> Set it to zero before the initial value is set.
>
> Fixes: 3129f7896afb ("mm/mremap: initial refactor of move_vma()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Thanks for this, however this has already been fixed via Andrew doing a
fix-patch which should land in mm-unstable,-next soon (possibly tmr?).
This is entirely my bad btw, for some reason my compiler locally didn't
catch this even with CONFIG_WERROR on which _really_ surprises me...
> ---
> mm/mremap.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/mremap.c b/mm/mremap.c
> index 456849b9e7bd..9c51a2360d84 100644
> --- a/mm/mremap.c
> +++ b/mm/mremap.c
> @@ -1014,6 +1014,7 @@ static unsigned long prep_move_vma(struct vma_remap_struct *vrm)
> return -ENOMEM;
>
> if (vma->vm_ops && vma->vm_ops->may_split) {
> + err = 0;
> if (vma->vm_start != old_addr)
> err = vma->vm_ops->may_split(vma, old_addr);
> if (!err && vma->vm_end != old_addr + old_len)
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/mremap: fix uninitialized return code
2025-03-05 17:29 ` Lorenzo Stoakes
@ 2025-03-05 18:25 ` Arnd Bergmann
2025-03-05 18:34 ` Lorenzo Stoakes
0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2025-03-05 18:25 UTC (permalink / raw)
To: Lorenzo Stoakes, Arnd Bergmann
Cc: Andrew Morton, Liam R. Howlett, Vlastimil Babka, Jann Horn,
Pedro Falcato, David Hildenbrand, Kefeng Wang, Jeff Xu, linux-mm,
linux-kernel
On Wed, Mar 5, 2025, at 18:29, Lorenzo Stoakes wrote:
> On Wed, Mar 05, 2025 at 06:27:56PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> The 'err' variable is set in a conditinal branch and is not
>> set otherwise:
>>
>> mm/mremap.c:1017:7: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>> 1017 | if (vma->vm_start != old_addr)
>>
>> Set it to zero before the initial value is set.
>>
>> Fixes: 3129f7896afb ("mm/mremap: initial refactor of move_vma()")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Thanks for this, however this has already been fixed via Andrew doing a
> fix-patch which should land in mm-unstable,-next soon (possibly tmr?).
>
> This is entirely my bad btw, for some reason my compiler locally didn't
> catch this even with CONFIG_WERROR on which _really_ surprises me...
Unfortunately gcc never shows warnings about conditionally uninitialized
variables. There is a -Wmaybe-uninitialized, but that has so many
false positives that it is completely useless and it is turned
off globally.
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/mremap: fix uninitialized return code
2025-03-05 18:25 ` Arnd Bergmann
@ 2025-03-05 18:34 ` Lorenzo Stoakes
0 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Stoakes @ 2025-03-05 18:34 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Arnd Bergmann, Andrew Morton, Liam R. Howlett, Vlastimil Babka,
Jann Horn, Pedro Falcato, David Hildenbrand, Kefeng Wang,
Jeff Xu, linux-mm, linux-kernel
On Wed, Mar 05, 2025 at 07:25:38PM +0100, Arnd Bergmann wrote:
> On Wed, Mar 5, 2025, at 18:29, Lorenzo Stoakes wrote:
> > On Wed, Mar 05, 2025 at 06:27:56PM +0100, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@arndb.de>
> >>
> >> The 'err' variable is set in a conditinal branch and is not
> >> set otherwise:
> >>
> >> mm/mremap.c:1017:7: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> >> 1017 | if (vma->vm_start != old_addr)
> >>
> >> Set it to zero before the initial value is set.
> >>
> >> Fixes: 3129f7896afb ("mm/mremap: initial refactor of move_vma()")
> >> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> >
> > Thanks for this, however this has already been fixed via Andrew doing a
> > fix-patch which should land in mm-unstable,-next soon (possibly tmr?).
> >
> > This is entirely my bad btw, for some reason my compiler locally didn't
> > catch this even with CONFIG_WERROR on which _really_ surprises me...
>
> Unfortunately gcc never shows warnings about conditionally uninitialized
> variables. There is a -Wmaybe-uninitialized, but that has so many
> false positives that it is completely useless and it is turned
> off globally.
OK I notice by building with LLVM=1 this is immediately reported locally,
so from now on I'll make sure to do a clang build too.
At least there is some means by which I can sensibly determine this!
Cheers!
>
> Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/mremap: fix uninitialized return code
2025-03-05 17:27 [PATCH] mm/mremap: fix uninitialized return code Arnd Bergmann
2025-03-05 17:29 ` Lorenzo Stoakes
@ 2025-03-05 18:46 ` Yosry Ahmed
1 sibling, 0 replies; 5+ messages in thread
From: Yosry Ahmed @ 2025-03-05 18:46 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Andrew Morton, Liam R. Howlett, Lorenzo Stoakes, Arnd Bergmann,
Vlastimil Babka, Jann Horn, Pedro Falcato, David Hildenbrand,
Kefeng Wang, Jeff Xu, linux-mm, linux-kernel
On Wed, Mar 05, 2025 at 06:27:56PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The 'err' variable is set in a conditinal branch and is not
> set otherwise:
>
> mm/mremap.c:1017:7: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> 1017 | if (vma->vm_start != old_addr)
>
> Set it to zero before the initial value is set.
>
> Fixes: 3129f7896afb ("mm/mremap: initial refactor of move_vma()")
I think Andrew already fixed this:
https://lore.kernel.org/lkml/20250304151556.635d9041a7ca36f1960fe664@linux-foundation.org/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> mm/mremap.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/mremap.c b/mm/mremap.c
> index 456849b9e7bd..9c51a2360d84 100644
> --- a/mm/mremap.c
> +++ b/mm/mremap.c
> @@ -1014,6 +1014,7 @@ static unsigned long prep_move_vma(struct vma_remap_struct *vrm)
> return -ENOMEM;
>
> if (vma->vm_ops && vma->vm_ops->may_split) {
> + err = 0;
> if (vma->vm_start != old_addr)
> err = vma->vm_ops->may_split(vma, old_addr);
> if (!err && vma->vm_end != old_addr + old_len)
> --
> 2.39.5
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-05 18:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-05 17:27 [PATCH] mm/mremap: fix uninitialized return code Arnd Bergmann
2025-03-05 17:29 ` Lorenzo Stoakes
2025-03-05 18:25 ` Arnd Bergmann
2025-03-05 18:34 ` Lorenzo Stoakes
2025-03-05 18:46 ` Yosry Ahmed
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox