mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 15:18:19 +00:00
net/smc: fix listen processing for SMC-Rv2
[ Upstream commit8c3b8dc5cc
] In the process of checking whether RDMAv2 is available, the current implementation first sets ini->smcrv2.ib_dev_v2, and then allocates smc buf desc, but the latter may fail. Unfortunately, the caller will only check the former. In this case, a NULL pointer reference will occur in smc_clc_send_confirm_accept() when accessing conn->rmb_desc. This patch does two things: 1. Use the return code to determine whether V2 is available. 2. If the return code is NODEV, continue to check whether V1 is available. Fixes:e49300a6bf
("net/smc: add listen processing for SMC-Rv2") Signed-off-by: liuyacan <liuyacan@corp.netease.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ee82867391
commit
5c66fb080b
1 changed files with 27 additions and 17 deletions
|
@ -1930,13 +1930,13 @@ static int smc_listen_rdma_reg(struct smc_sock *new_smc, bool local_first)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void smc_find_rdma_v2_device_serv(struct smc_sock *new_smc,
|
||||
struct smc_clc_msg_proposal *pclc,
|
||||
struct smc_init_info *ini)
|
||||
static int smc_find_rdma_v2_device_serv(struct smc_sock *new_smc,
|
||||
struct smc_clc_msg_proposal *pclc,
|
||||
struct smc_init_info *ini)
|
||||
{
|
||||
struct smc_clc_v2_extension *smc_v2_ext;
|
||||
u8 smcr_version;
|
||||
int rc;
|
||||
int rc = 0;
|
||||
|
||||
if (!(ini->smcr_version & SMC_V2) || !smcr_indicated(ini->smc_type_v2))
|
||||
goto not_found;
|
||||
|
@ -1954,26 +1954,31 @@ static void smc_find_rdma_v2_device_serv(struct smc_sock *new_smc,
|
|||
ini->smcrv2.saddr = new_smc->clcsock->sk->sk_rcv_saddr;
|
||||
ini->smcrv2.daddr = smc_ib_gid_to_ipv4(smc_v2_ext->roce);
|
||||
rc = smc_find_rdma_device(new_smc, ini);
|
||||
if (rc) {
|
||||
smc_find_ism_store_rc(rc, ini);
|
||||
if (rc)
|
||||
goto not_found;
|
||||
}
|
||||
|
||||
if (!ini->smcrv2.uses_gateway)
|
||||
memcpy(ini->smcrv2.nexthop_mac, pclc->lcl.mac, ETH_ALEN);
|
||||
|
||||
smcr_version = ini->smcr_version;
|
||||
ini->smcr_version = SMC_V2;
|
||||
rc = smc_listen_rdma_init(new_smc, ini);
|
||||
if (!rc)
|
||||
rc = smc_listen_rdma_reg(new_smc, ini->first_contact_local);
|
||||
if (!rc)
|
||||
return;
|
||||
ini->smcr_version = smcr_version;
|
||||
smc_find_ism_store_rc(rc, ini);
|
||||
if (rc) {
|
||||
ini->smcr_version = smcr_version;
|
||||
goto not_found;
|
||||
}
|
||||
rc = smc_listen_rdma_reg(new_smc, ini->first_contact_local);
|
||||
if (rc) {
|
||||
ini->smcr_version = smcr_version;
|
||||
goto not_found;
|
||||
}
|
||||
return 0;
|
||||
|
||||
not_found:
|
||||
rc = rc ?: SMC_CLC_DECL_NOSMCDEV;
|
||||
ini->smcr_version &= ~SMC_V2;
|
||||
ini->check_smcrv2 = false;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int smc_find_rdma_v1_device_serv(struct smc_sock *new_smc,
|
||||
|
@ -2006,6 +2011,7 @@ static int smc_listen_find_device(struct smc_sock *new_smc,
|
|||
struct smc_init_info *ini)
|
||||
{
|
||||
int prfx_rc;
|
||||
int rc;
|
||||
|
||||
/* check for ISM device matching V2 proposed device */
|
||||
smc_find_ism_v2_device_serv(new_smc, pclc, ini);
|
||||
|
@ -2033,14 +2039,18 @@ static int smc_listen_find_device(struct smc_sock *new_smc,
|
|||
return ini->rc ?: SMC_CLC_DECL_NOSMCDDEV;
|
||||
|
||||
/* check if RDMA V2 is available */
|
||||
smc_find_rdma_v2_device_serv(new_smc, pclc, ini);
|
||||
if (ini->smcrv2.ib_dev_v2)
|
||||
rc = smc_find_rdma_v2_device_serv(new_smc, pclc, ini);
|
||||
if (!rc)
|
||||
return 0;
|
||||
|
||||
/* skip V1 check if V2 is unavailable for non-Device reason */
|
||||
if (rc != SMC_CLC_DECL_NOSMCDEV &&
|
||||
rc != SMC_CLC_DECL_NOSMCRDEV &&
|
||||
rc != SMC_CLC_DECL_NOSMCDDEV)
|
||||
return rc;
|
||||
|
||||
/* check if RDMA V1 is available */
|
||||
if (!prfx_rc) {
|
||||
int rc;
|
||||
|
||||
rc = smc_find_rdma_v1_device_serv(new_smc, pclc, ini);
|
||||
smc_find_ism_store_rc(rc, ini);
|
||||
return (!rc) ? 0 : ini->rc;
|
||||
|
|
Loading…
Reference in a new issue