Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932088AbVJMQiK (ORCPT ); Thu, 13 Oct 2005 12:38:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932091AbVJMQiJ (ORCPT ); Thu, 13 Oct 2005 12:38:09 -0400 Received: from mail.tv-sign.ru ([213.234.233.51]:35557 "EHLO several.ru") by vger.kernel.org with ESMTP id S932088AbVJMQiI (ORCPT ); Thu, 13 Oct 2005 12:38:08 -0400 Message-ID: <434E906E.85BD86BF@tv-sign.ru> Date: Thu, 13 Oct 2005 20:50:54 +0400 From: Oleg Nesterov X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.20 i686) X-Accept-Language: en MIME-Version: 1.0 To: linux-kernel@vger.kernel.org Cc: Roland McGrath , Ingo Molnar , Michael Kerrisk , Linus Torvalds , Andrew Morton Subject: [PATCH] fix de_thread() vs do_coredump() deadlock Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1362 Lines: 41 de_thread() sends SIGKILL to all sub-threads and waits them to die in 'D' state. It is possible that one of the threads already dequeued coredump signal. When de_thread() unlocks ->sighand->lock that thread can enter do_coredump()->coredump_wait() and cause a deadlock. Signed-off-by: Oleg Nesterov --- 2.6.14-rc4/fs/exec.c~ 2005-09-21 21:08:33.000000000 +0400 +++ 2.6.14-rc4/fs/exec.c 2005-10-14 00:19:19.000000000 +0400 @@ -1468,11 +1468,21 @@ int do_coredump(long signr, int exit_cod current->fsuid = 0; /* Dump root private */ } mm->dumpable = 0; - init_completion(&mm->core_done); + + retval = -EAGAIN; spin_lock_irq(¤t->sighand->siglock); - current->signal->flags = SIGNAL_GROUP_EXIT; - current->signal->group_exit_code = exit_code; + if (!(current->signal->flags & SIGNAL_GROUP_EXIT)) { + current->signal->flags = SIGNAL_GROUP_EXIT; + current->signal->group_exit_code = exit_code; + retval = 0; + } spin_unlock_irq(¤t->sighand->siglock); + if (retval) { + up_write(&mm->mmap_sem); + goto fail; + } + + init_completion(&mm->core_done); coredump_wait(mm); /* - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/