glibc/sysdeps
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
..
aarch64 Regenerate aarch64 libm-test-ulps 2015-09-24 14:22:31 +01:00
alpha Move bits/atomic.h to atomic-machine.h (bug 14912). 2015-09-11 20:00:19 +00:00
arm Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
generic malloc: Rewrite with explicit TLS access using __thread 2015-10-17 12:06:48 +02:00
gnu Add more TCP_* values to netinet/tcp.h. 2015-09-01 13:45:49 +00:00
hppa Rename bits/linkmap.h to linkmap.h (bug 14912). 2015-09-04 19:44:27 +00:00
i386 Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
ia64 Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
ieee754 Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
init_array NPTL: Initializer for .init_array-only configurations. 2015-02-13 13:19:11 -08:00
m68k Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
mach Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
microblaze Use soft-fp fma for MicroBlaze (bug 13304). 2015-09-25 17:29:19 +00:00
mips Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
nacl NaCl: Do not install <sys/mtio.h>. 2015-09-11 14:16:18 -07:00
nios2 Fixes extern protected data handling testcases elf/tst-protected1a 2015-07-26 05:27:18 -07:00
nptl malloc: Rewrite with explicit TLS access using __thread 2015-10-17 12:06:48 +02:00
posix Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
powerpc PowerPC: Fix a race condition when eliding a lock 2015-10-19 16:58:03 -02:00
pthread Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
s390 Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
sh Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
sparc Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
tile Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
unix Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00
wordsize-32 Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
wordsize-64 Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
x86 Fix pow missing underflows (bug 18825). 2015-09-25 22:29:10 +00:00
x86_64 Convert 231 sysdeps function definitions to prototype style. 2015-10-19 12:04:33 +00:00