Article View: linux.kernel.netdev
Article #26241[PATCH net v3 1/7] net/smc: take the socket spinlock across the failover cursor switch
From: Bryam Vargas via B4 Relay
Date: Thu, 03 Dec 2026 09:15
Date: Thu, 03 Dec 2026 09:15
56 lines
13046 bytes
13046 bytes
From: Bryam Vargas <hexlabsecurity@proton.me>
smc_switch_cursor() rewrites the send cursors, sndbuf_space and
peer_rmbe_space under send_lock only. smc_cdc_tx_handler() updates
tx_curs_fin, local_tx_ctrl_fin and sndbuf_space, and
smc_cdc_msg_recv_action() updates the peer's consumer cursor and
peer_rmbe_space, under bh_lock_sock(). A CDC completion handled during a
link switch can credit its bytes twice and leave tx_curs_fin ahead of
tx_curs_sent, or leave tx_curs_sent and the producer cursor out of step,
so the resend writes at the wrong RMB offset. A CDC received at the same
time can be counted twice in peer_rmbe_space.
Take bh_lock_sock() around the link change and the cursor switch, in
the order the receive path already uses (the socket spinlock, then
send_lock).
Fixes: c6f02ebeea3a ("net/smc: switch connections to alternate link")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261029-b4-disp-33001ace-v8-0-f9bb96e17827%40proton.me?part=4
Cc: stable@vger.kernel.org
Reviewed-by: Sidraya Jayagond <sidraya@linux.ibm.com>
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
---
net/smc/smc_core.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index a3164201c142..73e86100e6db 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -1171,11 +1171,18 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr,
/* pre-fetch buffer outside of send_lock, might sleep */
rc = smc_cdc_get_free_slot(conn, to_lnk, &wr_buf, NULL, &pend);
if (!rc) {
- /* avoid race with smcr_tx_sndbuf_nonempty() */
- spin_lock_bh(&conn->send_lock);
+ /* the CDC completion handler and the receive path
+ * update the same cursors under the socket's spinlock,
+ * smcr_tx_sndbuf_nonempty() under send_lock
+ */
+ local_bh_disable();
+ bh_lock_sock(&smc->sk);
+ spin_lock(&conn->send_lock);
smc_switch_link_and_count(conn, to_lnk);
rc = smc_switch_cursor(smc, pend, wr_buf);
- spin_unlock_bh(&conn->send_lock);
+ spin_unlock(&conn->send_lock);
+ bh_unlock_sock(&smc->sk);
+ local_bh_enable();
}
sock_put(&smc->sk);
if (rc)
--
2.56.1
Technical Details
Message-ID:
<20261203-b4-disp-ba1ad55e-v3-1-6834ff90c5d0@proton.me>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376429-linux-kernel-netdev=dewy.ruReferences:
<20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0@proton.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376429-linux-kernel-netdev=dewy.ru From: devnull+hexlabsecurity.proton.me@kernel.org (Bryam Vargas via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH net v3 1/7] net/smc: take the socket spinlock across the failover cursor switch Date: Thu, 03 Dec 2026 04:15:03 -0500 Organization: Usenet Network Message-ID: <20261203-b4-disp-ba1ad55e-v3-1-6834ff90c5d0@proton.me> References: <20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0@proton.me> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2446050"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:fsGHpvDXLNx2B/LXVHsyUjWv19E= sha256:yugbFAhLKeW3gCyoqgQkq9RMACM/lCnm/U3ffh4IsK4= sha1:iIWvHBIO1EBM1cK3SqpWQxViios= sha256:0cD+/p3tMtWRKFHM/sJ6hAk2pmczgXLRD37HmEIywSQ= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id B47FA11789E; Thu, 3 Dec 2026 12:16:42 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DMcdG9EdsLVw; Thu, 3 Dec 2026 12:16:39 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376429-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 0B2CF117894; Thu, 3 Dec 2026 12:16:30 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id D5B5E32C5A; Thu, 3 Dec 2026 09:15:33 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796289311; b=bKyaex3JwNl7RgIHMWQQFYubtc2Vt/xrbXt7puEwG52HId/8JxqctjY6920aVVlejyi2 2qbdE7tXxY82xJFBvdXt9jHKDsndcLgBbBcLRSRyO8qzI3vCCL/uPLWa43U/nHuXhnuzk SmxAE82O9CtfgTOQCMDfLqwj/AitSF943NvtbVzDn9SUn9PsLiD0eATH443oFv/j/tsUc 8ResEZFhAoTP4msKG7O3K81JErnwmKJCJvLwbl7vetD8iD7zSBC7Zw0lYhKbMHoyD6JY5 /LnOGUwI1eQR+BW1/GZOACCE0EiLuU2iArHjd7RaiezInf+oaynTLcganHRebJ2kz4A== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289311; h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date: Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=zcBo/cyCx46rjhHBAmJbCHOZuyfIc1hufTRF3uvo7aw=; b=l5z/gjNWVZ3WE4mE5k//SMajHG6DjyWZ/dnLKQA0arn3WagdAQm1Wxcqd1t/o3nhIBSu KQGW7YjaZcXvgAtkmYB6dmR+VtbS33bkqqa37hHgL7wM0DHUOftoOxpJLFrCdgebjAWIZ Ce0Zf2Lmo+9yB7pUjOVE4B9Gu4+x02srH8DH25tJ6gX+wzLvyQ40JcI0Ri6IAW9tWnoi6 bydWY3ZKpGBK4S+ozQVf13d1srJaEXfAA/mbuld6W+46jpcw6VhqRySWl7HjvRRh3nihB OK9oteSijlzwwt2kEOPz7cDttBMCkR9i2G6XZKOJpjHVHSnvkWiEAvVXSP7KxOlD8Ww== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DI5pz2is; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03DF4606A6BC; Thu, 3 Dec 2026 09:15:11 +0000 (UTC) X-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=DI5pz2is X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796289305; b=qwgDo9S62umBljbIGjrwjL5oWeZm+w+m5H/+wExudZQcGYVeommDuCYvVEo7CuhJdVw3 9KEGwNPetSaceHbbTpzj/jDf3IipLNhiyHd6pxXE8kYnmGOhTrUXXVotu964CIOkApx9K q9ndQ0tIbv6dE2hiAQgi51pTZjOCwc4arBL8+oiOS1vF9wNqQdiMT7zbLru0Hoy3diQbx wVw4wqDbos5tJcfGhTsGT3t/BHoErU68nQOPwq6CfV5KGqrTZ5Lq3nCRUnx04b/y/8v5X e0CMyTyhSpNpIs331SXVhVNl1bXypXwqVAfPaMy2KgyGd1sCH9gjjtLYblN9Kg/aOLQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289305; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=zcBo/cyCx46rjhHBAmJbCHOZuyfIc1hufTRF3uvo7aw=; b=nqIg1GE/1zc0sqoI4YgTfOqnEprFbWQ+0dbQN9hSlPPByNT1OQEdHZYCqRTMKcvtZOb+ B3gyrHf3lJx+RmwQsG7MJ7iMLblBEf4mOldeZ2W5DImHQwI6EdSTC2OEG9tF1ADZOsDe6 /EzNK5A+4hUyj9CTKAJDtVzkTA06+HvD/QNDQgSz3ITsOtQkdfUbRoyq44TpBpoWgvP5x 7A/O2R2cuVw6wWpEwdnGB6K7N/ZMXOgDtgSZWujeYnBbm+1Rhq0X9IlaKCUQSCIBTLrF9 HBH2NmZ8tqwVVPq99Lwfk+MT/T2fj8R28n/9KjCtbbe4ksaQkl6nEn0r/BfbWugmx/w== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DI5pz2is; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-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 1AD6B606A336; Thu, 3 Dec 2026 09:15:04 +0000 (UTC) X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796289304; b=evZklUPTWYNcORBqed8K/MR5pCnJiJ75lz2rDBBtRlud2SZptQGRpbJNTR8rxhatFttx xqCdd5pIWgCiPRh+j7CfstBC1ZmC1Z9VnbxiP9fc2g8wi32da7zBHwDirxNxa+aIYkWxo ZBhWi32IRS8A6FvY4gtXUQFC/GQZsjze1gWqPyFrO0oEm6/FDSPpeMfycR1iecb4Xqx2z yjLv/tyB1TqsoXwB6Yvvr+J/mxaq0CIq5mBjB5ByuGN6IZQFqIJvdQ8vZvLsd3ZYJQDIP a7noZZbi0Z2hg9xbjRSXePv4bcSap0fJZE3AQjxcRZSgSVhxi/3kETUiW/DtUBJgkgw== X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796289304; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=zcBo/cyCx46rjhHBAmJbCHOZuyfIc1hufTRF3uvo7aw=; b=RnXBoxz48WKI3l2laBL/IszE6n7cSIhe38TSb+bSJI8HtEfLU+jir4N/DDlG1QRagpge wKCBkEukTC+gGUi7fyouDATfB0obtyGkhbrmqNdV7eGIt6YH5Tisji7L/2yhuhIsHJRaA h4sZRqMMC9BDfz6/uPIGKIsH/LoFVRdFp+uckd99S7vFZMy9VjLH/inGNNWQGL45kW2Kr 1GtMIwGdZGQiETQ3LxvzfgKVbky12Ef9PFzViCJLAYnxLf870Z6XJX5+w1+p4rwiRA5bg t+qr/roMfLvlxkBtAW6EylGQAOOtr9/nIPNffX5nf+LVtJ4owUUu927zS5DPtJlcpuA== X-ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 0A60E1F000C1; Thu, 3 Dec 2026 09:15:04 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796289304; bh=zcBo/cyCx46rjhHBAmJbCHOZuyfIc1hufTRF3uvo7aw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=DI5pz2is42nqti62VUBsSm6mlQi8hIT3a6qb6W/LhKqYI6DeTXekxg5B9MiiCwh76 ALGQc2Dcza+x6Lko/xZreS+dprZ8nD8c2Jy2IMtEKqjVO8ebwrTS7XU8H+K/Z457B/ e6HXGWSm+afypjUc+2sL0pwd8YRzTxC1PK/s8bfQcjyhK00KJSNUcN2uHMFotqdrYO avj1TmmbgbOC3BfevsqRxRDnP+wrvjddfMPhXlV2ZfINzpBFeIrfr3lkOLCmJDxo7V r27+n0aEAHkTI2mGGBR6wvE9orArIXZWKxJkgq+hwuK3GfSTaMoiWu3dUy7c91Qbau J01abJYs5wAQw== X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 888804F8AB; Thu, 3 Dec 2026 09:15:03 +0000 (UTC) X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261203-b4-disp-ba1ad55e-v3-0-6834ff90c5d0@proton.me> X-Cc: Wen Gu <guwen@linux.alibaba.com>, Guangguan Wang <guangguan.wang@linux.alibaba.com>, Tony Lu <tonylu@linux.alibaba.com>, Ursula Braun <ubraun@linux.ibm.com>, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, Hidayath Khan <hidayath@linux.ibm.com>, Simon Horman <horms@kernel.org>, Wenjia Zhang <wenjia@linux.ibm.com>, linux-kernel@vger.kernel.org, Stefan Raspl <raspl@linux.ibm.com>, netdev@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796289302; l=2240; i=hexlabsecurity@proton.me; s=default; h=from:subject:message-id; bh=veFWe5+QvKiyxi5kZ016yIOUwcv6Zpb5UPiwu1VffiY=; b=s37TMVMDxuXg3CqU4+0ZyItC1FvKerPfL6HG+aVT/fp4rbHbWrooyVT1Yvd1nkx352h3rigjU cqAENdX4nIXA3vn+sfhEKb2O4QTn85A02tvBonhJS0O+lDpI2emSERD X-Developer-Key: i=hexlabsecurity@proton.me; a=ed25519; pk=xw1AhCtQdvuoQc+bOQIYy9o8G++cp4/VniI2G/tc3G8= X-Endpoint-Received: by B4 Relay for hexlabsecurity@proton.me/default with auth_id=893 X-Original-From: Bryam Vargas <hexlabsecurity@proton.me> X-Reply-To: hexlabsecurity@proton.me