aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2009-03-26 20:06:07 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-08 11:51:38 -0400
commit6279a751fe096a21dc7704e918d570d3ff06e769 (patch)
tree2b24e0ecf004802a890f77195489f8aa76fa745d
parent633fe795b80693a8198e7d82f66538a72d2bbba2 (diff)
posix-timers: fix RLIMIT_CPU && fork()
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 <ia6432@inbox.ru> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: Peter Lojkin <ia6432@inbox.ru> Cc: Roland McGrath <roland@redhat.com> Cc: stable@kernel.org LKML-Reference: <20090327000607.GA10104@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--kernel/fork.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 4854c2c4a82e..9b51a1b190d4 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -808,6 +808,12 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)
808 sig->cputime_expires.virt_exp = cputime_zero; 808 sig->cputime_expires.virt_exp = cputime_zero;
809 sig->cputime_expires.sched_exp = 0; 809 sig->cputime_expires.sched_exp = 0;
810 810
811 if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) {
812 sig->cputime_expires.prof_exp =
813 secs_to_cputime(sig->rlim[RLIMIT_CPU].rlim_cur);
814 sig->cputimer.running = 1;
815 }
816
811 /* The timer lists. */ 817 /* The timer lists. */
812 INIT_LIST_HEAD(&sig->cpu_timers[0]); 818 INIT_LIST_HEAD(&sig->cpu_timers[0]);
813 INIT_LIST_HEAD(&sig->cpu_timers[1]); 819 INIT_LIST_HEAD(&sig->cpu_timers[1]);
@@ -823,11 +829,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
823 atomic_inc(&current->signal->live); 829 atomic_inc(&current->signal->live);
824 return 0; 830 return 0;
825 } 831 }
826 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
827
828 if (sig)
829 posix_cpu_timers_init_group(sig);
830 832
833 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
831 tsk->signal = sig; 834 tsk->signal = sig;
832 if (!sig) 835 if (!sig)
833 return -ENOMEM; 836 return -ENOMEM;
@@ -865,6 +868,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
865 memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim); 868 memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim);
866 task_unlock(current->group_leader); 869 task_unlock(current->group_leader);
867 870
871 posix_cpu_timers_init_group(sig);
872
868 acct_init_pacct(&sig->pacct); 873 acct_init_pacct(&sig->pacct);
869 874
870 tty_audit_fork(sig); 875 tty_audit_fork(sig);