mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
raw ip: fix race of two connect(2)
The historical design of sockets is that on a re-connect the disconnect is
performed at the socket layer in soconnectat(). Since SMP times this is
known to be racy and the function has appopriate comment. I missed that
in the recent change. The pr_connect method should normally expect the
socket to be already disconnected, however should be able to handle a race
where socket is actually connected. Convert the check that incorrectly
tried to handle normal path of re-connect into check that handles the
race.
Reported by: markj
Fixes: ece716c5d3
This commit is contained in:
1 parent
4dd9e4ed97
commit
ee5d87a3e2
1 file changed
+1
-2
@@ -904,8 +904,7 @@ rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
KASSERT(inp != NULL, ("rip_connect: inp == NULL"));
|
||||
|
||||
INP_WLOCK(inp);
|
||||
if (inp->inp_faddr.s_addr != INADDR_ANY &&
|
||||
addr->sin_addr.s_addr == INADDR_ANY)
|
||||
if (__predict_false(inp->inp_faddr.s_addr != INADDR_ANY))
|
||||
rip_dodisconnect(inp, false);
|
||||
if (addr->sin_addr.s_addr != INADDR_ANY) {
|
||||
inp->inp_faddr = addr->sin_addr;
|
||||
|
||||
Reference in new issue
Block a user