diff options
author | Vlastimil Babka <vbabka@suse.cz> | 2017-01-24 15:18:18 -0800 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2017-03-06 17:31:11 -0500 |
commit | 024795f95e6b79383786f42229332e0c704b67b9 (patch) | |
tree | 5692a2b320a3ac330fd9d16b25a0a68ff6003ce7 /tools/lguest | |
parent | eee6e0dbec05719fccb6f37f26e7341aa56a7860 (diff) |
mm/mempolicy.c: do not put mempolicy before using its nodemask
[ Upstream commit d51e9894d27492783fc6d1b489070b4ba66ce969 ]
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.
Fixes: be97a41b291e ("mm/mempolicy.c: merge alloc_hugepage_vma to alloc_pages_vma")
Link: http://lkml.kernel.org/r/20170118141124.8345-1-vbabka@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: <stable@vger.kernel.org> [4.0+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Diffstat (limited to 'tools/lguest')
0 files changed, 0 insertions, 0 deletions