[lkml]   [2001]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subjectsetrlimit() nit
The setrlimit() system call doesn't enforce rlim_cur <= rlim_max. This can
to some unexpected results. For example, if you call setrlimit() with
RLIMIT_CPU with a hard limit of 60 secs, and a soft limit of "unlimited",
nothing will ever happen-- the hard limit is ignored, because it's never
checked if the soft limit hasn't been exceeded first (see kernel/timer.c).
BSD had the same flaw-- always annoyed me. Simple fix (below). Diffs
are for 2.4.8.


--- linux/kernel/sys.c Thu Jul 26 13:43:33 2001
+++ linux.NEW/kernel/sys.c Thu Aug 16 00:20:14 2001
@@ -1119,6 +1119,8 @@
return -EINVAL;
if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
return -EFAULT;
+ if (new_rlim.rlim_cur > new_rlim.rlim_max)
+ new_rlim.rlim_cur = new_rlim.rlim_max;
old_rlim = current->rlim + resource;
if (((new_rlim.rlim_cur > old_rlim->rlim_max) ||
(new_rlim.rlim_max > old_rlim->rlim_max)) &&

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

 \ /
  Last update: 2005-03-22 12:57    [W:0.491 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site