Skip to contentSkip to conversation

net/smc: avoid early lgr access in smc_clc_wait_msg

PATCH Applied Ren Wei 3 participants 3 messages Apr 22 – Apr 23 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ren Wei

author
#1 lore raw

PATCH 1/1 net/smc: avoid early lgr access in smc_clc_wait_msg

From: Ruijie Li <[email protected]>

A CLC decline can be received while the handshake is still in an early stage, before the connection has been associated with a link group.

The decline handling in smc_clc_wait_msg() updates link-group level sync state for first-contact declines, but that state only exists after link group setup has completed. Guard the link-group update accordingly and keep the per-socket peer diagnosis handling unchanged.

This preserves the existing sync_err handling for established link-group contexts and avoids touching link-group state before it is available.

Fixes 0cfdd8f92cac ("smc: connection and link group creation")
---
 net/smc/smc_clc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/smc_clc.c +2 -2
index c38fc7bf0a7e..014d527d5462 100644
@@ -788,8 +788,8 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
 		dclc = (struct smc_clc_msg_decline *)clcm;
 		reason_code = SMC_CLC_DECL_PEERDECL;
 		smc->peer_diagnosis = ntohl(dclc->peer_diagnosis);
-		if (((struct smc_clc_msg_decline *)buf)->hdr.typev2 &
-						SMC_FIRST_CONTACT_MASK) {
+		if ((dclc->hdr.typev2 & SMC_FIRST_CONTACT_MASK) &&
+		    smc->conn.lgr) {
 			smc->conn.lgr->sync_err = 1;
 			smc_lgr_terminate_sched(smc->conn.lgr);
 		}
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#2 lore raw
Quoted 13 lines · Ren Wei

From: Ruijie Li <[email protected]>

A CLC decline can be received while the handshake is still in an early stage, before the connection has been associated with a link group.

The decline handling in smc_clc_wait_msg() updates link-group level sync state for first-contact declines, but that state only exists after link group setup has completed. Guard the link-group update accordingly and keep the per-socket peer diagnosis handling unchanged.

This preserves the existing sync_err handling for established link-group contexts and avoids touching link-group state before it is available.

Quoted 8 lines
Fixes 0cfdd8f92cac ("smc: connection and link group creation")

Best regards,
Dust

Quoted 21 lines

---
net/smc/smc_clc.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/smc_clc.c +2 -2
index c38fc7bf0a7e..014d527d5462 100644
@@ -788,8 +788,8 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
 		dclc = (struct smc_clc_msg_decline *)clcm;
 		reason_code = SMC_CLC_DECL_PEERDECL;
 		smc->peer_diagnosis = ntohl(dclc->peer_diagnosis);
-		if (((struct smc_clc_msg_decline *)buf)->hdr.typev2 &
-						SMC_FIRST_CONTACT_MASK) {
+		if ((dclc->hdr.typev2 & SMC_FIRST_CONTACT_MASK) &&
+		    smc->conn.lgr) {
 			smc->conn.lgr->sync_err = 1;
 			smc_lgr_terminate_sched(smc->conn.lgr);
 		}
Signature · 1 line
2.34.1
#3 lore raw
In reply to Ren Wei
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 22 Apr 2026 23:40:18 +0800 you wrote:

From: Ruijie Li <[email protected]>

A CLC decline can be received while the handshake is still in an early stage, before the connection has been associated with a link group.

The decline handling in smc_clc_wait_msg() updates link-group level sync state for first-contact declines, but that state only exists after link group setup has completed. Guard the link-group update accordingly and keep the per-socket peer diagnosis handling unchanged.

[...]

Here is the summary with links:
- [net,1/1] net/smc: avoid early lgr access in smc_clc_wait_msg

    https://git.kernel.org/netdev/net/c/5a8db80f721d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html