All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/fake-numa: fix leak of the distance table copy on errors
@ 2026-12-02 16:46 Mike Rapoport
  2026-12-02 16:54 ` David Hildenbrand (Arm)
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Mike Rapoport @ 2026-12-02 16:46 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Andrew Morton, David Hildenbrand, linux-kernel, linux-mm, Sashiko

From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

numa_emulation() copies the physical distance table before calling
fix_pxm_node_maps(), but if fix_pxm_node_maps() fails, the copy is never
freed.

This only happens with numa=fake= setups that fix_pxm_node_maps() already
warns about, and leaks a single page on systems with up to 64 nodes.

Free the copy at no_emu. memblock_free() ignores NULL, so this is safe for
the errors that happen before the table is copied.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/bug/linux-96a473a0-2815-4091-910e-970513fa6467
Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")
---
 mm/numa_emulation.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/numa_emulation.c b/mm/numa_emulation.c
index 55f26b22bb0be..d79b5e42b5415 100644
--- a/mm/numa_emulation.c
+++ b/mm/numa_emulation.c
@@ -546,6 +546,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 	return;
 
 no_emu:
+	memblock_free(phys_dist, phys_size);
 	numa_nodes_parsed = physnode_mask;
 	/* No emulation.  Build identity emu_nid_to_phys[] for numa_add_cpu() */
 	for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++)

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/fake-numa: fix leak of the distance table copy on errors
  2026-12-02 16:46 [PATCH] mm/fake-numa: fix leak of the distance table copy on errors Mike Rapoport
@ 2026-12-02 16:54 ` David Hildenbrand (Arm)
  2026-12-02 18:52 ` + mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch added to mm-unstable branch Andrew Morton
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand (Arm) @ 2026-12-02 16:54 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, linux-kernel, linux-mm, Sashiko

On 12/2/26 17:46, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> 
> numa_emulation() copies the physical distance table before calling
> fix_pxm_node_maps(), but if fix_pxm_node_maps() fails, the copy is never
> freed.
> 
> This only happens with numa=fake= setups that fix_pxm_node_maps() already
> warns about, and leaks a single page on systems with up to 64 nodes.
> 
> Free the copy at no_emu. memblock_free() ignores NULL, so this is safe for
> the errors that happen before the table is copied.
> 
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/bug/linux-96a473a0-2815-4091-910e-970513fa6467
> Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")
> ---

Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David

^ permalink raw reply	[flat|nested] 7+ messages in thread

* + mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch added to mm-unstable branch
  2026-12-02 16:46 [PATCH] mm/fake-numa: fix leak of the distance table copy on errors Mike Rapoport
  2026-12-02 16:54 ` David Hildenbrand (Arm)
@ 2026-12-02 18:52 ` Andrew Morton
  2026-12-03 16:55 ` [PATCH] mm/fake-numa: fix leak of the distance table copy on errors sashiko-bot
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2026-12-02 18:52 UTC (permalink / raw)
  To: mm-commits, david, rppt, akpm


The patch titled
     Subject: mm/fake-numa: fix leak of the distance table copy on errors
has been added to the -mm mm-unstable branch.  Its filename is
     mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch

This patch will later appear in the mm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
Subject: mm/fake-numa: fix leak of the distance table copy on errors
Date: Wed, 02 Dec 2026 18:46:11 +0200

numa_emulation() copies the physical distance table before calling
fix_pxm_node_maps(), but if fix_pxm_node_maps() fails, the copy is never
freed.

This only happens with numa=fake= setups that fix_pxm_node_maps() already
warns about, and leaks a single page on systems with up to 64 nodes.

Free the copy at no_emu.  memblock_free() ignores NULL, so this is safe
for the errors that happen before the table is copied.

Link: https://patch.msgid.link/20261202164612.1573222-1-rppt@kernel.org
Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/bug/linux-96a473a0-2815-4091-910e-970513fa6467
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>

 mm/numa_emulation.c |    1 +
 1 file changed, 1 insertion(+)

--- a/mm/numa_emulation.c~mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors
+++ a/mm/numa_emulation.c
@@ -546,6 +546,7 @@ void __init numa_emulation(struct numa_m
 	return;
 
 no_emu:
+	memblock_free(phys_dist, phys_size);
 	numa_nodes_parsed = physnode_mask;
 	/* No emulation.  Build identity emu_nid_to_phys[] for numa_add_cpu() */
 	for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++)
_

Patches currently in -mm which might be from rppt@kernel.org are

