about summary refs log tree commit diff
path: root/src/thread/pthread_create.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019-09-13 14:17:36 -0400
committerRich Felker <dalias@aerifal.cx>2019-09-13 14:17:36 -0400
commitf5eee489f7662b08ad1bba4b1267e34eb9565bba (patch)
tree90622a74ccfed46f6946194f4ed8caf510b1a395 /src/thread/pthread_create.c
parentf7e464bff4e4a9707a0e9471b1e039363059c8d4 (diff)
downloadmusl-f5eee489f7662b08ad1bba4b1267e34eb9565bba.tar.gz
musl-f5eee489f7662b08ad1bba4b1267e34eb9565bba.tar.xz
musl-f5eee489f7662b08ad1bba4b1267e34eb9565bba.zip
harden thread start with failed scheduling against broken __clone
commit 8a544ee3a2a75af278145b09531177cab4939b41 introduced a
dependency of the failure path for explicit scheduling at thread
creation on __clone's handling of the start function returning, which
should result in SYS_exit.

as noted in commit 05870abeaac0588fb9115cfd11f96880a0af2108, the arm
version of __clone was broken in this case. in the past, the mips
version was also broken; it was fixed in commit
8b2b61e0001281be0dcd3dedc899bf187172fecb.

since this code path is pretty much entirely untested (previously only
reachable in applications that call the public clone() and return from
the start function) and consists of fragile per-arch asm, don't assume
it works, at least not until it's been thoroughly tested. instead make
the SYS_exit syscall from the start function's failure path.
Diffstat (limited to 'src/thread/pthread_create.c')
-rw-r--r--src/thread/pthread_create.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index 5d00d765..5f491092 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -185,7 +185,7 @@ static int start(void *p)
 			__wait(&args->control, 0, 2, 1);
 		if (args->control) {
 			__syscall(SYS_set_tid_address, &args->control);
-			return 0;
+			for (;;) __syscall(SYS_exit, 0);
 		}
 	}
 	__syscall(SYS_rt_sigprocmask, SIG_SETMASK, &args->sig_mask, 0, _NSIG/8);