Re: [PATCH] mm/slub, kasan: fix checking page_alloc allocations on free

From: Andrey Konovalov
Date: Tue Aug 10 2021 - 20:41:38 EST


On Wed, Aug 11, 2021 at 2:18 AM Shakeel Butt <shakeelb@xxxxxxxxxx> wrote:
>
> On Tue, Aug 10, 2021 at 4:47 PM <andrey.konovalov@xxxxxxxxx> wrote:
> >
> > From: Andrey Konovalov <andreyknvl@xxxxxxxxx>
> >
> > A fix for stat counters f227f0faf63b ("slub: fix unreclaimable slab stat
> > for bulk free") used page_address(page) as kfree_hook() argument instead
> > of object. While the change is technically correct, it breaks KASAN's
> > ability to detect improper (unaligned) pointers passed to kfree() and
> > causes the kmalloc_pagealloc_invalid_free test to fail.
> >
> > This patch changes free_nonslab_page() to pass object to kfree_hook()
> > instead of page_address(page) as it was before the fix.
> >
> > Fixed: f227f0faf63b ("slub: fix unreclaimable slab stat for bulk free")
> > Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxx>
>
> The fix is already in the mm tree:
> https://lkml.kernel.org/r/20210802180819.1110165-1-shakeelb@xxxxxxxxxx

Ah, I missed this.

Please CC kasan-dev for KASAN-related fixes.

Thanks!