From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14323 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] fix deadlock in synccall after threaded fork Date: Mon, 1 Jul 2019 10:12:02 -0400 Message-ID: <20190701141202.GQ1506@brightrain.aerifal.cx> References: <20190701034428.62764-1-samuel@sholland.org> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="41744"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14339-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jul 01 16:12:17 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hhx2W-000Ala-NA for gllmg-musl@m.gmane.org; Mon, 01 Jul 2019 16:12:16 +0200 Original-Received: (qmail 14255 invoked by uid 550); 1 Jul 2019 14:12:14 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14235 invoked from network); 1 Jul 2019 14:12:14 -0000 Content-Disposition: inline In-Reply-To: <20190701034428.62764-1-samuel@sholland.org> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14323 Archived-At: On Sun, Jun 30, 2019 at 10:44:28PM -0500, Samuel Holland wrote: > synccall may be called by AS-safe functions such as setuid/setgid after > fork. although fork() resets libc.threads_minus_one, causing synccall to > take the single-threaded path, synccall still takes the thread list > lock. This lock may be held by another thread if for example fork() > races with pthread_create(). After fork(), the value of the lock is > meaningless, so clear it. > --- > src/process/fork.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/src/process/fork.c b/src/process/fork.c > index 11286ef4..fb42478a 100644 > --- a/src/process/fork.c > +++ b/src/process/fork.c > @@ -28,6 +28,7 @@ pid_t fork(void) > self->robust_list.off = 0; > self->robust_list.pending = 0; > self->next = self->prev = self; > + __thread_list_lock = 0; > libc.threads_minus_1 = 0; > } > __restore_sigs(&set); > -- > 2.21.0 Thanks! Committing this with a maintainer's note referencing the commits that caused the regression and a further remark on why it's safe/correct to make this change. Rich