Skip to content

Commit 07313a2

Browse files
yeeleemtkakpm00
authored andcommitted
mm: kfence: apply kmemleak_ignore_phys on early allocated pool
This patch solves two issues. (1) The pool allocated by memblock needs to unregister from kmemleak scanning. Apply kmemleak_ignore_phys to replace the original kmemleak_free as its address now is stored in the phys tree. (2) The pool late allocated by page-alloc doesn't need to unregister. Move out the freeing operation from its call path. Link: https://lkml.kernel.org/r/[email protected] Fixes: 0c24e06 ("mm: kmemleak: add rbtree and store physical address for objects allocated with PA") Signed-off-by: Yee Lee <[email protected]> Suggested-by: Catalin Marinas <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Suggested-by: Marco Elver <[email protected]> Reviewed-by: Marco Elver <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 14c99d6 commit 07313a2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

mm/kfence/core.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,14 +603,6 @@ static unsigned long kfence_init_pool(void)
603603
addr += 2 * PAGE_SIZE;
604604
}
605605

606-
/*
607-
* The pool is live and will never be deallocated from this point on.
608-
* Remove the pool object from the kmemleak object tree, as it would
609-
* otherwise overlap with allocations returned by kfence_alloc(), which
610-
* are registered with kmemleak through the slab post-alloc hook.
611-
*/
612-
kmemleak_free(__kfence_pool);
613-
614606
return 0;
615607
}
616608

@@ -623,8 +615,16 @@ static bool __init kfence_init_pool_early(void)
623615

624616
addr = kfence_init_pool();
625617

626-
if (!addr)
618+
if (!addr) {
619+
/*
620+
* The pool is live and will never be deallocated from this point on.
621+
* Ignore the pool object from the kmemleak phys object tree, as it would
622+
* otherwise overlap with allocations returned by kfence_alloc(), which
623+
* are registered with kmemleak through the slab post-alloc hook.
624+
*/
625+
kmemleak_ignore_phys(__pa(__kfence_pool));
627626
return true;
627+
}
628628

629629
/*
630630
* Only release unprotected pages, and do not try to go back and change

0 commit comments

Comments
 (0)