ipc: fix GETALL/IPC_RM race for sysv semaphores
authorAl Viro <viro@ZenIV.linux.org.uk>
Thu, 2 May 2013 23:30:49 +0000 (00:30 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 3 May 2013 02:51:31 +0000 (19:51 -0700)
We can step on WARN_ON_ONCE() in sem_getref() if a semaphore is removed
just as we are about to call sem_getref() from semctl_main(); results
are not pretty.

We should fail with -EIDRM, same as if IPC_RM happened while we'd been
doing allocation there.  This also expands sem_getref() at its only
callsite (and fixed there), while sem_getref_and_unlock() is simply
killed off - it has no callers at all.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
ipc/sem.c

diff --cc ipc/sem.c
Simple merge