From: Oleg Nesterov <oleg@tv-sign.ru>
To: paulmck@us.ibm.com, Roland McGrath <roland@redhat.com>,
George Anzinger <george@mvista.com>,
akpm@osdl.org, linux-kernel@vger.kernel.org, dipankar@in.ibm.com,
mingo@elte.hu, suzannew@cs.pdx.edu,
Chris Wright <chrisw@osdl.org>
Subject: [PATCH] fix de_thread() vs send_group_sigqueue() race
Date: Mon, 07 Nov 2005 21:12:43 +0300 [thread overview]
Message-ID: <436F991B.97AFC4C5@tv-sign.ru> (raw)
In-Reply-To: <436E1401.920A83EE@tv-sign.ru>
When non-leader thread does exec, de_thread calls release_task(leader) before
calling exit_itimers(). If local timer interrupt happens in between, it can
oops in send_group_sigqueue() while taking ->sighand->siglock == NULL.
However, we can't change send_group_sigqueue() to check p->signal != NULL,
because sys_timer_create() does get_task_struct() only in SIGEV_THREAD_ID
case. So it is possible that this task_struct was already freed and we can't
trust p->signal.
This patch changes de_thread() so that leader released after exit_itimers()
call.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- 2.6.14/fs/exec.c~ 2005-09-21 21:08:33.000000000 +0400
+++ 2.6.14/fs/exec.c 2005-11-07 23:54:42.000000000 +0300
@@ -593,6 +593,7 @@ static inline int de_thread(struct task_
struct signal_struct *sig = tsk->signal;
struct sighand_struct *newsighand, *oldsighand = tsk->sighand;
spinlock_t *lock = &oldsighand->siglock;
+ struct task_struct *leader = NULL;
int count;
/*
@@ -668,7 +669,7 @@ static inline int de_thread(struct task_
* and to assume its PID:
*/
if (!thread_group_leader(current)) {
- struct task_struct *leader = current->group_leader, *parent;
+ struct task_struct *parent;
struct dentry *proc_dentry1, *proc_dentry2;
unsigned long exit_state, ptrace;
@@ -677,6 +678,7 @@ static inline int de_thread(struct task_
* It should already be zombie at this point, most
* of the time.
*/
+ leader = current->group_leader;
while (leader->exit_state != EXIT_ZOMBIE)
yield();
@@ -736,7 +738,6 @@ static inline int de_thread(struct task_
proc_pid_flush(proc_dentry2);
BUG_ON(exit_state != EXIT_ZOMBIE);
- release_task(leader);
}
/*
@@ -746,8 +747,11 @@ static inline int de_thread(struct task_
sig->flags = 0;
no_thread_group:
- BUG_ON(atomic_read(&sig->count) != 1);
exit_itimers(sig);
+ if (leader)
+ release_task(leader);
+
+ BUG_ON(atomic_read(&sig->count) != 1);
if (atomic_read(&oldsighand->count) == 1) {
/*
next prev parent reply other threads:[~2005-11-07 16:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-05 1:36 [PATCH] Additional/catchup RCU signal fixes for -mm Paul E. McKenney
2005-11-05 16:32 ` Oleg Nesterov
2005-11-06 1:00 ` Paul E. McKenney
2005-11-06 14:17 ` Oleg Nesterov
2005-11-06 14:46 ` Oleg Nesterov
2005-11-06 23:02 ` Paul E. McKenney
2005-11-06 14:32 ` Posix timers vs exec problems Oleg Nesterov
2005-11-07 18:12 ` Oleg Nesterov [this message]
2005-11-08 20:36 ` [PATCH] fix de_thread() vs send_group_sigqueue() race Chris Wright
2005-11-08 20:55 ` Linus Torvalds
2005-11-16 23:26 ` [PATCH] sigaction should clear all signals on SIG_IGN, not just < 32 George Anzinger
2005-11-22 1:09 ` Thread group exec race -> null pointer... HELP George Anzinger
2005-11-22 14:45 ` Oleg Nesterov
2005-11-23 20:30 ` George Anzinger
2005-11-25 15:03 ` Ingo Molnar
2005-11-22 19:20 ` [PATCH] fix do_wait() vs exec() race Oleg Nesterov
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=436F991B.97AFC4C5@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@osdl.org \
--cc=chrisw@osdl.org \
--cc=dipankar@in.ibm.com \
--cc=george@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@us.ibm.com \
--cc=roland@redhat.com \
--cc=suzannew@cs.pdx.edu \
/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
Powered by JetHome