Bug 19282 - dl_load_write_lock isn't reinitialised during fork
Summary: dl_load_write_lock isn't reinitialised during fork
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-23 13:17 UTC by Stephen Robinson
Modified: 2019-08-27 10:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
test case (1.18 KB, application/x-compressed-tar)
2015-11-23 13:20 UTC, Stephen Robinson
Details
patch (323 bytes, patch)
2015-11-23 13:20 UTC, Stephen Robinson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Robinson 2015-11-23 13:17:02 UTC
While investigating bug 4578 I ran into a deadlock due to dl_load_write_lock not being reinitialised for the child process during a fork.

If one thread calls dl_iterate_phdr() and then another thread calls fork() then the child process ends up with a dl_load_write_lock that is already locked by the thread that called dl_iterate_phdr().

The fork call already reinitialises dl_load_lock but reinitialisation of dl_load_write_lock was not added to fork when that new lock was created.

I have created and attached a test case that recreates this and a patch to fix it.
Comment 1 Stephen Robinson 2015-11-23 13:20:26 UTC
Created attachment 8806 [details]
test case
Comment 2 Stephen Robinson 2015-11-23 13:20:50 UTC
Created attachment 8807 [details]
patch
Comment 3 Andreas Schwab 2017-10-09 07:59:06 UTC
In a multi-threaded process a forked child may only call async-signal-safe functions.
Comment 4 Florian Weimer 2019-08-27 10:02:22 UTC
Mailing list discussion: https://sourceware.org/ml/libc-alpha/2017-10/msg00265.html