lkml.org 
[lkml]   [2001]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subjectsetrlimit() nit
Date
The setrlimit() system call doesn't enforce rlim_cur <= rlim_max. This can
lead
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.

+-DLS


--- 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

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