]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mptcp: cope racing subflow creation in mptcp_rcv_space_adjust
authorPaolo Abeni <pabeni@redhat.com>
Fri, 8 Nov 2024 10:58:17 +0000 (11:58 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 Nov 2024 03:06:34 +0000 (19:06 -0800)
Additional active subflows - i.e. created by the in kernel path
manager - are included into the subflow list before starting the
3whs.

A racing recvmsg() spooling data received on an already established
subflow would unconditionally call tcp_cleanup_rbuf() on all the
current subflows, potentially hitting a divide by zero error on
the newly created ones.

Explicitly check that the subflow is in a suitable state before
invoking tcp_cleanup_rbuf().

Fixes: c76c6956566f ("mptcp: call tcp_cleanup_rbuf on subflows")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/02374660836e1b52afc91966b7535c8c5f7bafb0.1731060874.git.pabeni@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/mptcp/protocol.c

index 95a5a3da394474797abed09e73e9e61027959a1f..48d480982b7870e8b945d29c7f6d8d3896003101 100644 (file)
@@ -2082,7 +2082,8 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
                                slow = lock_sock_fast(ssk);
                                WRITE_ONCE(ssk->sk_rcvbuf, rcvbuf);
                                WRITE_ONCE(tcp_sk(ssk)->window_clamp, window_clamp);
-                               tcp_cleanup_rbuf(ssk, 1);
+                               if (tcp_can_send_ack(ssk))
+                                       tcp_cleanup_rbuf(ssk, 1);
                                unlock_sock_fast(ssk, slow);
                        }
                }