Skip to content

Commit c619d1e

Browse files
author
Rafael Aquini
committed
mm: kmemleak: fix upper boundary check for physical address objects
JIRA: https://issues.redhat.com/browse/RHEL-84184 This patch is a backport of the following upstream commit: commit 488b5b9 Author: Catalin Marinas <[email protected]> Date: Mon Jan 27 18:42:33 2025 +0000 mm: kmemleak: fix upper boundary check for physical address objects Memblock allocations are registered by kmemleak separately, based on their physical address. During the scanning stage, it checks whether an object is within the min_low_pfn and max_low_pfn boundaries and ignores it otherwise. With the recent addition of __percpu pointer leak detection (commit 6c99d4e ("kmemleak: enable tracking for percpu pointers")), kmemleak started reporting leaks in setup_zone_pageset() and setup_per_cpu_pageset(). These were caused by the node_data[0] object (initialised in alloc_node_data()) ending on the PFN_PHYS(max_low_pfn) boundary. The non-strict upper boundary check introduced by commit 84c3262 ("mm: kmemleak: check physical address when scan") causes the pg_data_t object to be ignored (not scanned) and the __percpu pointers it contains to be reported as leaks. Make the max_low_pfn upper boundary check strict when deciding whether to ignore a physical address object and not scan it. Link: https://lkml.kernel.org/r/[email protected] Fixes: 84c3262 ("mm: kmemleak: check physical address when scan") Signed-off-by: Catalin Marinas <[email protected]> Reported-by: Jakub Kicinski <[email protected]> Tested-by: Matthieu Baerts (NGI0) <[email protected]> Cc: Patrick Wang <[email protected]> Cc: <[email protected]> [6.0.x] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Rafael Aquini <[email protected]>
1 parent a18995a commit c619d1e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/kmemleak.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ static void kmemleak_scan(void)
16191619
unsigned long phys = object->pointer;
16201620

16211621
if (PHYS_PFN(phys) < min_low_pfn ||
1622-
PHYS_PFN(phys + object->size) >= max_low_pfn)
1622+
PHYS_PFN(phys + object->size) > max_low_pfn)
16231623
__paint_it(object, KMEMLEAK_BLACK);
16241624
}
16251625

0 commit comments

Comments
 (0)