|
Message-ID: <alpine.LRH.2.00.1801262330200.27010@gjva.wvxbf.pm> Date: Fri, 26 Jan 2018 23:31:01 +0100 (CET) From: Jiri Kosina <jikos@...nel.org> To: Kees Cook <keescook@...omium.org> cc: Andrew Morton <akpm@...ux-foundation.org>, Andy Lutomirski <luto@...nel.org>, Jann Horn <jannh@...gle.com>, Ingo Molnar <mingo@...nel.org>, Laura Abbott <labbott@...hat.com>, Thomas Gleixner <tglx@...utronix.de>, Al Viro <viro@...iv.linux.org.uk>, Sahara <keun-o.park@...kmatter.ae>, "Levin, Alexander (Sasha Levin)" <alexander.levin@...izon.com>, Michal Hocko <mhocko@...e.com>, Andrea Arcangeli <aarcange@...hat.com>, "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>, linux-kernel@...r.kernel.org, kernel-hardening@...ts.openwall.com Subject: Re: [PATCH] fork: Allow stack to be wiped on fork On Fri, 26 Jan 2018, Jiri Kosina 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())? Ah, of course you already do by extending THREADINFO_GFP, sorry for the noise. -- Jiri Kosina
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.