Skip to content

Commit b7c3528

Browse files
Evan Liintel-lab-lkp
authored andcommitted
subflow: relax WARN in subflow_data_ready() on teardown races
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 ae15506 ("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: ae15506 ("mptcp: fix duplicate reset on fastclose") Reported-by: kitta <[email protected]> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220856 Co-developed-by: kitta <[email protected]> Signed-off-by: Evan Li <[email protected]>
1 parent 35b12c9 commit b7c3528

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

net/mptcp/subflow.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,9 +1522,27 @@ static void subflow_data_ready(struct sock *sk)
15221522
return;
15231523
}
15241524

1525-
WARN_ON_ONCE(!__mptcp_check_fallback(msk) && !subflow->mp_capable &&
1526-
!subflow->mp_join && !(state & TCPF_CLOSE));
1527-
1525+
/* Check if subflow is in a valid state. Skip warning for legitimate edge cases
1526+
* such as connection teardown, race conditions, or when parent is being destroyed.
1527+
*/
1528+
if (!__mptcp_check_fallback(msk) && !subflow->mp_capable &&
1529+
!subflow->mp_join && !(state & TCPF_CLOSE)) {
1530+
/* Legitimate cases where this can happen:
1531+
* 1. During connection teardown
1532+
* 2. Race conditions with subflow destruction
1533+
* 3. Packets arriving after subflow cleanup
1534+
* Log debug info but don't warn loudly in production.
1535+
*/
1536+
if (unlikely(tcp_sk(sk)->repair_queue == TCP_RECV_QUEUE ||
1537+
sock_flag(sk, SOCK_DEAD) || !refcount_read(&parent->sk_refcnt))) {
1538+
/* Expected during cleanup, silently return */
1539+
return;
1540+
}
1541+
/* For other cases, still log for debugging but don't WARN */
1542+
if (net_ratelimit())
1543+
pr_debug("MPTCP: subflow in unexpected state sk=%p parent=%p state=%u\n",
1544+
sk, parent, state);
1545+
}
15281546
if (mptcp_subflow_data_available(sk)) {
15291547
mptcp_data_ready(parent, sk);
15301548

0 commit comments

Comments
 (0)