Messages in this thread | | | Date | Thu, 13 Jul 2000 16:02:30 +0200 | From | Jakub Jelinek <> | Subject | Re: Result of compiling with `-W' |
| |
Hi!
> --- 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.
Jakub
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |