diff mbox series

[1/1] kasan: fix memory leak of kasan quarantine

Message ID 1608031683-24967-2-git-send-email-Kuan-Ying.Lee@mediatek.com
State New
Headers show
Series [1/1] kasan: fix memory leak of kasan quarantine | expand

Commit Message

Kuan-Ying Lee Dec. 15, 2020, 11:28 a.m. UTC
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.

Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: <stable@vger.kernel.org>    [5.10-]
---
 mm/kasan/quarantine.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Kuan-Ying Lee Dec. 17, 2020, 10:28 a.m. UTC | #1
On Tue, 2020-12-15 at 19:28 +0800, Kuan-Ying Lee wrote:
> 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.

> 

> Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>

> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>

> Cc: Alexander Potapenko <glider@google.com>

> Cc: Dmitry Vyukov <dvyukov@google.com>

> Cc: Andrew Morton <akpm@linux-foundation.org>

> Cc: Matthias Brugger <matthias.bgg@gmail.com>

> Cc: <stable@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;

>  	}


Sorry.

Please ignore this patch.

Thanks.
diff mbox series

Patch

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;
 	}