diff options
author | Andrew Morton <akpm@osdl.org> | 2006-03-24 06:18:35 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-24 10:33:30 -0500 |
commit | e0661111e5441995f7a69dc4336c9f131cb9bc58 (patch) | |
tree | 47a0a0ae66a9f792e6c9edbf683cdc0b62a2d4b7 /kernel/sys.c | |
parent | ec9e16bacdba1da1ee15dd162384e22df5c87e09 (diff) |
[PATCH] RLIMIT_CPU: fix handling of a zero limit
At present the kernel doesn't honour an attempt to set RLIMIT_CPU to zero
seconds. But the spec says it should, and that's what 2.4.x does.
Fixing this for real would involve some complexity (such as adding a new
it-has-been-set flag to the task_struct, and testing that everwhere, instead
of overloading the value of it_prof_expires).
Given that a 2.4 kernel won't actually send the signal until one second has
expired anyway, let's just handle this case by treating the caller's
zero-seconds as one second.
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Ulrich Weigand <uweigand@de.ibm.com>
Cc: Cliff Wickman <cpw@sgi.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index 9bdf94f3ae29..9e157e0240d4 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1661,8 +1661,19 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim) | |||
1661 | 1661 | ||
1662 | it_prof_secs = cputime_to_secs(current->signal->it_prof_expires); | 1662 | it_prof_secs = cputime_to_secs(current->signal->it_prof_expires); |
1663 | if (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) { | 1663 | if (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) { |
1664 | cputime_t cputime = secs_to_cputime(new_rlim.rlim_cur); | 1664 | unsigned long rlim_cur = new_rlim.rlim_cur; |
1665 | cputime_t cputime; | ||
1665 | 1666 | ||
1667 | if (rlim_cur == 0) { | ||
1668 | /* | ||
1669 | * The caller is asking for an immediate RLIMIT_CPU | ||
1670 | * expiry. But we use the zero value to mean "it was | ||
1671 | * never set". So let's cheat and make it one second | ||
1672 | * instead | ||
1673 | */ | ||
1674 | rlim_cur = 1; | ||
1675 | } | ||
1676 | cputime = secs_to_cputime(rlim_cur); | ||
1666 | read_lock(&tasklist_lock); | 1677 | read_lock(&tasklist_lock); |
1667 | spin_lock_irq(¤t->sighand->siglock); | 1678 | spin_lock_irq(¤t->sighand->siglock); |
1668 | set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL); | 1679 | set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL); |