All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	torvalds@osdl.org, akpm@osdl.org, alan@lxorguk.ukuu.org.uk,
	Alexander Nyberg <alexn@telia.com>,
	Roland McGrath <roland@redhat.com>, Ingo Molnar <mingo@elte.hu>,
	Andi Kleen <ak@suse.de>, Chris Wright <chrisw@osdl.org>
Subject: [PATCH 02/10] [PATCH] Fix fs/exec.c:788 (de_thread()) BUG_ON
Date: Thu, 29 Sep 2005 19:20:18 -0700	[thread overview]
Message-ID: <20050930022201.149837000@localhost.localdomain> (raw)
In-Reply-To: 20050930022016.640197000@localhost.localdomain

[-- Attachment #1: fix-de_thread-BUG_ON.patch --]
[-- Type: text/plain, Size: 2012 bytes --]

-stable review patch.  If anyone has any objections, please let us know.
------------------

It turns out that the BUG_ON() in fs/exec.c: de_thread() is unreliable
and can trigger due to the test itself being racy.

de_thread() does
 	while (atomic_read(&sig->count) > count) {
	}
	.....
	.....
	BUG_ON(!thread_group_empty(current));

but release_task does
	write_lock_irq(&tasklist_lock)
	__exit_signal
		(this is where atomic_dec(&sig->count) is run)
	__exit_sighand
	__unhash_process
		takes write lock on tasklist_lock
		remove itself out of PIDTYPE_TGID list
	write_unlock_irq(&tasklist_lock)

so there's a clear (although small) window between the
atomic_dec(&sig->count) and the actual PIDTYPE_TGID unhashing of the
thread.

And actually there is no need for all threads to have exited at this
point, so we simply kill the BUG_ON.

Big thanks to Marc Lehmann who provided the test-case.

Fixes Bug 5170 (http://bugme.osdl.org/show_bug.cgi?id=5170)

Signed-off-by: Alexander Nyberg <alexn@telia.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>
Acked-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Chris Wright <chrisw@osdl.org>
---
 fs/exec.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Index: linux-2.6.13.y/fs/exec.c
===================================================================
--- linux-2.6.13.y.orig/fs/exec.c
+++ linux-2.6.13.y/fs/exec.c
@@ -745,8 +745,8 @@ static inline int de_thread(struct task_
         }
 
 	/*
-	 * Now there are really no other threads at all,
-	 * so it's safe to stop telling them to kill themselves.
+	 * There may be one thread left which is just exiting,
+	 * but it's safe to stop telling the group to kill themselves.
 	 */
 	sig->flags = 0;
 
@@ -785,7 +785,6 @@ no_thread_group:
 			kmem_cache_free(sighand_cachep, oldsighand);
 	}
 
-	BUG_ON(!thread_group_empty(current));
 	BUG_ON(!thread_group_leader(current));
 	return 0;
 }

--

  parent reply	other threads:[~2005-09-30  2:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-30  2:20 [PATCH 00/10] -stable review Chris Wright
2005-09-30  2:20 ` [PATCH 01/10] [PATCH] yenta oops fix Chris Wright
2005-09-30  2:20 ` Chris Wright [this message]
2005-09-30  2:20 ` [PATCH 03/10] [PATCH] fix IPv6 per-socket multicast filtering in exact-match case Chris Wright
2005-09-30  2:20 ` [PATCH 04/10] [PATCH] ipvs: ip_vs_ftp breaks connections using persistence Chris Wright
2005-09-30  2:20 ` [PATCH 05/10] [PATCH]: Missing acct/mm calls in compat_do_execve() Chris Wright
2005-09-30  5:48   ` Hugh Dickins
2005-09-30 21:24     ` Chris Wright
2005-10-01  2:18       ` David S. Miller
2005-09-30  2:20 ` [uml-devel] [PATCH 06/10] [PATCH] uml - Fix x86_64 page leak Chris Wright
2005-09-30  2:20   ` Chris Wright
2005-09-30  2:20 ` [PATCH 07/10] [PATCH] check connect(2) status for IPv6 UDP socket Chris Wright
2005-09-30  6:25   ` Chuck Wolber
2005-09-30  7:10     ` David S. Miller
2005-09-30 11:05       ` Mitsuru KANDA / 神田 充
2005-10-05 19:00         ` Chris Wright
2005-10-05 19:05           ` David S. Miller
2005-09-30  2:20 ` [PATCH 08/10] [PATCH] skge: set mac address oops with bonding Chris Wright
2005-09-30  2:20 ` [PATCH 09/10] [PATCH] tcp: set default congestion control correctly for incoming connections Chris Wright
2005-09-30  2:20 ` [PATCH 10/10] [TCP]: Dont over-clamp window in tcp_clamp_window() Chris Wright

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=20050930022201.149837000@localhost.localdomain \
    --to=chrisw@osdl.org \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=alexn@telia.com \
    --cc=chuckw@quantumlinux.com \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rdunlap@xenotime.net \
    --cc=roland@redhat.com \
    --cc=stable@kernel.org \
    --cc=torvalds@osdl.org \
    --cc=tytso@mit.edu \
    --cc=zwane@arm.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.