make pointers used in robust list volatile
authorRich Felker <dalias@aerifal.cx>
Sun, 17 Aug 2014 04:46:26 +0000 (00:46 -0400)
committerRich Felker <dalias@aerifal.cx>
Sun, 17 Aug 2014 04:46:26 +0000 (00:46 -0400)
commitde7e99c58508ca70f0b1b8ef259a823a3766c434
tree68fbc616cb85a0a5a2992f64080d19b25855088f
parentd338b506e39b1e2c68366b12be90704c635602ce
make pointers used in robust list volatile

when manipulating the robust list, the order of stores matters,
because the code may be asynchronously interrupted by a fatal signal
and the kernel will then access the robust list in what is essentially
an async-signal context.

previously, aliasing considerations made it seem unlikely that a
compiler could reorder the stores, but proving that they could not be
reordered incorrectly would have been extremely difficult. instead
I've opted to make all the pointers used as part of the robust list,
including those in the robust list head and in the individual mutexes,
volatile.

in addition, the format of the robust list has been changed to point
back to the head at the end, rather than ending with a null pointer.
this is to match the documented kernel robust list ABI. the null
pointer, which was previously used, only worked because faults during
access terminate the robust list processing.
13 files changed:
arch/arm/bits/alltypes.h.in
arch/i386/bits/alltypes.h.in
arch/microblaze/bits/alltypes.h.in
arch/mips/bits/alltypes.h.in
arch/or1k/bits/alltypes.h.in
arch/powerpc/bits/alltypes.h.in
arch/sh/bits/alltypes.h.in
arch/x32/bits/alltypes.h.in
arch/x86_64/bits/alltypes.h.in
src/internal/pthread_impl.h
src/thread/pthread_mutex_trylock.c
src/thread/pthread_mutex_unlock.c
src/thread/pthread_mutexattr_setrobust.c