diff options
author | Yisheng Xie <xieyisheng1@huawei.com> | 2018-03-22 19:17:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-03-22 20:07:01 -0400 |
commit | 8970a63e965b43288c4f5f40efbc2bbf80de7f16 (patch) | |
tree | 5fbccafe8068d97d24f9cb26354cbfe9c0e6b3e1 | |
parent | 3215b9d57a2c75c4305a3956ca303d7004485200 (diff) |
mm/mempolicy.c: avoid use uninitialized preferred_node
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>
-rw-r--r-- | mm/mempolicy.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index d879f1d8a44a..32cba0332787 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -2124,6 +2124,9 @@ bool __mpol_equal(struct mempolicy *a, struct mempolicy *b) | |||
2124 | case MPOL_INTERLEAVE: | 2124 | case MPOL_INTERLEAVE: |
2125 | return !!nodes_equal(a->v.nodes, b->v.nodes); | 2125 | return !!nodes_equal(a->v.nodes, b->v.nodes); |
2126 | case MPOL_PREFERRED: | 2126 | case MPOL_PREFERRED: |
2127 | /* a's ->flags is the same as b's */ | ||
2128 | if (a->flags & MPOL_F_LOCAL) | ||
2129 | return true; | ||
2127 | return a->v.preferred_node == b->v.preferred_node; | 2130 | return a->v.preferred_node == b->v.preferred_node; |
2128 | default: | 2131 | default: |
2129 | BUG(); | 2132 | BUG(); |