From: Nguyen Van Tien <nguyenvantiennani@gmail.com>
To: linux-rdma@vger.kernel.org
Cc: dennis.dalessandro@cornelisnetworks.com, jgg@nvidia.com,
leonro@nvidia.com, Nguyen Van Tien <nguyenvantiennani@gmail.com>
Subject: [PATCH] RDMA/rdmavt: Fix potential use-after-free in rvt_mmap()
Date: Tue, 25 Aug 2026 11:20:58 +0700 [thread overview]
Message-ID: <20260825042058.561-1-nguyenvantiennani@gmail.com> (raw)
rvt_mmap() drops the pending lock and only takes the VMA reference in
rvt_vma_open() after remap_vmalloc_range() returns. A concurrent owner
teardown can free ip->obj and ip between list_del_init() and the later
kref_get(), leaving rvt_mmap() operating on freed memory.
Apply the same fix pattern as the RXE provider (CVE-2026-64582): take
the reference with kref_get_unless_zero() while pending_lock is held,
release the lock only after the reference is secured, and on remap
failure clear the VMA state and put the reference.
Signed-off-by: Nguyen Van Tien <nguyenvantiennani@gmail.com>
---
drivers/infiniband/sw/rdmavt/mmap.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/sw/rdmavt/mmap.c b/drivers/infiniband/sw/rdmavt/mmap.c
index 473f464f3..318e8877b 100644
--- a/drivers/infiniband/sw/rdmavt/mmap.c
+++ b/drivers/infiniband/sw/rdmavt/mmap.c
@@ -100,15 +100,30 @@ int rvt_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
if (size > ip->size)
break;
+ /*
+ * Increment refcount and check whether it is being freed atm
+ * while holding the lock to prevent UAF, matching the RXE
+ * provider fix.
+ */
+ if (!kref_get_unless_zero(&ip->ref)) {
+ spin_unlock_irq(&rdi->pending_lock);
+ ret = -ENXIO;
+ goto done;
+ }
+
list_del_init(&ip->pending_mmaps);
spin_unlock_irq(&rdi->pending_lock);
- ret = remap_vmalloc_range(vma, ip->obj, 0);
- if (ret)
- goto done;
vma->vm_ops = &rvt_vm_ops;
vma->vm_private_data = ip;
- rvt_vma_open(vma);
+
+ ret = remap_vmalloc_range(vma, ip->obj, 0);
+ if (ret) {
+ vma->vm_private_data = NULL;
+ vma->vm_ops = NULL;
+ kref_put(&ip->ref, rvt_release_mmap_info);
+ goto done;
+ }
goto done;
}
spin_unlock_irq(&rdi->pending_lock);
--
2.53.0
next reply other threads:[~2026-08-25 4:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 4:20 Nguyen Van Tien [this message]
2026-08-25 13:28 ` [PATCH] RDMA/rdmavt: Fix potential use-after-free in rvt_mmap() Dennis Dalessandro
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=20260825042058.561-1-nguyenvantiennani@gmail.com \
--to=nguyenvantiennani@gmail.com \
--cc=dennis.dalessandro@cornelisnetworks.com \
--cc=jgg@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
/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