mm-cma-simplify-cma_declare_contiguous_multi.patch
mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch
hibernation-make-swsusp_page-helpers-static.patch
hibernation-ensure-secretmem-pages-dont-reach-a-snapshot.patch
hibernate-handle-potential-errors-in-hibernate_mapunmap_page.patch
hibernation-kfence-explicitly-map-unmap-kfence-pages.patch
hibernation-make-hibernation-unavailable-when-debug_pagealloc-is-on.patch


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/fake-numa: fix leak of the distance table copy on errors
  2026-12-02 16:46 [PATCH] mm/fake-numa: fix leak of the distance table copy on errors Mike Rapoport
  2026-12-02 16:54 ` David Hildenbrand (Arm)
  2026-12-02 18:52 ` + mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch added to mm-unstable branch Andrew Morton
@ 2026-12-03 16:55 ` sashiko-bot
  2026-12-03 19:33 ` Joshua Hahn
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-03 16:55 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, David Hildenbrand, linux-mm

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mm/fake-numa: missing Signed-off-by trailer in commit message
--

commit 6fee39a2a55ee7144e4b3c511eb81670693a5b69
Author: Mike Rapoport (Microsoft) <rppt@kernel.org>

> mm/fake-numa: fix leak of the distance table copy on errors
>
> numa_emulation() copies the physical distance table before calling
> fix_pxm_node_maps(), but if fix_pxm_node_maps() fails, the copy is never
> freed.
>
> This only happens with numa=fake= setups that fix_pxm_node_maps() already
> warns about, and leaks a single page on systems with up to 64 nodes.
>
> Free the copy at no_emu. memblock_free() ignores NULL, so this is safe for
> the errors that happen before the table is copied.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/bug/linux-96a473a0-2815-4091-910e-970513fa6467
> Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")

[Severity: High]
The commit message is missing a Signed-off-by trailer.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202164612.1573222-1-rppt@kernel.org?part=1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/fake-numa: fix leak of the distance table copy on errors
  2026-12-02 16:46 [PATCH] mm/fake-numa: fix leak of the distance table copy on errors Mike Rapoport
                   ` (2 preceding siblings ...)
  2026-12-03 16:55 ` [PATCH] mm/fake-numa: fix leak of the distance table copy on errors sashiko-bot
@ 2026-12-03 19:33 ` Joshua Hahn
  2026-12-04 14:47 ` Sang-Heon Jeon
  2026-12-05 19:38 ` [merged mm/memblock.git] mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch removed from -mm tree Andrew Morton
  5 siblings, 0 replies; 7+ messages in thread
From: Joshua Hahn @ 2026-12-03 19:33 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Andrew Morton, David Hildenbrand, linux-kernel, linux-mm, Sashiko

On Wed, Dec 02, 2026 at 06:46:11PM +0200, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> 
> numa_emulation() copies the physical distance table before calling
> fix_pxm_node_maps(), but if fix_pxm_node_maps() fails, the copy is never
> freed.
> 
> This only happens with numa=fake= setups that fix_pxm_node_maps() already
> warns about, and leaks a single page on systems with up to 64 nodes.
> 
> Free the copy at no_emu. memblock_free() ignores NULL, so this is safe for
> the errors that happen before the table is copied.
 
Hello Mike, thank you for the fix! Looks good to me,
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>

Have a great day!
Joshua

> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/bug/linux-96a473a0-2815-4091-910e-970513fa6467
> Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")
> ---
>  mm/numa_emulation.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/numa_emulation.c b/mm/numa_emulation.c
> index 55f26b22bb0be..d79b5e42b5415 100644
> --- a/mm/numa_emulation.c
> +++ b/mm/numa_emulation.c
> @@ -546,6 +546,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
>  	return;
>  
>  no_emu:
> +	memblock_free(phys_dist, phys_size);
>  	numa_nodes_parsed = physnode_mask;
>  	/* No emulation.  Build identity emu_nid_to_phys[] for numa_add_cpu() */
>  	for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++)
> 
> base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
> -- 
> 2.53.0
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mm/fake-numa: fix leak of the distance table copy on errors
  2026-12-02 16:46 [PATCH] mm/fake-numa: fix leak of the distance table copy on errors Mike Rapoport
                   ` (3 preceding siblings ...)
  2026-12-03 19:33 ` Joshua Hahn
@ 2026-12-04 14:47 ` Sang-Heon Jeon
  2026-12-05 19:38 ` [merged mm/memblock.git] mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch removed from -mm tree Andrew Morton
  5 siblings, 0 replies; 7+ messages in thread
From: Sang-Heon Jeon @ 2026-12-04 14:47 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Andrew Morton, David Hildenbrand, linux-kernel, linux-mm, Sashiko

On Wed, Dec 02, 2026 at 06:46:11PM +0200, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
>
> numa_emulation() copies the physical distance table before calling
> fix_pxm_node_maps(), but if fix_pxm_node_maps() fails, the copy is never
> freed.
>
> This only happens with numa=fake= setups that fix_pxm_node_maps() already
> warns about, and leaks a single page on systems with up to 64 nodes.
>
> Free the copy at no_emu. memblock_free() ignores NULL, so this is safe for
> the errors that happen before the table is copied.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/bug/linux-96a473a0-2815-4091-910e-970513fa6467
> Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")

Looks good to me. Thank you :)

Reviewed-by: Sang-Heon Jeon <ekffu200098@gmail.com>

Best Regards,
Sang-Heon Jeon


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [merged mm/memblock.git] mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch removed from -mm tree
  2026-12-02 16:46 [PATCH] mm/fake-numa: fix leak of the distance table copy on errors Mike Rapoport
                   ` (4 preceding siblings ...)
  2026-12-04 14:47 ` Sang-Heon Jeon
@ 2026-12-05 19:38 ` Andrew Morton
  5 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2026-12-05 19:38 UTC (permalink / raw)
  To: mm-commits, joshua.hahnjy, ekffu200098, david, rppt, akpm


