From: Chris Wright Date: Fri, 17 Feb 2006 21:59:36 +0000 (-0800) Subject: [PATCH] sys_mbind sanity checking X-Git-Tag: v2.6.15.5~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99e1baf86ff6a31330ff0c7bb77110338f03ddc5;p=thirdparty%2Fkernel%2Fstable.git [PATCH] sys_mbind sanity checking Make sure maxnodes is safe size before calculating nlongs in get_nodes(). Signed-off-by: Chris Wright Signed-off-by: Linus Torvalds [chrisw: fix units, pointed out by Andi] Cc: Andi Kleen Signed-off-by: Greg Kroah-Hartman --- diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 72f402cc9c9af..6e870ba707c7e 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -524,6 +524,8 @@ static int get_nodes(nodemask_t *nodes, unsigned long __user *nmask, nodes_clear(*nodes); if (maxnode == 0 || !nmask) return 0; + if (maxnode > PAGE_SIZE*BITS_PER_BYTE) + return -EINVAL; nlongs = BITS_TO_LONGS(maxnode); if ((maxnode % BITS_PER_LONG) == 0)