Re: [PATCH v3 1/2] kasan: catch invalid free before SLUB reinitializes the object
From: Jann Horn
Date: Tue Jul 30 2024 - 06:36:12 EST
On Sat, Jul 27, 2024 at 2:47 AM Andrey Konovalov <andreyknvl@xxxxxxxxx> wrote:
> On Fri, Jul 26, 2024 at 3:52 PM Jann Horn <jannh@xxxxxxxxxx> wrote:
> >
> > > Do we still need this patch?
> >
> > I just tried removing this patch from the series; without it, the
> > kmem_cache_invalid_free kunit test fails because the kmem_cache_free()
> > no longer synchronously notices that the pointer is misaligned. I
> > guess I could change the testcase like this to make the tests pass
> > without this patch, but I'd like to hear from you or another KASAN
> > person whether you think that's a reasonable change:
>
> Ah, I see. I think detecting a bug earlier if we can is better. So I
> don't mind keeping this patch, was just confused by the commit
> message.
ack, changed it in v4
> Adding on top of my comments from before: I think if you move
> check_slab_free() out of poison_slab_object() (but add to
> __kasan_mempool_poison_object()), and move is_kfence_address() and
> kasan_arch_is_ready() to poison_slab_object()'s callers, you won't
> even need the free_validation_result enum, so the patch should become
> simpler.
right, makes sense, changed in v4
> You can also rename check_slab_free() to check_slab_allocation() to
> make it be named similarly to the already existing
> check_page_allocation().
done in v4