summaryrefslogtreecommitdiff
path: root/src/linux/getrandom.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2020-09-17 15:09:46 -0400
committerRich Felker <dalias@aerifal.cx>2020-09-17 23:58:01 -0400
commita5aff1972c9e3981566414b09a28e331ccd2be5d (patch)
treeabae169b8d6228eb285e494b3f18ed96e1fb9d64 /src/linux/getrandom.c
parent55fb9a177316aa46c639d93dd0323d9a9a8c160c (diff)
downloadmusl-a5aff1972c9e3981566414b09a28e331ccd2be5d.tar.gz
musl-a5aff1972c9e3981566414b09a28e331ccd2be5d.tar.bz2
musl-a5aff1972c9e3981566414b09a28e331ccd2be5d.tar.xz
musl-a5aff1972c9e3981566414b09a28e331ccd2be5d.zip
avoid set*id/setrlimit misbehavior and hang in vforked/cloned child
taking the deprecated/dropped vfork spec strictly, doing pretty much anything but execve in the child is wrong and undefined. however, these are commonly needed operations to setup the child state before exec, and historical implementations tolerated them. for single-threaded parents, these operations already worked as expected in the vforked child. however, due to the need for __synccall to synchronize id/resource limit changes among all threads, calling these functions in the vforked child of a multithreaded parent caused a misdirected broadcast signaling of all threads in the parent. these signals could kill the parent entirely if the synccall signal handler had never been installed in the parent, or could be ignored if it had, or could signal/kill one or more utterly wrong processes if the parent already terminated (due to vfork semantics, only possible via fatal signal) and the parent tids were recycled. in any case, the expected number of semaphore posts would never happen, so the child would permanently hang (with all signals blocked) waiting for them. to mitigate this, and also make the normal usage case work as intended, treat the condition where the caller's actual tid does not match the tid in its thread structure as single-threaded, and bypass the entire synccall broadcast operation.
Diffstat (limited to 'src/linux/getrandom.c')
0 files changed, 0 insertions, 0 deletions