* setrlimit() nit
@ 2001-08-16 6:53 David Stevens
0 siblings, 0 replies; only message in thread
From: David Stevens @ 2001-08-16 6:53 UTC (permalink / raw)
To: linux-kernel
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)) &&
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-08-16 6:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-16 6:53 setrlimit() nit David Stevens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®