[lkml]   [2000]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Result of compiling with `-W'

> --- linux-2.4.0-test4-pre6/kernel/sys.c Tue Jul 11 22:21:17 2000
> +++ linux-akpm/kernel/sys.c Thu Jul 13 22:49:10 2000
> @@ -1058,7 +1058,7 @@
> return -EINVAL;
> if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
> return -EFAULT;
> - if (new_rlim.rlim_cur < 0 || new_rlim.rlim_max < 0)
> + if ((signed)new_rlim.rlim_cur < 0 || (signed)new_rlim.rlim_max < 0)
> return -EINVAL;
> old_rlim = current->rlim + resource;
> if (((new_rlim.rlim_cur > old_rlim->rlim_max) ||

Please be extremely careful with things like this.
E.g. this hunk does not seem to be correct to me, you should kill that if
with return -EINVAL completely.
Maybe the if should look like
if (new_rlim.rlim_cur > RLIM_INFINITY || new_rlim.rlim_max > RLIM_INFINITY)
return -EINVAL;
(but this would give you a warning with -W anyway on arches where
RLIM_INFINITY is ~0UL, but not all of them define it that way).
On several platforms (i386 included) RLIM_INFINITY is ~0UL and values like 3G are valid.
Also, if you cast an unsigned long to signed (which means int), you break all the 64bit
ports (by killing top 32bits). I think your patch should be checked
carefully because this will not be the only place where it happens.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:57    [from the cache]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site