ipc/sem.c: update/correct memory barriers
sem_lock() did not properly pair memory barriers:
!spin_is_locked() and spin_unlock_wait() are both only control barriers.
The code needs an acquire barrier, otherwise the cpu might perform read
operations before the lock test.
As no primitive exists inside <include/spinlock.h> and since it seems
noone wants another primitive, the code creates a local primitive within
With regards to -stable:
The change of sem_wait_array() is a bugfix, the change to sem_lock() is a
nop (just a preprocessor redefinition to improve the readability). The
bugfix is necessary for all kernels that use sem_wait_array() (i.e.:
starting from 3.10).
Signed-off-by: Manfred Spraul <email@example.com>
Reported-by: Oleg Nesterov <firstname.lastname@example.org>
Acked-by: Peter Zijlstra (Intel) <email@example.com>
Cc: "Paul E. McKenney" <firstname.lastname@example.org>
Cc: Kirill Tkhai <email@example.com>
Cc: Ingo Molnar <firstname.lastname@example.org>
Cc: Josh Poimboeuf <email@example.com>
Cc: Davidlohr Bueso <firstname.lastname@example.org>
Cc: <email@example.com> [3.10+]
Signed-off-by: Andrew Morton <firstname.lastname@example.org>
Signed-off-by: Linus Torvalds <email@example.com>
1 file changed