From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796334710; b=zmUZX8/joQt06O+9P86XLy0pjjpGXq8jTRsQJi+VYOjtnVFockM0hW5m4Q1OmApw68CP 8CB0K5YGMAKgE2lA1jOiM9bVyu8SnYnpkD//DrnkGHtW/zJlmUR6bLIpuOP1xYrVrXxDb AtPks2L6zotbwh4+xj9FP11oU9MQ75lbZoH1KZsm/vxYDAMuZAox9mk57IqCfcVs5n7GK 25zrKXH4Q+UNo++/eA2QHBPxOOrtKbfRvFwXXQzhBXc4gho+Lo6tbMNmvv5xnrLyMjgy2 u6mo7ZDDVeibtLmkuWZCGTIajZ3E88HdIQUKhq1YdRUEPUk5zkyPFr199JyNhixQ/Zw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796334710; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=qTqeKyhTuhMnkw5Z6NenzDSpDpylvG533DRYE4IA+Oo=; b=HA6RNjMzu9lZvHJt2wkRwCRWBKVTFM/jG0Sa62toz2JuGibKvmWlweOD/ib5Lt/3beUT THTF6h7faa2K+G3H3kEeJ8MRcztLpMmVy2omdXXAeSBnP93ghktp7pgkbZr5bZZ4uCwRC yx1zHmSf2dZKYGeo8KA0AKDQ6Ro4iZ+1JaNb8O+OjNGhnkclPNBpyG4xY88jVkCWSmimb hVdLFAPnUYKQFLlyDJH4BCYsoz59KVcYgct+NnrtTtBlmP94RI8qWerxB8XWdI45Jexv/ 3F7EbeVhEUtrF7EvTDysXpTiF4Ys1aATHSXUB2KzeQXyMSGu3zNnFzPV36f7O7bXE3g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=R09QPqsO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0AC3606A322; Thu, 3 Dec 2026 21:51:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=R09QPqsO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 810131F000CE; Thu, 3 Dec 2026 21:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796334710; bh=qTqeKyhTuhMnkw5Z6NenzDSpDpylvG533DRYE4IA+Oo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=R09QPqsO9K7onZCMXNRLKQiHeuk6zjw2yW2my0qXb9uRyzN6wozV17gd1+/uGYIzm 6XLEGHxTsDvb2OJskv7PaSA7vJio/Gp8V5z8oG3t/cwyv2OyB5wNlAGU4+IG4eHeYu BmLZo50xX5x60ek9A2z79iTc/vt2tpIE7C864efFAyw5Z5y5hY/PLv+hE1lnewPzQK G4NJz2kdPN4Qk7A0g010exTk4bpSoQVhn02TkX8W/rbYDR5JWCICbTSEsq2dJe1l9g gyLBYRtNQ3aAx8lz2dKvGc2OBBxLlxf+CJBNfHxEFgmoQO1IJe6411DeoIN5n8yvtG fRjJV69ylBHbA== Subject: Re: [PATCH net 2/9] mptcp: keep an orphan while it can send its data From: netdev-bot+sashiko@kernel.org To: matttbe@kernel.org Cc: martineau@kernel.org, geliang@kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, dcaratti@redhat.com, netdev@vger.kernel.org, mptcp@lists.linux.dev, mason@kernel.org, stable@vger.kernel.org Date: Thu, 03 Dec 2026 21:51:49 +0000 Message-ID: <179633470902.3146.5343522154219240904@kernel.org> In-Reply-To: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-2-9f03efcb1a17@kernel.org> References: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-2-9f03efcb1a17@kernel.org> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 1 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The fix does not cover MPTCP connections that fell back to TCP (plain TCP peer), so they still get the reset this commit claims to… - [Medium] Unbounded orphan lifetime controlled by the remote peer (baseline decision: resolved later in the series). - [Low] The new timer restart in mptcp_check_send_data_fin() can overwrite a deliberately backdated close timeout. - [Low] mptcp_orphan_keep() evaluates `tcp_jiffies32 - READ_ONCE(tcp_sk(ssk)->rcv_tstamp) < 2 * TCP_RTO_MAX` under the msk… -- mptcp: keep an orphan while it can send its data This commit keeps an orphaned MPTCP socket alive past its close timeout while data is still pending and an active subflow recently received an ACK. In that case mptcp_worker() re-arms the timeout and pushes the pending data again, and the close timeout is also restarted when the DATA_FIN is sent for an orphan. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/647 > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c > index d6a07fa4b4e4c..82a0cbe38192e 100644 > --- a/net/mptcp/protocol.c > +++ b/net/mptcp/protocol.c > @@ -2814,6 +2814,28 @@ static bool mptcp_close_tout_expired(const struct sock *sk) > inet_csk(sk)->icsk_mtup.probe_timestamp + mptcp_close_timeout(sk)); > } > > +/* Before its DATA_FIN, keep an orphan while a subflow can send its data */ > +static bool mptcp_orphan_keep(struct sock *sk) > +{ > + struct mptcp_sock *msk = mptcp_sk(sk); > + struct mptcp_subflow_context *subflow; > + > + if (!sock_flag(sk, SOCK_DEAD) || msk->snd_nxt == msk->write_seq) > + return false; [Severity: High] Does this cover connections that fell back to plain TCP? The snd_nxt == write_seq check only counts data still queued at the MPTCP level. It does not count data that is already in the subflow's TCP write queue but has not been sent. On fallback, mptcp_check_allowed_size() doesn't apply the peer window: net/mptcp/protocol.c:mptcp_check_allowed_size() { ... if (__mptcp_check_fallback(msk)) return avail_size; ... } So the whole tail can move into msk->first as soon as it fits in the subflow sndbuf, even while the peer window is closed. __mptcp_push_pending() then calls mptcp_check_send_data_fin(). That sets snd_nxt = write_seq, restarts the close timeout (the new code further below) and calls mptcp_subflow_shutdown(). On fallback, that queues the TCP FIN behind the undelivered data and simulates the DATA_FIN ack: net/mptcp/protocol.c:mptcp_subflow_shutdown() { ... if (__mptcp_check_fallback(mptcp_sk(sk))) { pr_debug("Fallback\n"); ssk->sk_shutdown |= how; tcp_shutdown(ssk, how); ... WRITE_ONCE(mptcp_sk(sk)->snd_una, mptcp_sk(sk)->snd_nxt); ... } >>From then on, mptcp_orphan_keep() can never return true. When the restarted TCP_TIMEWAIT_LEN expires: mptcp_worker() mptcp_do_fastclose() /* sets fastclosing, returns early on fallback */ __mptcp_close_ssk(sk, ssk, subflow, 0) __mptcp_subflow_disconnect(ssk, subflow, fastclosing) tcp_disconnect(ssk, 0) /* RST, write queue purged */ Take an MPTCP server with a plain TCP client. The server writes data that fits in the subflow sndbuf, then calls close(), and the client pauses for more than 60 seconds. Would the client still get ECONNRESET and lose the tail? That is the symptom the commit message describes as fixed ("TCP delivered everything, as MPTCP now does"). The same logic is still there at the end of the series. Should the keep check also account for data queued in the subflows on fallback, or should fallback orphans be left to TCP's orphan handling? > + > + mptcp_for_each_subflow(msk, subflow) { > + struct sock *ssk = mptcp_subflow_tcp_sock(subflow); > + > + /* a live peer acks at least the probes, every TCP_RTO_MAX */ > + if (__mptcp_subflow_active(subflow) && > + tcp_jiffies32 - READ_ONCE(tcp_sk(ssk)->rcv_tstamp) < > + 2 * TCP_RTO_MAX) > + return true; [Severity: Low] Can this unsigned subtraction underflow? tcp_ack() writes tp->rcv_tstamp in softirq, under the subflow lock: tp->rcv_tstamp = tcp_jiffies32; This check runs under the msk socket lock only, and the order of the two loads here is unspecified. Consider this sequence: - the worker loads tcp_jiffies32 (T) - jiffies ticks - another CPU processes an ACK and stores rcv_tstamp = T + 1 - the worker loads rcv_tstamp The difference is then 0xffffffff, so a subflow that has just received an ACK is treated as not live. If it is the only active subflow, the orphan is fastclosed. Would taking a single tcp_jiffies32 snapshot and using a signed comparison avoid this? mptcp_close_tout_expired() just above already uses time_after32(). > + } > + > + return false; > +} > + [ ... ] > @@ -3151,6 +3173,11 @@ static void mptcp_worker(struct work_struct *work) > if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) > __mptcp_close_subflow(sk); > > + if (mptcp_close_tout_expired(sk) && mptcp_orphan_keep(sk)) { > + mptcp_start_tout_timer(sk); > + __mptcp_push_pending(sk, 0); > + } [Severity: Medium] With only this patch applied, what limits how long an orphan can be kept? Each time the close timeout expires, it is re-armed here as long as these hold: - snd_nxt != write_seq - an active subflow got any ACK within 2 * TCP_RTO_MAX There is no cap, no orphan count check and no memory pressure check. A peer that advertises a zero window and acks the probes could keep the msk and its send buffers pinned forever. The commit message notes that "nothing limits how long the peer can keep its window closed". The TCP orphan limits in tcp_probe_timer() (tcp_orphan_retries() and tcp_out_of_resources()) don't apply, because the subflows are not SOCK_DEAD. __mptcp_close() also doesn't count MPTCP orphans in tcp_orphan_count. This seems to be fixed later in the series: - "mptcp: limit an orphan probing a zero window" adds mptcp_subflow_probe_timed_out() - "mptcp: count orphans as TCP does" adds tcp_orphan_count_inc() and mptcp_orphan_oom() Since this patch has Cc: stable, could it be backported without those follow-ups? > if (mptcp_close_tout_expired(sk)) { > struct mptcp_subflow_context *subflow, *tmp; > [ ... ] > @@ -3392,6 +3419,10 @@ static void mptcp_check_send_data_fin(struct sock *sk) > > WRITE_ONCE(msk->snd_nxt, msk->write_seq); > > + /* an orphan's close timeout is for the DATA_FIN exchange */ > + if (sock_flag(sk, SOCK_DEAD)) > + mptcp_start_tout_timer(sk); [Severity: Low] Can this restart overwrite a close timeout that was backdated on purpose? When the last subflow of an orphan is closed while msk->first is already in TCP_CLOSE, __mptcp_close_ssk() does: if (sock_flag(sk, SOCK_DEAD)) { /* let the worker close and destroy the orphan */ mptcp_set_close_tout(sk, tcp_jiffies32 - (mptcp_close_timeout(sk) + 1)); mptcp_schedule_work(sk); There are two ways this can run before mptcp_check_send_data_fin(): - inside mptcp_worker() itself, earlier in the same run, via mptcp_pm_worker()->mptcp_pm_rm_addr_recv()-> mptcp_pm_rm_addr_or_subflow()->mptcp_close_ssk() - from netlink PM paths such as mptcp_pm_nl_subflow_destroy_doit(), before the worker runs A DATA_FIN may still be pending at that point. For example, __mptcp_subflow_push_pending() pushed the last data and only scheduled the worker, and all the data was DATA_ACKed. In that case, the new mptcp_start_tout_timer() call resets probe_timestamp to now. Then mptcp_close_tout_expired() is false and the state is not TCP_CLOSE, so __mptcp_destroy_sock() is skipped. Would the orphan then stay around for another TCP_TIMEWAIT_LEN with no usable subflow, instead of being destroyed in this worker run as it was before? This code is unchanged at the end of the series. > + > mptcp_for_each_subflow(msk, subflow) { > struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow); > -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17%40kernel.org