Skip to content

Commit d9e410e

Browse files
maorgottliebjgunthorpe
authored andcommitted
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: b5de0c6 ("RDMA/cma: Fix use after free race in roce multicast join") Link: https://lore.kernel.org/r/913bc6783fd7a95fe71ad9454e01653ee6fb4a9a.1642491047.git.leonro@nvidia.com Signed-off-by: Maor Gottlieb <maorg@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent e5cce44 commit d9e410e

File tree

1 file changed

+12
-10
lines changed
  • drivers/infiniband/core

1 file changed

+12
-10
lines changed

drivers/infiniband/core/cma.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ static const char * const cma_events[] = {
6767
[RDMA_CM_EVENT_TIMEWAIT_EXIT] = "timewait exit",
6868
};
6969

70-
static void cma_set_mgid(struct rdma_id_private *id_priv, struct sockaddr *addr,
71-
union ib_gid *mgid);
70+
static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid,
71+
enum ib_gid_type gid_type);
7272

7373
const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event)
7474
{
@@ -1846,17 +1846,19 @@ static void destroy_mc(struct rdma_id_private *id_priv,
18461846
if (dev_addr->bound_dev_if)
18471847
ndev = dev_get_by_index(dev_addr->net,
18481848
dev_addr->bound_dev_if);
1849-
if (ndev) {
1849+
if (ndev && !send_only) {
1850+
enum ib_gid_type gid_type;
18501851
union ib_gid mgid;
18511852

1852-
cma_set_mgid(id_priv, (struct sockaddr *)&mc->addr,
1853-
&mgid);
1854-
1855-
if (!send_only)
1856-
cma_igmp_send(ndev, &mgid, false);
1857-
1858-
dev_put(ndev);
1853+
gid_type = id_priv->cma_dev->default_gid_type
1854+
[id_priv->id.port_num -
1855+
rdma_start_port(
1856+
id_priv->cma_dev->device)];
1857+
cma_iboe_set_mgid((struct sockaddr *)&mc->addr, &mgid,
1858+
gid_type);
1859+
cma_igmp_send(ndev, &mgid, false);
18591860
}
1861+
dev_put(ndev);
18601862

18611863
cancel_work_sync(&mc->iboe_join.work);
18621864
}

0 commit comments

Comments
 (0)