Commit 7ea0cb81 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fix sem_lock deadlock

From: Anton Blanchard <anton@samba.org>

I saw a lockup where 2 cpus were stuck in sem_lock().  It seems like we can
loop back to retry_undos with the lock held.  That path takes the lock so
we will deadlock.
parent 1cfc080a
...@@ -1038,8 +1038,10 @@ asmlinkage long sys_semtimedop(int semid, struct sembuf __user *tsops, ...@@ -1038,8 +1038,10 @@ asmlinkage long sys_semtimedop(int semid, struct sembuf __user *tsops,
* allocated an undo structure, it was invalidated by an RMID * allocated an undo structure, it was invalidated by an RMID
* and now a new array with received the same id. Check and retry. * and now a new array with received the same id. Check and retry.
*/ */
if (un && un->semid == -1) if (un && un->semid == -1) {
sem_unlock(sma);
goto retry_undos; goto retry_undos;
}
error = -EFBIG; error = -EFBIG;
if (max >= sma->sem_nsems) if (max >= sma->sem_nsems)
goto out_unlock_free; goto out_unlock_free;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment