[patch] __lock_sock race condition in 2.3.18*

Andrea Arcangeli (andrea@suse.de)
Mon, 20 Sep 1999 18:59:39 +0200 (CEST)


This patch will fix a SMP race condition in __lock_sock. Basically it
avoids to deadlock in __lock_sock if release_sock is been run after the
user-count check and the setting (overwriting) of current->state.

diff -urN 2.3.18ac6/net/core/sock.c 2.3.18ac6-netdeadlock/net/core/sock.c
--- 2.3.18ac6/net/core/sock.c Mon Sep 20 01:15:46 1999
+++ 2.3.18ac6-netdeadlock/net/core/sock.c Mon Sep 20 18:14:19 1999
@@ -757,14 +757,14 @@

add_wait_queue_exclusive(&sk->lock.wq, &wait);
for(;;) {
- current->state = TASK_EXCLUSIVE | TASK_UNINTERRUPTIBLE;
+ set_current_state(TASK_EXCLUSIVE | TASK_UNINTERRUPTIBLE);
+ if(!sk->lock.users)
+ break;
spin_unlock_bh(&sk->lock.slock);
schedule();
spin_lock_bh(&sk->lock.slock);
- if(!sk->lock.users)
- break;
}
- current->state = TASK_RUNNING;
+ __set_current_state(TASK_RUNNING);
remove_wait_queue(&sk->lock.wq, &wait);
}

Andrea

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/