diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index dc9f11b8a0f9..2e61c3125c4d 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -560,9 +560,15 @@ out: } /* - * Accept a connection. Essentially all the work is - * done at higher levels; just return the address - * of the peer, storing through addr. + * Accept a connection. Essentially all the work is done at higher levels; + * just return the address of the peer, storing through addr. + * + * The rationale for acquiring the tcbinfo lock here is somewhat complicated, + * and is described in detail in the commit log entry for r175612. Acquiring + * it delays an accept(2) racing with sonewconn(), which inserts the socket + * before the inpcb address/port fields are initialized. A better fix would + * prevent the socket from being placed in the listen queue until all fields + * are fully initialized. */ static int tcp_usr_accept(struct socket *so, struct sockaddr **nam)