Re: [PATCH mm v3 17/19] kasan: clean up metadata allocation and usage

From: Dmitry Vyukov
Date: Tue Nov 17 2020 - 08:28:25 EST


On Tue, Nov 17, 2020 at 2:18 PM Marco Elver <elver@xxxxxxxxxx> wrote:
>
> On Tue, 17 Nov 2020 at 14:12, Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:
>
> > > + */
> > > *(u8 *)kasan_mem_to_shadow(object) = KASAN_KMALLOC_FREE;
> > > +
> > > ___cache_free(cache, object, _THIS_IP_);
> > >
> > > if (IS_ENABLED(CONFIG_SLAB))
> > > @@ -168,6 +173,9 @@ void quarantine_put(struct kmem_cache *cache, void *object)
> > > struct qlist_head temp = QLIST_INIT;
> > > struct kasan_free_meta *meta = kasan_get_free_meta(cache, object);
> > >
> > > + if (!meta)
> > > + return;
> >
> > Humm... is this possible? If yes, we would be leaking the object here...
> > Perhaps BUG_ON with a comment instead.
>
> If this is possible in prod-mode KASAN, a WARN_ON() that returns would be safer.

We only compile quarantine.c for CONFIG_KASAN_GENERIC.