Skip to content

Commit f0858e1

Browse files
ruijieli51gregkh
authored andcommitted
net/smc: avoid early lgr access in smc_clc_wait_msg
commit 5a8db80 upstream. 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: 0cfdd8f ("smc: connection and link group creation") Cc: stable@kernel.org Reported-by: Yuan Tan <yuantan098@gmail.com> Reported-by: Yifan Wu <yifanwucs@gmail.com> Reported-by: Juefei Pu <tomapufckgml@gmail.com> Reported-by: Xin Liu <bird@lzu.edu.cn> Signed-off-by: Ruijie Li <ruijieli51@gmail.com> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn> Reviewed-by: Dust Li <dust.li@linux.alibaba.com> Link: https://patch.msgid.link/08c68a5c817acf198cce63d22517e232e8d60718.1776850759.git.ruijieli51@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e98bd88 commit f0858e1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

net/smc/smc_clc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
784784
dclc = (struct smc_clc_msg_decline *)clcm;
785785
reason_code = SMC_CLC_DECL_PEERDECL;
786786
smc->peer_diagnosis = ntohl(dclc->peer_diagnosis);
787-
if (((struct smc_clc_msg_decline *)buf)->hdr.typev2 &
788-
SMC_FIRST_CONTACT_MASK) {
787+
if ((dclc->hdr.typev2 & SMC_FIRST_CONTACT_MASK) &&
788+
smc->conn.lgr) {
789789
smc->conn.lgr->sync_err = 1;
790790
smc_lgr_terminate_sched(smc->conn.lgr);
791791
}

0 commit comments

Comments
 (0)