Skip to content

Commit 0226436

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: do not rely on implicit state check in mptcp_listen()
Since the blamed commit, closing the first subflow resets the first subflow socket state to SS_UNCONNECTED. The current mptcp listen implementation relies only on such state to prevent touching not-fully-disconnected sockets. Incoming mptcp fastclose (or paired endpoint removal) unconditionally closes the first subflow. All the above allows an incoming fastclose followed by a listen() call to successfully race with a blocking recvmsg(), potentially causing the latter to hit a divide by zero bug in cleanup_rbuf/__tcp_select_window(). Address the issue explicitly checking the msk socket state in mptcp_listen(). An alternative solution would be moving the first subflow socket state update into mptcp_disconnect(), but in the long term the first subflow socket should be removed: better avoid relaying on it for internal consistency check. Fixes: b29fcfb ("mptcp: full disconnect implementation") Cc: [email protected] Reported-by: Christoph Paasch <[email protected]> Closes: multipath-tcp/mptcp_net-next#414 Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Matthieu Baerts <[email protected]> Signed-off-by: Matthieu Baerts <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3fffa15 commit 0226436

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/mptcp/protocol.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,6 +3703,11 @@ static int mptcp_listen(struct socket *sock, int backlog)
37033703
pr_debug("msk=%p", msk);
37043704

37053705
lock_sock(sk);
3706+
3707+
err = -EINVAL;
3708+
if (sock->state != SS_UNCONNECTED || sock->type != SOCK_STREAM)
3709+
goto unlock;
3710+
37063711
ssock = __mptcp_nmpc_socket(msk);
37073712
if (IS_ERR(ssock)) {
37083713
err = PTR_ERR(ssock);

0 commit comments

Comments
 (0)