The quilt patch titled
     Subject: mm/fake-numa: fix leak of the distance table copy on errors
has been removed from the -mm tree.  Its filename was
     mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch

This patch was dropped because it was merged into mm/memblock.git

------------------------------------------------------
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
Subject: mm/fake-numa: fix leak of the distance table copy on errors
Date: Wed, 02 Dec 2026 18:46:11 +0200

numa_emulation() copies the physical distance table before calling
fix_pxm_node_maps(), but if fix_pxm_node_maps() fails, the copy is never
freed.

This only happens with numa=fake= setups that fix_pxm_node_maps() already
warns about, and leaks a single page on systems with up to 64 nodes.

Free the copy at no_emu.  memblock_free() ignores NULL, so this is safe
for the errors that happen before the table is copied.

Link: https://patch.msgid.link/20261202164612.1573222-1-rppt@kernel.org
Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/bug/linux-96a473a0-2815-4091-910e-970513fa6467
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>
Reviewed-by: Sang-Heon Jeon <ekffu200098@gmail.com>

 mm/numa_emulation.c |    1 +
 1 file changed, 1 insertion(+)

--- a/mm/numa_emulation.c~mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors
+++ a/mm/numa_emulation.c
@@ -546,6 +546,7 @@ void __init numa_emulation(struct numa_m
 	return;
 
 no_emu:
+	memblock_free(phys_dist, phys_size);
 	numa_nodes_parsed = physnode_mask;
 	/* No emulation.  Build identity emu_nid_to_phys[] for numa_add_cpu() */
 	for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++)
_

Patches currently in -mm which might be from rppt@kernel.org are

mm-cma-simplify-cma_declare_contiguous_multi.patch
mm-secretmem-disable-memfd_secret-if-secretmem_init-fails.patch
mm-cma-fix-handling-of-free-ranges-that-cross-4g-for-multi-range-areas.patch
userfaultfd-write-lock-the-vma-before-clearing-its-uffd-state.patch
userfaultfd-mark-zero-pages-moved-by-uffdio_move-soft-dirty.patch
userfaultfd-mark-thps-moved-by-uffdio_move-soft-dirty.patch
selftests-mm-free-the-test-context-when-uffd_test_ctx_init-fails.patch
hibernation-make-swsusp_page-helpers-static.patch
hibernation-ensure-secretmem-pages-dont-reach-a-snapshot.patch
hibernate-handle-potential-errors-in-hibernate_mapunmap_page.patch
hibernation-kfence-explicitly-map-unmap-kfence-pages.patch
hibernation-make-hibernation-unavailable-when-debug_pagealloc-is-on.patch


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-12-05 19:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 16:46 [PATCH] mm/fake-numa: fix leak of the distance table copy on errors Mike Rapoport
2026-12-02 16:54 ` David Hildenbrand (Arm)
2026-12-02 18:52 ` + mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch added to mm-unstable branch Andrew Morton
2026-12-03 16:55 ` [PATCH] mm/fake-numa: fix leak of the distance table copy on errors sashiko-bot
2026-12-03 19:33 ` Joshua Hahn
2026-12-04 14:47 ` Sang-Heon Jeon
2026-12-05 19:38 ` [merged mm/memblock.git] mm-fake-numa-fix-leak-of-the-distance-table-copy-on-errors.patch removed from -mm tree Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.