Commit 70e52ba1 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] Fix ABI in set_mempolicy()

Fix ABI in set_mempolicy() that got broken by an earlier change.

Add a check for very big input values and prevent excessive looping in the
kernel.

Cc: Paul "nyer, nyer, your mother wears combat boots!" Jackson <pj@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8657d877
......@@ -132,6 +132,7 @@ static int get_nodes(unsigned long *nodes, unsigned long __user *nmask,
unsigned long nlongs;
unsigned long endmask;
--maxnode;
bitmap_zero(nodes, MAX_NUMNODES);
if (maxnode == 0 || !nmask)
return 0;
......@@ -145,6 +146,8 @@ static int get_nodes(unsigned long *nodes, unsigned long __user *nmask,
/* When the user specified more nodes than supported just check
if the non supported part is all zero. */
if (nlongs > BITS_TO_LONGS(MAX_NUMNODES)) {
if (nlongs > PAGE_SIZE/sizeof(long))
return -EINVAL;
for (k = BITS_TO_LONGS(MAX_NUMNODES); k < nlongs; k++) {
unsigned long t;
if (get_user(t, nmask + k))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment