lkml.org 
[lkml]   [2008]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] fix count(), compat_count() bounds checking
hi,

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 '>='.

thanks,

-Jason


Signed-off-by: Jason Baron <jbaron@redhat.com>

---

fs/compat.c | 2 +-
fs/exec.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/fs/compat.c b/fs/compat.c
index 3d4d57a..2c68dd7 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1233,7 +1233,7 @@ static int compat_count(compat_uptr_t __user *argv, int max)
if (!p)
break;
argv++;
- if(++i > max)
+ if (i++ >= max)
return -E2BIG;
}
}
diff --git a/fs/exec.c b/fs/exec.c
index 9bf0476..7766839 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -389,7 +389,7 @@ static int count(char __user * __user * argv, int max)
if (!p)
break;
argv++;
- if(++i > max)
+ if (i++ >= max)
return -E2BIG;
cond_resched();
}

\
 
 \ /
  Last update: 2008-09-19 17:53    [W:0.067 / U:0.616 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site