Skip to content

Commit 421c8f5

Browse files
committed
mm: kfence: apply kmemleak_ignore_phys on early allocated pool
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2151065 commit 07313a2 Author: Yee Lee <yee.lee@mediatek.com> Date: Tue, 28 Jun 2022 19:37:11 +0800 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/20220628113714.7792-2-yee.lee@mediatek.com Fixes: 0c24e06 ("mm: kmemleak: add rbtree and store physical address for objects allocated with PA") Signed-off-by: Yee Lee <yee.lee@mediatek.com> Suggested-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Suggested-by: Marco Elver <elver@google.com> Reviewed-by: Marco Elver <elver@google.com> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Waiman Long <longman@redhat.com>
1 parent da05036 commit 421c8f5

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
@@ -591,14 +591,6 @@ static unsigned long kfence_init_pool(void)
591591
addr += 2 * PAGE_SIZE;
592592
}
593593

594-
/*
595-
* The pool is live and will never be deallocated from this point on.
596-
* Remove the pool object from the kmemleak object tree, as it would
597-
* otherwise overlap with allocations returned by kfence_alloc(), which
598-
* are registered with kmemleak through the slab post-alloc hook.
599-
*/
600-
kmemleak_free(__kfence_pool);
601-
602594
return 0;
603595
}
604596

@@ -611,8 +603,16 @@ static bool __init kfence_init_pool_early(void)
611603

612604
addr = kfence_init_pool();
613605

614-
if (!addr)
606+
if (!addr) {
607+
/*
608+
* The pool is live and will never be deallocated from this point on.
609+
* Ignore the pool object from the kmemleak phys object tree, as it would
610+
* otherwise overlap with allocations returned by kfence_alloc(), which
611+
* are registered with kmemleak through the slab post-alloc hook.
612+
*/
613+
kmemleak_ignore_phys(__pa(__kfence_pool));
615614
return true;
615+
}
616616

617617
/*
618618
* Only release unprotected pages, and do not try to go back and change

0 commit comments

Comments
 (0)