From: evan.li@linux.alibaba.com
To: matttbe@kernel.org, martineau@kernel.org, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org
Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev,
linux-kernel@vger.kernel.org, Evan Li <evan.li@linux.alibaba.com>,
kitta <kitta@linux.alibaba.com>
Subject: [PATCH] subflow: relax WARN in subflow_data_ready() on teardown races
Date: Fri, 12 Dec 2025 17:59:09 +0800 [thread overview]
Message-ID: <20251212095909.2480475-1-evan.li@linux.alibaba.com> (raw)
From: Evan Li <evan.li@linux.alibaba.com>
A WARN splat in subflow_data_ready() can be triggered when a subflow
enters an unexpected state during connection teardown or cleanup:
WARNING: net/mptcp/subflow.c:1527 at subflow_data_ready+0x38a/0x670
This comes from the following check:
WARN_ON_ONCE(!__mptcp_check_fallback(msk) &&
!subflow->mp_capable &&
!subflow->mp_join &&
!(state & TCPF_CLOSE));
Under fuzzing and other stress scenarios, there are legitimate windows
where this condition can become true without indicating a real bug, for
example:
during connection teardown / fastclose handling
races with subflow destruction
packets arriving after subflow cleanup
when the parent MPTCP socket is being destroyed
After commit ae155060247b ("mptcp: fix duplicate reset on fastclose"),
these edge cases became easier to trigger and the WARN started firing
spuriously, causing noisy reports but no functional issues.
Refine the state check in subflow_data_ready() so that:
if the socket is in a known teardown/cleanup situation
(SOCK_DEAD, zero parent refcnt, or repair/recv-queue handling),
the function simply returns without emitting a warning; and
for other unexpected states, we emit a ratelimited pr_debug() to
aid debugging, instead of a WARN_ON_ONCE() that can panic
fuzzing/CI kernels or flood logs in production.
This suppresses the bogus warning while preserving diagnostics for any
real state machine bugs.
Fixes: ae155060247b ("mptcp: fix duplicate reset on fastclose")
Reported-by: kitta <kitta@linux.alibaba.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220856
Co-developed-by: kitta <kitta@linux.alibaba.com>
Signed-off-by: Evan Li <evan.li@linux.alibaba.com>
---
net/mptcp/subflow.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 86ce58ae5..01d30679c 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1524,9 +1524,27 @@ static void subflow_data_ready(struct sock *sk)
return;
}
- WARN_ON_ONCE(!__mptcp_check_fallback(msk) && !subflow->mp_capable &&
- !subflow->mp_join && !(state & TCPF_CLOSE));
-
+ /* Check if subflow is in a valid state. Skip warning for legitimate edge cases
+ * such as connection teardown, race conditions, or when parent is being destroyed.
+ */
+ if (!__mptcp_check_fallback(msk) && !subflow->mp_capable &&
+ !subflow->mp_join && !(state & TCPF_CLOSE)) {
+ /* Legitimate cases where this can happen:
+ * 1. During connection teardown
+ * 2. Race conditions with subflow destruction
+ * 3. Packets arriving after subflow cleanup
+ * Log debug info but don't warn loudly in production.
+ */
+ if (unlikely(tcp_sk(sk)->repair_queue == TCP_RECV_QUEUE ||
+ sock_flag(sk, SOCK_DEAD) || !refcount_read(&parent->sk_refcnt))) {
+ /* Expected during cleanup, silently return */
+ return;
+ }
+ /* For other cases, still log for debugging but don't WARN */
+ if (net_ratelimit())
+ pr_debug("MPTCP: subflow in unexpected state sk=%p parent=%p state=%u\n",
+ sk, parent, state);
+ }
if (mptcp_subflow_data_available(sk)) {
mptcp_data_ready(parent, sk);
--
2.43.7
next reply other threads:[~2025-12-12 9:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-12 9:59 evan.li [this message]
2025-12-12 10:34 ` [PATCH] subflow: relax WARN in subflow_data_ready() on teardown races Matthieu Baerts
2025-12-12 11:15 ` MPTCP CI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251212095909.2480475-1-evan.li@linux.alibaba.com \
--to=evan.li@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kitta@linux.alibaba.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox