* [PATCH] RDMA/cm: Fix leaking the multicast GID table reference
@ 2025-11-29 0:53 Jason Gunthorpe
2025-11-30 0:49 ` Jason Gunthorpe
2025-12-17 1:44 ` Jason Gunthorpe
0 siblings, 2 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2025-11-29 0:53 UTC (permalink / raw)
To: Leon Romanovsky, linux-rdma
Cc: Avihai Horon, Eli Cohen, Leon Romanovsky, Amit Matityahu, patches,
Roland Dreier, stable, syzbot+b0da83a6c0e2e2bddbd4
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.
Cc: stable@vger.kernel.org
Fixes: fe454dc31e84 ("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>
---
drivers/infiniband/core/cma.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 95e89f5c147c2c..4f5fd47086ab90 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -2031,6 +2031,8 @@ static void destroy_mc(struct rdma_id_private *id_priv,
dev_put(ndev);
cancel_work_sync(&mc->iboe_join.work);
+ if (event->event == RDMA_CM_EVENT_MULTICAST_JOIN)
+ rdma_destroy_ah_attr(&event->param.ud.ah_attr);
}
kfree(mc);
}
base-commit: 3fbaef0942719187f3396bfd0c780d55d35e0980
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] RDMA/cm: Fix leaking the multicast GID table reference
2025-11-29 0:53 [PATCH] RDMA/cm: Fix leaking the multicast GID table reference Jason Gunthorpe
@ 2025-11-30 0:49 ` Jason Gunthorpe
2025-12-17 1:44 ` Jason Gunthorpe
1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2025-11-30 0:49 UTC (permalink / raw)
To: Leon Romanovsky, linux-rdma
Cc: Avihai Horon, Eli Cohen, Leon Romanovsky, Amit Matityahu, patches,
Roland Dreier, stable, syzbot+b0da83a6c0e2e2bddbd4
On Fri, Nov 28, 2025 at 08:53:21PM -0400, Jason Gunthorpe wrote:
> 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.
>
> Cc: stable@vger.kernel.org
> Fixes: fe454dc31e84 ("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>
> ---
> drivers/infiniband/core/cma.c | 2 ++
> 1 file changed, 2 insertions(+)
Bah, a hunk got lost, it should be like this:
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 95e89f5c147c2c..f00f1d3fbd9c53 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -2009,6 +2009,7 @@ static void destroy_mc(struct rdma_id_private *id_priv,
ib_sa_free_multicast(mc->sa_mc);
if (rdma_protocol_roce(id_priv->id.device, id_priv->id.port_num)) {
+ struct rdma_cm_event *event = &mc->iboe_join.event;
struct rdma_dev_addr *dev_addr =
&id_priv->id.route.addr.dev_addr;
struct net_device *ndev = NULL;
@@ -2031,6 +2032,8 @@ static void destroy_mc(struct rdma_id_private *id_priv,
dev_put(ndev);
cancel_work_sync(&mc->iboe_join.work);
+ if (event->event == RDMA_CM_EVENT_MULTICAST_JOIN)
+ rdma_destroy_ah_attr(&event->param.ud.ah_attr);
}
kfree(mc);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] RDMA/cm: Fix leaking the multicast GID table reference
2025-11-29 0:53 [PATCH] RDMA/cm: Fix leaking the multicast GID table reference Jason Gunthorpe
2025-11-30 0:49 ` Jason Gunthorpe
@ 2025-12-17 1:44 ` Jason Gunthorpe
1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2025-12-17 1:44 UTC (permalink / raw)
To: Leon Romanovsky, linux-rdma
Cc: Avihai Horon, Eli Cohen, Leon Romanovsky, Amit Matityahu, patches,
Roland Dreier, stable, syzbot+b0da83a6c0e2e2bddbd4
On Fri, Nov 28, 2025 at 08:53:21PM -0400, Jason Gunthorpe wrote:
> 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.
>
> Cc: stable@vger.kernel.org
> Fixes: fe454dc31e84 ("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>
> ---
> drivers/infiniband/core/cma.c | 2 ++
> 1 file changed, 2 insertions(+)
Applied to for-rc with the missing hunk
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-17 1:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-29 0:53 [PATCH] RDMA/cm: Fix leaking the multicast GID table reference Jason Gunthorpe
2025-11-30 0:49 ` Jason Gunthorpe
2025-12-17 1:44 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).