mm/mempolicy.c: avoid use uninitialized preferred_node
authorYisheng Xie <xieyisheng1@huawei.com>
Thu, 22 Mar 2018 23:17:02 +0000 (16:17 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 31 May 2018 23:30:24 +0000 (00:30 +0100)
commitc218eb3152efa5b424e3c6951d6796a357a45f05
tree77ec4d4b711635204fe1b51687f804f11272d87e
parentb4eeaa94d0eb1a4b84361c941056f28c8ca314a6
mm/mempolicy.c: avoid use uninitialized preferred_node

commit 8970a63e965b43288c4f5f40efbc2bbf80de7f16 upstream.

Alexander reported a use of uninitialized memory in __mpol_equal(),
which is caused by incorrect use of preferred_node.

When mempolicy in mode MPOL_PREFERRED with flags MPOL_F_LOCAL, it uses
numa_node_id() instead of preferred_node, however, __mpol_equal() uses
preferred_node without checking whether it is MPOL_F_LOCAL or not.

[akpm@linux-foundation.org: slight comment tweak]
Link: http://lkml.kernel.org/r/4ebee1c2-57f6-bcb8-0e2d-1833d1ee0bb7@huawei.com
Fixes: fc36b8d3d819 ("mempolicy: use MPOL_F_LOCAL to Indicate Preferred Local Policy")
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Reported-by: Alexander Potapenko <glider@google.com>
Tested-by: Alexander Potapenko <glider@google.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
mm/mempolicy.c