提交 362e6663 编写于 作者: J Jason Baron 提交者: Linus Torvalds

exec.c, compat.c: fix count(), compat_count() bounds checking

With MAX_ARG_STRINGS set to 0x7FFFFFFF, and being passed to 'count()' and
compat_count(), it would appear that the current max bounds check of
fs/exec.c:394:

	if(++i > max)
		return -E2BIG;

would never trigger. Since 'i' is of type int, so values would wrap and the
function would continue looping.

Simple fix seems to be chaning ++i to i++ and checking for '>='.
Signed-off-by: NJason Baron <jbaron@redhat.com>
Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: "Ollie Wild" <aaw@google.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9679e4dd
......@@ -1239,7 +1239,7 @@ static int compat_count(compat_uptr_t __user *argv, int max)
if (!p)
break;
argv++;
if(++i > max)
if (i++ >= max)
return -E2BIG;
}
}
......
......@@ -391,7 +391,7 @@ static int count(char __user * __user * argv, int max)
if (!p)
break;
argv++;
if(++i > max)
if (i++ >= max)
return -E2BIG;
cond_resched();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册