From: Jeremy Kerr <jeremy@redfishsoftware.com.au>
To: Andrew Morton <akpm@osdl.org>
Cc: rusty@rustcorp.com.au, linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: Re: [PATCH] Fix signal race during process exit
Date: Wed, 2 Jun 2004 18:13:26 +1000 [thread overview]
Message-ID: <200406021813.26216.jeremy@redfishsoftware.com.au> (raw)
In-Reply-To: <20040602001653.738887b2.akpm@osdl.org>
> Andrew Morton <akpm@osdl.org> wrote:
> > yes?
>
> no. It needs tasklist_lock as well, to keep the other CPU (which is doing
> wait4) at bay.
almost:
> + tsk->it_virt_incr = 0;
> + tsk->it_prof_value = 0;
If we're using this approach, we also need to deal with the send_sig() calls
in do_process_times():
if (psecs / HZ > p->rlim[RLIMIT_CPU].rlim_cur) {
/* Send SIGXCPU every second.. */
if (!(psecs % HZ))
send_sig(SIGXCPU, p, 1);
/* and SIGKILL when we go over max.. */
if (psecs / HZ > p->rlim[RLIMIT_CPU].rlim_max)
send_sig(SIGKILL, p, 1);
}
by setting rlim_cur to RLIM_INFINITY.
Fix a race identified by Jeremy Kerr <jeremy@redfishsoftware.com.au>: if
update_process_times() decides to deliver a signal due to process timer
expiry, it can race with __exit_sighand()'s freeing of task->sighand.
Fix that by clearing the per-process timer state in exit_notify(), while under
local_irq_disable() and under tasklist_lock. tasklist_lock provides exclusion
wrt release_task()'s freeing of task->sighand and local_irq_disable() provides
exclusion wrt update_process_times()'s inspection of the per-process timer
state.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff -urN --exclude '.*.sw[op]' linux-2.6.7-rc2-bk2.orig/kernel/exit.c
linux-2.6.7-rc2-bk2/kernel/exit.c
--- linux-2.6.7-rc2-bk2.orig/kernel/exit.c 2004-06-02 11:29:13.000000000 +1000
+++ linux-2.6.7-rc2-bk2/kernel/exit.c 2004-06-02 18:02:05.000000000 +1000
@@ -736,6 +736,14 @@
tsk->state = state;
tsk->flags |= PF_DEAD;
+ /*
+ * Clear these here so that update_process_times() won't try to deliver
+ * itimer, profile or rlimit signals to this task while it is in late exit.
+ */
+ tsk->it_virt_incr = 0;
+ tsk->it_prof_value = 0;
+ tsk->rlim[RLIMIT_CPU].rlim_cur = RLIM_INFINITY;
+
/*
* In the preemption case it must be impossible for the task
* to get runnable again, so use "_raw_" unlock to keep
Jeremy
next prev parent reply other threads:[~2004-06-02 8:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-02 2:13 [PATCH] Fix signal race during process exit Jeremy Kerr
2004-06-02 5:57 ` Andrew Morton
2004-06-02 6:49 ` Rusty Russell
2004-06-02 7:08 ` Andrew Morton
2004-06-02 7:16 ` Andrew Morton
2004-06-02 8:13 ` Jeremy Kerr [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-06-04 1:21 Roland McGrath
2004-06-04 1:30 ` Andrew Morton
2004-06-10 1:48 ` Roland McGrath
2004-06-10 2:20 ` Andrew Morton
2004-06-10 2:51 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200406021813.26216.jeremy@redfishsoftware.com.au \
--to=jeremy@redfishsoftware.com.au \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox