On Tue, 16 Jan 2018, Kees Cook wrote:

> diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
> index 34f053a150a9..091f53fe31cc 100644
> --- a/include/linux/thread_info.h
> +++ b/include/linux/thread_info.h
> @@ -43,7 +43,9 @@ enum {
>  #define THREAD_ALIGN THREAD_SIZE
>  #endif
>  
> -#if IS_ENABLED(CONFIG_DEBUG_STACK_USAGE) || IS_ENABLED(CONFIG_DEBUG_KMEMLEAK)
> +#if IS_ENABLED(CONFIG_DEBUG_STACK_USAGE) || \
> +    IS_ENABLED(CONFIG_DEBUG_KMEMLEAK) || \
> +    IS_ENABLED(CONFIG_CLEAR_STACK_FORK)
>  # define THREADINFO_GFP              (GFP_KERNEL_ACCOUNT | __GFP_ZERO)
>  #else
>  # define THREADINFO_GFP              (GFP_KERNEL_ACCOUNT)
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 2295fc69717f..215b1ce2b2cd 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -215,7 +215,7 @@ static unsigned long *alloc_thread_stack_node(struct 
> task_struct *tsk, int node)
>               if (!s)
>                       continue;
>  
> -#ifdef CONFIG_DEBUG_KMEMLEAK
> +#if IS_ENABLED(CONFIG_DEBUG_KMEMLEAK) || IS_ENABLED(CONFIG_CLEAR_STACK_FORK)
>               /* Clear stale pointers from reused stack. */
>               memset(s->addr, 0, THREAD_SIZE);
>  #endif

Is there any good reason not to do it symmetricaly also for non-vmapped 
stacks? (by passing __GFP_ZERO to alloc_pages_node())?

Thanks,

-- 
Jiri Kosina
SUSE Labs

Reply via email to