summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_sockbuf.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-02-17 12:53:45 +0000
committerrwatson <rwatson@FreeBSD.org>2005-02-17 12:53:45 +0000
commit630d43c2befebc4f04f49e4afa2b780a92cadd1c (patch)
tree3db47f2ba2f1ceeeb8f1101a6e881025197253f5 /sys/kern/uipc_sockbuf.c
parentcd4209c59eddce615fbac82d60bbfd7b458735f3 (diff)
downloadFreeBSD-src-630d43c2befebc4f04f49e4afa2b780a92cadd1c.zip
FreeBSD-src-630d43c2befebc4f04f49e4afa2b780a92cadd1c.tar.gz
In sonewconn(), set the new socket's state to show the protocol-provided
connection status before inserting the new socket into the listen socket's accept queue, or there might be a race in which another thread wakes up when the accept lock is released, and sees the socket before its state is set correctly. The wakeup still occurs after the accept lock is released. There have been no diagnoses of this bug in real-world systems (as yet). MFC after: 3 days
Diffstat (limited to 'sys/kern/uipc_sockbuf.c')
-rw-r--r--sys/kern/uipc_sockbuf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index 4e167bd..91f152e 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -249,6 +249,7 @@ sonewconn(head, connstatus)
sodealloc(so);
return ((struct socket *)0);
}
+ so->so_state |= connstatus;
ACCEPT_LOCK();
if (connstatus) {
TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
@@ -279,7 +280,6 @@ sonewconn(head, connstatus)
}
ACCEPT_UNLOCK();
if (connstatus) {
- so->so_state |= connstatus;
sorwakeup(head);
wakeup_one(&head->so_timeo);
}
OpenPOWER on IntegriCloud