When cpu is going offline, set q->offline as true
and interrupt happened. The interrupt may call the
quarantine_put. But quarantine_put do not free the
the object. The object will cause memory leak.

Add qlink_free() to free the object.

Fixes: 6c82d45c7f03 (kasan: fix object remaining in offline per-cpu quarantine)
Signed-off-by: Kuan-Ying Lee <kuan-ying....@mediatek.com>
Cc: Andrey Ryabinin <aryabi...@virtuozzo.com>
Cc: Alexander Potapenko <gli...@google.com>
Cc: Dmitry Vyukov <dvyu...@google.com>
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: Matthias Brugger <matthias....@gmail.com>
Cc: <sta...@vger.kernel.org>    [5.10-]
---
 mm/kasan/quarantine.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c
index 0e3f8494628f..cac7c617df72 100644
--- a/mm/kasan/quarantine.c
+++ b/mm/kasan/quarantine.c
@@ -191,6 +191,7 @@ void quarantine_put(struct kasan_free_meta *info, struct 
kmem_cache *cache)
 
        q = this_cpu_ptr(&cpu_quarantine);
        if (q->offline) {
+               qlink_free(&info->quarantine_link, cache);
                local_irq_restore(flags);
                return;
        }
-- 
2.18.0

Reply via email to