[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090824141141.0893a2c0.kamezawa.hiroyu@jp.fujitsu.com>
Date: Mon, 24 Aug 2009 14:11:41 +0900
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To: Hiroshi Shimamoto <h-shimamoto@...jp.nec.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Oleg Nesterov <oleg@...hat.com>,
Roland McGrath <roland@...hat.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fix race copy_process() vs de_thread()
On Mon, 24 Aug 2009 13:01:40 +0900
Hiroshi Shimamoto <h-shimamoto@...jp.nec.com> wrote:
> Signed-off-by: Hiroshi Shimamoto <h-shimamoto@...jp.nec.com>
> ---
> kernel/fork.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 3ffa10f..be6c5b5 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -882,6 +882,9 @@ static void cleanup_signal(struct task_struct *tsk)
> {
> struct signal_struct *sig = tsk->signal;
>
> + if (!sig)
> + return;
> +
> atomic_dec(&sig->live);
>
> if (atomic_dec_and_test(&sig->count))
> @@ -1230,6 +1233,15 @@ static struct task_struct *copy_process(unsigned long clone_flags,
> */
> recalc_sigpending();
> if (signal_pending(current)) {
> + /* If there is any task waiting for the group exit, notify it */
> + if ((clone_flags & CLONE_THREAD) &&
> + p->signal->group_exit_task) {
> + atomic_dec(&p->signal->live);
> + atomic_dec(&p->signal->count);
> + if (atomic_read(&p->signal->count) == p->signal->notify_count)
> + wake_up_process(p->signal->group_exit_task);
> + p->signal = NULL;
> + }
> spin_unlock(¤t->sighand->siglock);
> write_unlock_irq(&tasklist_lock);
> retval = -ERESTARTNOINTR;
I'm not sure whehter I catch the issue correctly but, shouldn't we encapsulate
this check in cleanup_signal() ?
like...
static void cleanup_signal(struct task_struct *tsk)
{
struct signal_struct *sig = tsk->signal;
sighand = rcu_dereference(tsk->sighand);
spin_lock(&sighand->siglock);
if (sig->group_exit_task && atomic_read(&sig->count) == sig->notify_count)
wake_up_process(sig->group_exit_task);
spin_unlock(&sighand->siglock);
atomic_dec(&sig->live);
if (!atomic_dec_and_test(&sig->count))
__cleanup_signal(sig);
}
BTW, why sig->xxx members in "signal" struct is guarded by lock in "sighand"
struct ??
Thanks,
-Kame
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists