Re: [PATCH v2 1/1] mm: kfence: apply kmemleak_ignore_phys on early allocated pool

From: Geert Uytterhoeven
Date: Fri Jul 15 2022 - 04:18:01 EST


Hi Yee,

On Tue, Jun 28, 2022 at 1:42 PM <yee.lee@xxxxxxxxxxxx> wrote:
> From: Yee Lee <yee.lee@xxxxxxxxxxxx>
>
> 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.
>
> Suggested-by: Catalin Marinas <catalin.marinas@xxxxxxx>
> Suggested-by: Marco Elver <elver@xxxxxxxxxx>
> Signed-off-by: Yee Lee <yee.lee@xxxxxxxxxxxx>

Thank you, this fixes the storm of

BUG: KFENCE: invalid read in scan_block+0x78/0x130
BUG: KFENCE: use-after-free read in scan_block+0x78/0x130
BUG: KFENCE: out-of-bounds read in scan_block+0x78/0x130

messages I was seeing on arm64.

Tested-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds