glibc/sysdeps/powerpc
Tulio Magno Quites Machado Filho 6ec52bf634 PowerPC: Fix a race condition when eliding a lock
The previous code used to evaluate the preprocessor token is_lock_free to
a variable before starting a transaction.  This behavior can cause an
error if another thread got the lock (without using a transaction)
between the evaluation of the token and the beginning of the transaction.

This bug can be triggered with the following order of events:
1. The lock accessed by is_lock_free is free.
2. Thread T1 evaluates is_lock_free and stores into register R1 that the
   lock is free.
3. Thread T2 acquires the same lock used in is_lock_free.
4. T1 begins the transaction, creating a memory barrier where is_lock_free
   is false, but R1 is true.
5. T1 reads R1 and doesn't abort the transaction.
6. T1 calls ELIDE_UNLOCK, which reads false from is_lock_free and decides
   to unlock a lock acquired by T2, leading to undefined behavior.

This patch delays the evaluation of is_lock_free to inside a transaction
by moving this part of the code to the macro ELIDE_LOCK.

	[BZ #18743]
	* sysdeps/powerpc/nptl/elide.h (__elide_lock): Move most of this
	code to...
	(ELIDE_LOCK): ...here.
	(__get_new_count): New function with part of the code from
	__elide_lock that updates the value of adapt_count after a
	transaction abort.
	(__elided_trylock): Moved this code to...
	(ELIDE_TRYLOCK): ...here.
2015-10-19 16:58:03 -02:00
..
bits Move bits/atomic.h to atomic-machine.h (bug 14912). 2015-09-11 20:00:19 +00:00
fpu Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
nofpu
nptl PowerPC: Fix a race condition when eliding a lock 2015-10-19 16:58:03 -02:00
power4
power5+/fpu
power6
power7/fpu
powerpc32 Fix powerpc32 lround, lroundf spurious exceptions (bug 19134). 2015-10-14 21:13:42 +00:00
powerpc64 PowerPC: Add comments to optimized strncpy 2015-10-01 17:36:55 -03:00
soft-fp
sys/platform
abort-instr.h
atomic-machine.h Move bits/atomic.h to atomic-machine.h (bug 14912). 2015-09-11 20:00:19 +00:00
dl-procinfo.c powerpc: Sync hwcap.h with kernel 2015-08-26 14:55:40 -03:00
dl-procinfo.h
dl-tls.c
dl-tls.h
ffs.c
fpu_control.h
gccframe.h
ifunc-sel.h
Implies
jmpbuf-offsets.h
jmpbuf-unwind.h
ldsodefs.h
locale-defines.sym
longjmp.c
machine-gmon.h
Makefile
math-tests.h
memusage.h
mp_clz_tab.c
novmx-longjmp.c
novmx-sigjmp.c
novmxsetjmp.h
preconfigure
rtld-global-offsets.sym
sched_cpucount.c
sigjmp.c
sotruss-lib.c
stackinfo.h
strcat.c
sysdep.h
test-arith.c
test-arithf.c
test-gettimebase.c
tls-macros.h
tst-stack-align.h
tst-tlsopt-powerpc.c
Versions