Commit d9e410eb authored by Maor Gottlieb's avatar Maor Gottlieb Committed by Jason Gunthorpe

RDMA/cma: Use correct address when leaving multicast group

In RoCE we should use cma_iboe_set_mgid() and not cma_set_mgid to generate
the mgid, otherwise we will generate an IGMP for an incorrect address.

Fixes: b5de0c60 ("RDMA/cma: Fix use after free race in roce multicast join")
Link: https://lore.kernel.org/r/913bc6783fd7a95fe71ad9454e01653ee6fb4a9a.1642491047.git.leonro@nvidia.comSigned-off-by: default avatarMaor Gottlieb <maorg@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent e5cce44a
...@@ -67,8 +67,8 @@ static const char * const cma_events[] = { ...@@ -67,8 +67,8 @@ static const char * const cma_events[] = {
[RDMA_CM_EVENT_TIMEWAIT_EXIT] = "timewait exit", [RDMA_CM_EVENT_TIMEWAIT_EXIT] = "timewait exit",
}; };
static void cma_set_mgid(struct rdma_id_private *id_priv, struct sockaddr *addr, static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid,
union ib_gid *mgid); enum ib_gid_type gid_type);
const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event) const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event)
{ {
...@@ -1846,17 +1846,19 @@ static void destroy_mc(struct rdma_id_private *id_priv, ...@@ -1846,17 +1846,19 @@ static void destroy_mc(struct rdma_id_private *id_priv,
if (dev_addr->bound_dev_if) if (dev_addr->bound_dev_if)
ndev = dev_get_by_index(dev_addr->net, ndev = dev_get_by_index(dev_addr->net,
dev_addr->bound_dev_if); dev_addr->bound_dev_if);
if (ndev) { if (ndev && !send_only) {
enum ib_gid_type gid_type;
union ib_gid mgid; union ib_gid mgid;
cma_set_mgid(id_priv, (struct sockaddr *)&mc->addr, gid_type = id_priv->cma_dev->default_gid_type
&mgid); [id_priv->id.port_num -
rdma_start_port(
if (!send_only) id_priv->cma_dev->device)];
cma_igmp_send(ndev, &mgid, false); cma_iboe_set_mgid((struct sockaddr *)&mc->addr, &mgid,
gid_type);
dev_put(ndev); cma_igmp_send(ndev, &mgid, false);
} }
dev_put(ndev);
cancel_work_sync(&mc->iboe_join.work); cancel_work_sync(&mc->iboe_join.work);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment