[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170526134949.3045-1-lhenriques@suse.com>
Date: Fri, 26 May 2017 14:49:49 +0100
From: Luis Henriques <lhenriques@...e.com>
To: Andy Lutomirski <luto@...nel.org>,
Catalin Marinas <catalin.marinas@....com>
Cc: Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Michal Hocko <mhocko@...e.com>,
Thomas Gleixner <tglx@...utronix.de>,
"Eric W . Biederman" <ebiederm@...ssion.com>,
Peter Zijlstra <peterz@...radead.org>,
Oleg Nesterov <oleg@...hat.com>,
Mateusz Guzik <mguzik@...hat.com>,
linux-kernel@...r.kernel.org, Luis Henriques <lhenriques@...e.com>,
stable@...r.kernel.org
Subject: [PATCH] fork: fix kmemleak false positive due to thread stacks caching
kmemleak has been reporting memory leaks since commit ac496bf48d97 ("fork:
Optimize task creation by caching two thread stacks per CPU if
CONFIG_VMAP_STACK=y"):
unreferenced object 0xffffc900002b0000 (size 16384):
comm "init", pid 147, jiffies 4294893306 (age 11.292s)
hex dump (first 32 bytes):
9d 6e ac 57 00 00 00 00 00 00 00 00 00 00 00 00 .n.W............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff815b481e>] kmemleak_alloc+0x4e/0xb0
[<ffffffff8112a8b0>] __vmalloc_node_range+0x160/0x240
[<ffffffff8104a328>] copy_process.part.8+0x478/0x1630
[<ffffffff8104b69a>] _do_fork+0xca/0x330
[<ffffffff8104b9a9>] SyS_clone+0x19/0x20
[<ffffffff8100199c>] do_syscall_64+0x4c/0xb0
[<ffffffff815b8d06>] return_from_SYSCALL_64+0x0/0x6a
[<ffffffffffffffff>] 0xffffffffffffffff
This is because this commit started caching 2 thread stacks per CPU, and
kmemleak assumes its memory is never freed. Report these stacks as not
being memory leaks using kmemleak_not_leak().
Cc: stable@...r.kernel.org
Fixes: ac496bf48d97 ("fork: Optimize task creation by caching two thread stacks per CPU if CONFIG_VMAP_STACK=y")
Signed-off-by: Luis Henriques <lhenriques@...e.com>
---
kernel/fork.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/fork.c b/kernel/fork.c
index aa1076c5e4a9..c4d79ad0f5bc 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -255,6 +255,7 @@ static inline void free_thread_stack(struct task_struct *tsk)
this_cpu_write(cached_stacks[i], tsk->stack_vm_area);
local_irq_restore(flags);
+ kmemleak_not_leak(tsk->stack);
return;
}
local_irq_restore(flags);
Powered by blists - more mailing lists