mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-24 11:25:43 +00:00
mm/mempolicy: fix get_nodes out of bound access
[ Upstream commit000eca5d04
] 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:e130242dc3
("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>
This commit is contained in:
parent
2ba8fd5ae6
commit
8176f6a0d9
1 changed files with 1 additions and 1 deletions
|
@ -1387,7 +1387,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 bits = min_t(unsigned long, maxnode, BITS_PER_LONG);
|
||||||
unsigned long t;
|
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;
|
return -EFAULT;
|
||||||
|
|
||||||
if (maxnode - bits >= MAX_NUMNODES) {
|
if (maxnode - bits >= MAX_NUMNODES) {
|
||||||
|
|
Loading…
Reference in a new issue