From: Bryam Vargas smc_switch_conns() moves a connection to the new link without smc_switch_cursor() if its state is on a list of closing states. SMC_APPCLOSEWAIT1 is on that list, but data can still be sent in that state: smc_sendmsg() takes it while the peer has only shut down its write side, and data already queued goes out after the peer's close as well. Writes that were in flight on the old link are not sent again, and no failover validation message is sent; RFC 7609 section 4.6 requires both when a connection changes links. The connection's switch generation is not bumped either. So a completion that the old link delivers late is only ordered against tx_curs_fin, and that order comes from the u16 wrap. Once tx_curs_fin is more than 32768 wraps ahead of that completion's cursor, the completion reads as ahead of tx_curs_fin and is credited. sndbuf_space can then go past the send buffer size. Take SMC_APPCLOSEWAIT1 out of the list, so that the connection is switched like one in SMC_ACTIVE. As with SMC_ACTIVE, the switch can wait for a free slot after it drops conns_lock. While the link group is listed, a close() that meanwhile frees the connection waits in smcr_buf_unuse(). It waits there for the LLC flow that the switch runs in, if any, and for llc_conf_mutex. Every caller of smc_switch_conns() holds llc_conf_mutex. Fixes: c6f02ebeea3a ("net/smc: switch connections to alternate link") Closes: https://lore.kernel.org/all/sashiko-outbox-249474@kernel.org/ Suggested-by: Sidraya Jayagond Cc: stable@vger.kernel.org # depends on "net/smc: do not credit stale CDC completions after a link switch" Signed-off-by: Bryam Vargas --- net/smc/smc_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index a32f676b19f8..a4783d73bd37 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -1165,11 +1165,13 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr, /* conn->lnk not yet set in SMC_INIT state */ if (smc->sk.sk_state == SMC_INIT) continue; + /* not SMC_APPCLOSEWAIT1: data can still be sent there, + * see smc_tx_sendmsg() and smc_tx_sndbuf_nonempty() + */ if (smc->sk.sk_state == SMC_CLOSED || smc->sk.sk_state == SMC_PEERCLOSEWAIT1 || smc->sk.sk_state == SMC_PEERCLOSEWAIT2 || smc->sk.sk_state == SMC_APPFINCLOSEWAIT || - smc->sk.sk_state == SMC_APPCLOSEWAIT1 || smc->sk.sk_state == SMC_APPCLOSEWAIT2 || smc->sk.sk_state == SMC_PEERFINCLOSEWAIT || smc->sk.sk_state == SMC_PEERABORTWAIT || -- 2.56.1