Skip to content

Commit 488b5b9

Browse files
ctmarinasakpm00
authored andcommitted
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]>
1 parent c3d8ced commit 488b5b9

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
@@ -1689,7 +1689,7 @@ static void kmemleak_scan(void)
16891689
unsigned long phys = object->pointer;
16901690

16911691
if (PHYS_PFN(phys) < min_low_pfn ||
1692-
PHYS_PFN(phys + object->size) >= max_low_pfn)
1692+
PHYS_PFN(phys + object->size) > max_low_pfn)
16931693
__paint_it(object, KMEMLEAK_BLACK);
16941694
}
16951695

0 commit comments

Comments
 (0)