From: "shaikh.kamal" <shaikhkamal2012@gmail.com>
To: "shaikh.kamal" <shaikhkamal2012@gmail.com>,
Roland Dreier <rolandd@cisco.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: skhan@linuxfoundation.org, me@brighamcampbell.com,
syzbot+a6ffe86390c8a6afc818@syzkaller.appspotmail.com
Subject: [PATCH] RDMA/ucma: Fix use-after-free in ucma_create_uevent
Date: Sun, 3 May 2026 16:21:25 +0530 [thread overview]
Message-ID: <20260503105125.16368-1-shaikhkamal2012@gmail.com> (raw)
ucma_create_uevent() dereferences event->param.ud.private_data
as a struct ucma_multicast for multicast events. However,
this pointer may refer to memory that has already been freed,
leading to a use-after-free.
Fix this by avoiding dereferencing private_data for multicast
events and instead using ctx for uid and id, which has a
well-defined lifetime.
Tested by running the reproducer under KASAN with slub_debug
enabled for several hours with no crashes observed.
Reported-by: syzbot+a6ffe86390c8a6afc818@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a6ffe86390c8a6afc818
Fixes: c8f6a362bf3e ("RDMA/cma: Add multicast communication support")
Signed-off-by: shaikh.kamal <shaikhkamal2012@gmail.com>
---
drivers/infiniband/core/ucma.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 6e700b974033..8eef10352af7 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -270,10 +270,12 @@ static struct ucma_event *ucma_create_uevent(struct ucma_context *ctx,
switch (event->event) {
case RDMA_CM_EVENT_MULTICAST_JOIN:
case RDMA_CM_EVENT_MULTICAST_ERROR:
- uevent->mc = (struct ucma_multicast *)
- event->param.ud.private_data;
- uevent->resp.uid = uevent->mc->uid;
- uevent->resp.id = uevent->mc->id;
+ /*
+ * event->param.ud.private_data may point to a ucma_multicast
+ * that has already been freed, so use ctx instead.
+ */
+ uevent->resp.uid = ctx->uid;
+ uevent->resp.id = ctx->id;
break;
default:
uevent->resp.uid = ctx->uid;
--
2.43.0
reply other threads:[~2026-05-03 10:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260503105125.16368-1-shaikhkamal2012@gmail.com \
--to=shaikhkamal2012@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=me@brighamcampbell.com \
--cc=rolandd@cisco.com \
--cc=skhan@linuxfoundation.org \
--cc=syzbot+a6ffe86390c8a6afc818@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox