2009-04-23 07:47:42

by Chris Wright

[permalink] [raw]
Subject: [patch 057/100] posix-timers: fix RLIMIT_CPU && fork()

-stable review patch. If anyone has any objections, please let us know.
---------------------

From: Oleg Nesterov <[email protected]>

upstream commit: 6279a751fe096a21dc7704e918d570d3ff06e769

See http://bugzilla.kernel.org/show_bug.cgi?id=12911

copy_signal() copies signal->rlim, but RLIMIT_CPU is "lost". Because
posix_cpu_timers_init_group() sets cputime_expires.prof_exp = 0 and thus
fastpath_timer_check() returns false unless we have other expired cpu timers.

Change copy_signal() to set cputime_expires.prof_exp if we have RLIMIT_CPU.
Also, set cputimer.running = 1 in that case. This is not strictly necessary,
but imho makes sense.

Reported-by: Peter Lojkin <[email protected]>
Signed-off-by: Oleg Nesterov <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Cc: Peter Lojkin <[email protected]>
Cc: Roland McGrath <[email protected]>
Cc: [email protected]
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Chris Wright <[email protected]>
---
kernel/fork.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -808,6 +808,12 @@ static void posix_cpu_timers_init_group(
sig->cputime_expires.virt_exp = cputime_zero;
sig->cputime_expires.sched_exp = 0;

+ if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) {
+ sig->cputime_expires.prof_exp =
+ secs_to_cputime(sig->rlim[RLIMIT_CPU].rlim_cur);
+ sig->cputimer.running = 1;
+ }
+
/* The timer lists. */
INIT_LIST_HEAD(&sig->cpu_timers[0]);
INIT_LIST_HEAD(&sig->cpu_timers[1]);
@@ -823,11 +829,8 @@ static int copy_signal(unsigned long clo
atomic_inc(&current->signal->live);
return 0;
}
- sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
-
- if (sig)
- posix_cpu_timers_init_group(sig);

+ sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
tsk->signal = sig;
if (!sig)
return -ENOMEM;
@@ -865,6 +868,8 @@ static int copy_signal(unsigned long clo
memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim);
task_unlock(current->group_leader);

+ posix_cpu_timers_init_group(sig);
+
acct_init_pacct(&sig->pacct);

tty_audit_fork(sig);


2009-04-23 21:09:25

by Chuck Ebbert

[permalink] [raw]
Subject: Re: [patch 057/100] posix-timers: fix RLIMIT_CPU && fork()

On Thu, 23 Apr 2009 00:21:17 -0700
Chris Wright <[email protected]> wrote:

> -stable review patch. If anyone has any objections, please let us know.
> ---------------------
>
> From: Oleg Nesterov <[email protected]>
>
> upstream commit: 6279a751fe096a21dc7704e918d570d3ff06e769
>

The following commit was also submitted:

37bebc70d7ad4144c571d74500db3bb26ec0c0eb
posix timers: fix RLIMIT_CPU && fork()

Did it get dropped because it has the exact same title?

2009-04-23 21:14:29

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [patch 057/100] posix-timers: fix RLIMIT_CPU && fork()

On 04/23, Chuck Ebbert wrote:
>
> On Thu, 23 Apr 2009 00:21:17 -0700
> Chris Wright <[email protected]> wrote:
>
> > -stable review patch. If anyone has any objections, please let us know.
> > ---------------------
> >
> > From: Oleg Nesterov <[email protected]>
> >
> > upstream commit: 6279a751fe096a21dc7704e918d570d3ff06e769
> >
>
> The following commit was also submitted:
>
> 37bebc70d7ad4144c571d74500db3bb26ec0c0eb
> posix timers: fix RLIMIT_CPU && fork()
>
> Did it get dropped because it has the exact same title?

The commit above should be dropped, I'll send the "please revert" patch.

It was supposed to be the most simple fix for soon-to-be-released 2.6.29

Oleg.

2009-04-23 21:18:34

by Chris Wright

[permalink] [raw]
Subject: Re: [patch 057/100] posix-timers: fix RLIMIT_CPU && fork()

* Chuck Ebbert ([email protected]) wrote:
> On Thu, 23 Apr 2009 00:21:17 -0700
> Chris Wright <[email protected]> wrote:
>
> > -stable review patch. If anyone has any objections, please let us know.
> > ---------------------
> >
> > From: Oleg Nesterov <[email protected]>
> >
> > upstream commit: 6279a751fe096a21dc7704e918d570d3ff06e769
> >
>
> The following commit was also submitted:
>
> 37bebc70d7ad4144c571d74500db3bb26ec0c0eb
> posix timers: fix RLIMIT_CPU && fork()
>
> Did it get dropped because it has the exact same title?

No, Oleg said to ignore it in favor to the two that are in 2.6.29.2.
That first one was an attempt at a quick and dirty fix for 2.6.29,
but it missed 2.6.29 proper.

thanks,
-chris