[PATCH] [BZ #19402] Clear list of acquired robust mutexes in the child process after forking.

Torvald Riegel triegel@redhat.com
Thu Dec 22 10:16:00 GMT 2016


I've asked for comments on whether mutexes acquired before fork() remain
to be acquired by just the parent process after fork():
https://sourceware.org/ml/libc-alpha/2016-12/msg00772.html

If we can agree on one of the requirements I'm proposing there, this
patch fixes the core problem of bug 19402.  (The reproducer of this bug
reveals another issue on x86, for which I'll send a patch next.)

The fix is:

Robust mutexes acquired at the time of a call to fork() do not remain
acquired by the forked child process.  We have to clear the list of
acquired robust mutexes before registering this list with the kernel;
otherwise, if some of the robust mutexes are process-shared, the parent
process can alter the child's robust mutex list, which can lead to
deadlocks or even modification of memory that may not be occupied by a
mutex anymore.

Tested on x86_64-linux with glibc's tests and the reproducer from 19402.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: robust-clear-list.patch
Type: text/x-patch
Size: 2275 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20161222/8141e8d3/attachment.bin>


More information about the Libc-alpha mailing list