Skip to content

Commit

Permalink
mm/mempolicy: fix get_nodes out of bound access
Browse files Browse the repository at this point in the history
[ Upstream commit 000eca5 ]

When user specified more nodes than supported, get_nodes will access nmask
array out of bounds.

Link: https://lkml.kernel.org/r/20220601093211.2970565-1-tianyu.li@arm.com
Fixes: e130242 ("mm: simplify compat numa syscalls")
Signed-off-by: Tianyu Li <tianyu.li@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
TianyuLi0 authored and gregkh committed Aug 17, 2022
1 parent 0b9f2f2 commit 4465215
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask,
unsigned long bits = min_t(unsigned long, maxnode, BITS_PER_LONG);
unsigned long t;

if (get_bitmap(&t, &nmask[maxnode / BITS_PER_LONG], bits))
if (get_bitmap(&t, &nmask[(maxnode - 1) / BITS_PER_LONG], bits))
return -EFAULT;

if (maxnode - bits >= MAX_NUMNODES) {
Expand Down

0 comments on commit 4465215

Please sign in to comment.