diff options
| author | Manfred Spraul <[email protected]> | 2013-09-03 16:00:08 +0200 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2013-09-03 10:42:56 -0700 |
| commit | bebcb928c820d0ee83aca4b192adc195e43e66a2 (patch) | |
| tree | 28ad45577c7e65e28938eed04b0459674a11f0e3 /lib/dynamic_debug.c | |
| parent | ec1882a9391c55332ebf3d1654f40b76e4a6c010 (diff) | |
ipc/msg.c: Fix lost wakeup in msgsnd().
The check if the queue is full and adding current to the wait queue of
pending msgsnd() operations (ss_add()) must be atomic.
Otherwise:
- the thread that performs msgsnd() finds a full queue and decides to
sleep.
- the thread that performs msgrcv() first reads all messages from the
queue and then sleeps, because the queue is empty.
- the msgrcv() calls do not perform any wakeups, because the msgsnd()
task has not yet called ss_add().
- then the msgsnd()-thread first calls ss_add() and then sleeps.
Net result: msgsnd() and msgrcv() both sleep forever.
Observed with msgctl08 from ltp with a preemptible kernel.
Fix: Call ipc_lock_object() before performing the check.
The patch also moves security_msg_queue_msgsnd() under ipc_lock_object:
- msgctl(IPC_SET) explicitely mentions that it tries to expunge any
pending operations that are not allowed anymore with the new
permissions. If security_msg_queue_msgsnd() is called without locks,
then there might be races.
- it makes the patch much simpler.
Reported-and-tested-by: Vineet Gupta <[email protected]>
Acked-by: Rik van Riel <[email protected]>
Cc: [email protected] # for 3.11
Signed-off-by: Manfred Spraul <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'lib/dynamic_debug.c')
0 files changed, 0 insertions, 0 deletions