lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 20 Sep 2008 01:06:13 +0200
From:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
To:	Jason Baron <jbaron@...hat.com>
Cc:	linux-kernel@...r.kernel.org, aaw <aaw@...gle.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH] fix count(), compat_count() bounds checking

On Fri, 2008-09-19 at 11:50 -0400, Jason Baron wrote:
> 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

Right - looks sane enough, although in practise I'm not sure we'll ever
care since I suspect we'll hit the target stack limit before this.

Ollie?

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

Acked-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>

> 
> ---
> 
>  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();
>  		}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