This fixes a race in both msgrcv() and msgsnd() between finding the msg andSigned-off-by: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>
actually dealing with the queue, as another thread can delete shmid
underneath us if we are preempted before acquiring the kern_ipc_perm.lock.
Manfred illustrates this nicely:
Assume a preemptible kernel that is preempted just aftermsq = msq_obtain_object_check(ns, msqid)in do_msgrcv().
The only lock that is held is rcu_read_lock().
Now the other thread processes IPC_RMID.
When the first task is resumed, then it will happily wait for messages on a
deleted queue.
Fix this by checking for if the queue has been deleted after taking the lock.
Reported-by: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx # for 3.11
Signed-off-by: Davidlohr Bueso <davidlohr@xxxxxx>