OSDN Git Service

ipc/sem.c: fix race with concurrent semtimedop() timeouts and IPC_RMID
authorManfred Spraul <manfred@colorfullife.com>
Tue, 26 Jul 2011 00:11:47 +0000 (17:11 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 5 Aug 2011 04:58:41 +0000 (21:58 -0700)
commite73ff29041b5f8991ef81669a1a9f0553d14766a
tree87b0a35ac9488b06d7bcad27125f723e08298703
parent9f78aa15dc4b47ca0bc6269c7c0e4f2345a66580
ipc/sem.c: fix race with concurrent semtimedop() timeouts and IPC_RMID

commit d694ad62bf539dbb20a0899ac2a954555f9e4a83 upstream.

If a semaphore array is removed and in parallel a sleeping task is woken
up (signal or timeout, does not matter), then the woken up task does not
wait until wake_up_sem_queue_do() is completed.  This will cause crashes,
because wake_up_sem_queue_do() will read from a stale pointer.

The fix is simple: Regardless of anything, always call get_queue_result().
This function waits until wake_up_sem_queue_do() has finished it's task.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=27142

Reported-by: Yuriy Yevtukhov <yuriy@ucoz.com>
Reported-by: Harald Laabs <kernel@dasr.de>
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ipc/sem.c