kmemleak: clear stale pointers from task stacks
Subsystems (3)
[email protected]
maintainerPATCH 16/18 kmemleak: clear stale pointers from task stacks
From: Konstantin Khlebnikov <[email protected]>
Subject: kmemleak: clear stale pointers from task stacks
Kmemleak considers any pointers on task stacks as references. This patch clears newly allocated and reused vmap stacks.
Signed-off-by Konstantin Khlebnikov <[email protected]>
Acked-by Catalin Marinas <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
include/linux/thread_info.h | 2 +- kernel/fork.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
include/linux/thread_info.h renamed from include/linux/thread_info.h~kmemleak-clear-stale-pointers-from-task-stacks +1 -1
@@ -42,7 +42,7 @@ enum {#define THREAD_ALIGN THREAD_SIZE#endif -#ifdef CONFIG_DEBUG_STACK_USAGE +#if IS_ENABLED (CONFIG_DEBUG_STACK_USAGE ) ||IS_ENABLED (CONFIG_DEBUG_KMEMLEAK )# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK | \ __GFP_ZERO)#else
kernel/fork.c renamed from kernel/fork.c~kmemleak-clear-stale-pointers-from-task-stacks +4 -0
@@ -215,6 +215,10 @@ static unsigned long *alloc_thread_stackif (!s)continue ; +#ifdef CONFIG_DEBUG_KMEMLEAK +/* Clear stale pointers from reused stack. */ +memset (s->addr,0 ,THREAD_SIZE ); +#endif tsk->stack_vm_area = s;return s->addr; }
_