Re: [PATCH v2 1/2] kasan: catch invalid free before SLUB reinitializes the object

From: Jann Horn
Date: Thu Jul 25 2024 - 06:54:54 EST


On Wed, Jul 24, 2024 at 11:17 PM Andrew Morton
<akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Wed, 24 Jul 2024 18:34:12 +0200 Jann Horn <jannh@xxxxxxxxxx> wrote:
>
> > Currently, when KASAN is combined with init-on-free behavior, the
> > initialization happens before KASAN's "invalid free" checks.
> >
> > More importantly, a subsequent commit will want to use the object metadata
> > region to store an rcu_head, and we should let KASAN check that the object
> > pointer is valid before that. (Otherwise that change will make the existing
> > testcase kmem_cache_invalid_free fail.)
> >
> > So add a new KASAN hook that allows KASAN to pre-validate a
> > kmem_cache_free() operation before SLUB actually starts modifying the
> > object or its metadata.
>
> I added this, to fix the CONFIG_KASAN=n build

Whoops, thanks for fixing that up.