Skip to content

Commit 57f3cb6

Browse files
committed
RDMA/cm: Fix leaking the multicast GID table reference
If the CM ID is destroyed while the CM event for multicast creating is still queued the cancel_work_sync() will prevent the work from running which also prevents destroying the ah_attr. This leaks a refcount and triggers a WARN: GID entry ref leak for dev syz1 index 2 ref=573 WARNING: CPU: 1 PID: 655 at drivers/infiniband/core/cache.c:809 release_gid_table drivers/infiniband/core/cache.c:806 [inline] WARNING: CPU: 1 PID: 655 at drivers/infiniband/core/cache.c:809 gid_table_release_one+0x284/0x3cc drivers/infiniband/core/cache.c:886 Destroy the ah_attr after canceling the work, it is safe to call this twice. Link: https://patch.msgid.link/r/0-v1-4285d070a6b2+20a-rdma_mc_gid_leak_syz_jgg@nvidia.com Cc: stable@vger.kernel.org Fixes: fe454dc ("RDMA/ucma: Fix use-after-free bug in ucma_create_uevent") Reported-by: syzbot+b0da83a6c0e2e2bddbd4@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/68232e7b.050a0220.f2294.09f6.GAE@google.com Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent a7b8e87 commit 57f3cb6

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • drivers/infiniband/core

drivers/infiniband/core/cma.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,7 @@ static void destroy_mc(struct rdma_id_private *id_priv,
20092009
ib_sa_free_multicast(mc->sa_mc);
20102010

20112011
if (rdma_protocol_roce(id_priv->id.device, id_priv->id.port_num)) {
2012+
struct rdma_cm_event *event = &mc->iboe_join.event;
20122013
struct rdma_dev_addr *dev_addr =
20132014
&id_priv->id.route.addr.dev_addr;
20142015
struct net_device *ndev = NULL;
@@ -2031,6 +2032,8 @@ static void destroy_mc(struct rdma_id_private *id_priv,
20312032
dev_put(ndev);
20322033

20332034
cancel_work_sync(&mc->iboe_join.work);
2035+
if (event->event == RDMA_CM_EVENT_MULTICAST_JOIN)
2036+
rdma_destroy_ah_attr(&event->param.ud.ah_attr);
20342037
}
20352038
kfree(mc);
20362039
}

0 commit comments

Comments
 (0)