Skip to content

Commit 3719790

Browse files
maorgottliebgregkh
authored andcommitted
RDMA/cma: Use correct address when leaving multicast group
commit d9e410e upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aa4ecd9 commit 3719790

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

  • drivers/infiniband/core

‎drivers/infiniband/core/cma.c‎

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

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

7474
const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event)
7575
{
@@ -1840,17 +1840,19 @@ static void destroy_mc(struct rdma_id_private *id_priv,
18401840
if (dev_addr->bound_dev_if)
18411841
ndev = dev_get_by_index(dev_addr->net,
18421842
dev_addr->bound_dev_if);
1843-
if (ndev) {
1843+
if (ndev && !send_only) {
1844+
enum ib_gid_type gid_type;
18441845
union ib_gid mgid;
18451846

1846-
cma_set_mgid(id_priv, (struct sockaddr *)&mc->addr,
1847-
&mgid);
1848-
1849-
if (!send_only)
1850-
cma_igmp_send(ndev, &mgid, false);
1851-
1852-
dev_put(ndev);
1847+
gid_type = id_priv->cma_dev->default_gid_type
1848+
[id_priv->id.port_num -
1849+
rdma_start_port(
1850+
id_priv->cma_dev->device)];
1851+
cma_iboe_set_mgid((struct sockaddr *)&mc->addr, &mgid,
1852+
gid_type);
1853+
cma_igmp_send(ndev, &mgid, false);
18531854
}
1855+
dev_put(ndev);
18541856

18551857
cancel_work_sync(&mc->iboe_join.work);
18561858
}

0 commit comments

Comments
 (0)