From b2475c2334dc1acf9ec5aad6a37a806c1de85780 Mon Sep 17 00:00:00 2001 From: Wen Gu Date: Mon, 16 Jun 2025 16:09:08 +0800 Subject: [PATCH] anolis: net/smc: fix the issue of server fallback failure ANBZ: #21781 A failure was found when smc server tries to send clc decline messages. It results in connections being unexpectedly reset, rather than a fallback. It was introduced by the commit described by 'Fixes' tag, which removes the check for smc_listen_work, leading to smc_net_clcsock_sendmsg consistently returning -EOPNOTSUPP. To fix it, we restores the specific logic that ensures the clc decline message is properly handled and sent when the server transitions to a fallback state. Besides, there is no need to check the connect_work for the client here, as the client first sends a decline message and then sets use_fallback to true, which is the opposite of the service side. Fixes: 718c9ff4980b ("net/smc: fix LGR and link use-after-free issue") Co-developed-by: D.Wythe Signed-off-by: Wen Gu Reviewed-by: D. Wythe Link: https://gitee.com/anolis/cloud-kernel/pulls/5442 --- net/smc/smc_inet.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/smc/smc_inet.c b/net/smc/smc_inet.c index 70686c62c178..41cbaf42123c 100644 --- a/net/smc/smc_inet.c +++ b/net/smc/smc_inet.c @@ -290,6 +290,9 @@ static int smc_inet_clcsock_sendmsg(struct socket *sock, struct msghdr *msg, siz smc = smc_sk(sock->sk); + if (current_work() == &smc->smc_listen_work) + goto send; + /* smc_inet_clcsock_sendmsg only works for smc handshaking * fallback sendmsg should process by smc_inet_sendmsg. * see more details in smc_inet_sendmsg(). @@ -301,6 +304,7 @@ static int smc_inet_clcsock_sendmsg(struct socket *sock, struct msghdr *msg, siz * Therefore, we rely on the implementation of conenct_work() implementation, which * is locked always. */ +send: return tcp_sendmsg_locked(sk, msg, len); }