Patch "mm/mempolicy.c: do not put mempolicy before using its nodemask" has been added to the 4.4-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
mm/mempolicy.c: do not put mempolicy before using its nodemask
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mm-mempolicy.c-do-not-put-mempolicy-before-using-its-nodemask.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
d51e9894d27492783fc6d1b489070b4ba66ce969Mon Sep 17 00:00:00 2001
From: Vlastimil Babka <[email protected]>
Date: Tue, 24 Jan 2017 15:18:18 -0800
Subject: mm/mempolicy.c: do not put mempolicy before using its nodemask
From: Vlastimil Babka <[email protected]>
commit d51e9894d27492783fc6d1b489070b4ba66ce969 upstream.
Since commit be97a41b291e ("mm/mempolicy.c: merge alloc_hugepage_vma to alloc_pages_vma") alloc_pages_vma() can potentially free a mempolicy by mpol_cond_put() before accessing the embedded nodemask by __alloc_pages_nodemask(). The commit log says it's so "we can use a single exit path within the function" but that's clearly wrong. We can still do that when doing mpol_cond_put() after the allocation attempt.
Make sure the mempolicy is not freed prematurely, otherwise __alloc_pages_nodemask() can end up using a bogus nodemask, which could lead e.g. to premature OOM.
--- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mempolicy.c +1 -1
@@ -2006,8 +2006,8 @@ retry_cpuset: nmask =policy_nodemask (gfp, pol); zl =policy_zonelist (gfp, pol, node); -mpol_cond_put (pol); page =__alloc_pages_nodemask (gfp, order, zl, nmask); +mpol_cond_put (pol); out:if (unlikely (!page &&read_mems_allowed_retry (cpuset_mems_cookie))) goto retry_cpuset;
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/mm-mempolicy.c-do-not-put-mempolicy-before-using-its-nodemask.patch