From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Andrew Morton <akpm@linux-foundation.org>,
David Rientjes <rientjes@google.com>
Cc: <linux-kernel@vger.kernel.org>, <vegard.nossum@oracle.com>,
<dvyukov@google.com>, <glider@google.com>
Subject: Re: + stackdepot-fix-mempolicy-use-after-free.patch added to -mm tree
Date: Tue, 20 Sep 2016 16:04:21 +0300 [thread overview]
Message-ID: <57522051-0376-b746-3969-bd43daff51bf@virtuozzo.com> (raw)
In-Reply-To: <20160919115519.1c12bb3c0215260e20f9b1cb@linux-foundation.org>
On 09/19/2016 09:55 PM, Andrew Morton wrote:
> 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?
>
This already fixed in c11600e4fed67ae4cd6 ("mm, mempolicy: task->mempolicy must be NULL before dropping final reference")
prev parent reply other threads:[~2016-09-20 13:19 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
2016-09-20 13:04 ` Andrey Ryabinin [this message]
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=57522051-0376-b746-3969-bd43daff51bf@virtuozzo.com \
--to=aryabinin@virtuozzo.com \
--cc=akpm@linux-foundation.org \
--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®