From: Andrew Morton <akpm@linux-foundation.org>
To: David Rientjes <rientjes@google.com>
Cc: linux-kernel@vger.kernel.org, vegard.nossum@oracle.com,
aryabinin@virtuozzo.com, dvyukov@google.com, glider@google.com
Subject: Re: + stackdepot-fix-mempolicy-use-after-free.patch added to -mm tree
Date: Mon, 19 Sep 2016 11:55:19 -0700 [thread overview]
Message-ID: <20160919115519.1c12bb3c0215260e20f9b1cb@linux-foundation.org> (raw)
In-Reply-To: <alpine.DEB.2.10.1608241805280.144357@chino.kir.corp.google.com>
On Wed, 24 Aug 2016 18:08:08 -0700 (PDT) David Rientjes <rientjes@google.com> wrote:
> > diff -puN lib/stackdepot.c~stackdepot-fix-mempolicy-use-after-free lib/stackdepot.c
> > --- a/lib/stackdepot.c~stackdepot-fix-mempolicy-use-after-free
> > +++ a/lib/stackdepot.c
> > @@ -243,6 +243,12 @@ depot_stack_handle_t depot_save_stack(st
> > alloc_flags &= ~GFP_ZONEMASK;
> > alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
> > alloc_flags |= __GFP_NOWARN;
> > + /*
> > + * Avoid using current->mempolicy which may already have
> > + * been freed -- we may be in the process of saving the
> > + * stack for exactly that __mpol_put() call.
> > + */
> > + alloc_flags |= __GFP_THISNODE;
> > page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
> > if (page)
> > prealloc = page_address(page);
>
> This is wrong, it unnecessarily restricts the allocation to a local node
> and has a greater chance to fail. Passing __GFP_THISNODE here is only an
> implementation detail of mempolicies to avoid reference to freed policy.
> It is easy to fix by using alloc_pages_node(NUMA_NO_NODE, alloc_flags,
> STACK_ALLOC_ORDER) instead of alloc_pages() directly.
Any volunteers to test and send the patch?
next prev parent reply other threads:[~2016-09-19 18:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <57b762c9.W4lqscwtxU8GMid9%akpm@linux-foundation.org>
2016-08-25 1:08 ` David Rientjes
2016-09-19 18:55 ` Andrew Morton [this message]
2016-09-20 13:04 ` Andrey Ryabinin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160919115519.1c12bb3c0215260e20f9b1cb@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
--cc=vegard.nossum@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®