mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: musl@lists.openwall.com
Cc: Samuel Holland <samuel@sholland.org>
Subject: [PATCH] fix deadlock in synccall after threaded fork
Date: Sun, 30 Jun 2019 22:44:28 -0500	[thread overview]
Message-ID: <20190701034428.62764-1-samuel@sholland.org> (raw)

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



             reply	other threads:[~2019-07-01  3:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01  3:44 Samuel Holland [this message]
2019-07-01 14:12 ` Rich Felker

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=20190701034428.62764-1-samuel@sholland.org \
    --to=samuel@sholland.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).