From: Dave McCracken <dmccr@us.ibm.com>
To: Linus Torvalds <torvalds@transmeta.com>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] Fix race condition in wait with thread groups
Date: Tue, 06 Nov 2001 10:00:04 -0600 [thread overview]
Message-ID: <30540000.1005062403@baldur> (raw)
There is code in sys_wait4() that makes a task wait for the children of all
members of the thread group. This code has a race condition when more than
one task in a thread group calls wait. Once it has picked a zomebie task
to return it drops the tasklist lock before it calls release_task(). This
allows another task to select the same zombie to clean up.
My fix for this race condition is to set the zombie task's state to a
different value before the tasklist lock is released. This means no other
waiting task will select it. There could be other ways of marking a task
as already selected for cleanup, but this seemed the simplest.
The patch is appended below. It applies cleanly to 2.4.14
Dave McCracken
======================================================================
Dave McCracken IBM Linux Base Kernel Team 1-512-838-3059
dmccr@us.ibm.com T/L 678-3059
-------------------------
--- linux-2.4.13/kernel/exit.c Mon Oct 22 11:27:55 2001
+++ linux-2.4.14-pre8/kernel/exit.c Mon Nov 5 11:56:45 2001
@@ -534,6 +534,9 @@
}
goto end_wait4;
case TASK_ZOMBIE:
+ /* Make sure no other waiter picks this task up */
+ p->state = TASK_DEAD;
+
current->times.tms_cutime += p->times.tms_utime + p->times.tms_cutime;
current->times.tms_cstime += p->times.tms_stime + p->times.tms_cstime;
read_unlock(&tasklist_lock);
--- linux-2.4.13/include/linux/sched.h Tue Oct 23 23:59:06 2001
+++ linux-2.4.14-pre8/include/linux/sched.h Mon Nov 5 12:56:20 2001
@@ -88,6 +88,7 @@
#define TASK_UNINTERRUPTIBLE 2
#define TASK_ZOMBIE 4
#define TASK_STOPPED 8
+#define TASK_DEAD 16
#define __set_task_state(tsk, state_value) \
do { (tsk)->state = (state_value); } while (0)
reply other threads:[~2001-11-06 16:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=30540000.1005062403@baldur \
--to=dmccr@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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