From: Yuansheng Yang <0xbeac@gmail.com>
To: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
Cc: linux-rdma@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH] RDMA/irdma: clear push_wqe_mmap_entry on error in irdma_setup_push_mmap_entries()
Date: Sat, 5 Dec 2026 22:52:47 +0800 [thread overview]
Message-ID: <20261205145247.1712139-1-0xbeac@gmail.com> (raw)
In irdma_setup_push_mmap_entries(), iwqp->push_wqe_mmap_entry is stored
upon the first irdma_user_mmap_entry_insert(). If the second
irdma_user_mmap_entry_insert() for iwqp->push_db_mmap_entry fails,
irdma_setup_push_mmap_entries() calls
rdma_user_mmap_entry_remove(iwqp->push_wqe_mmap_entry) -- dropping the
sole kref and freeing the entry -- and returns -ENOMEM without resetting
iwqp->push_wqe_mmap_entry to NULL.
Crucially, both irdma_modify_qp_roce() and irdma_modify_qp() ignore the
error returned by irdma_setup_push_mmap_entries(). Consequently, either
an immediate ib_respond_udata() failure or a later _irdma_destroy_qp()
after an otherwise successful modify_qp calls
irdma_remove_push_mmap_entries(iwqp) and passes the freed entry to
rdma_user_mmap_entry_remove() a second time, triggering a use-after-free:
BUG: KASAN: slab-use-after-free in rdma_user_mmap_entry_remove
Call Trace:
rdma_user_mmap_entry_remove
_irdma_destroy_qp
irdma_destroy_qp
Clear iwqp->push_wqe_mmap_entry to NULL after removing it in
irdma_setup_push_mmap_entries() so subsequent cleanup via
irdma_remove_push_mmap_entries() does not touch the freed entry.
Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
Cc: stable@vger.kernel.org
Signed-off-by: Yuansheng Yang <0xbeac@gmail.com>
---
Compiled drivers/infiniband/hw/irdma/verbs.o with W=1 on x86_64
(0 warnings, 0 errors) and verified on v7.4-rc5 in an x86_64 KASAN QEMU
guest via irdma_modify_qp_roce() failing push_db_mmap_entry insertion
followed by irdma_destroy_qp(): before this fix, KASAN reports a
slab-use-after-free in rdma_user_mmap_entry_remove(); after this fix,
10/10 iterations complete with iwqp->push_wqe_mmap_entry == NULL and 0
KASAN, BUG, or WARNING diagnostics.
drivers/infiniband/hw/irdma/verbs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index 9cc1b65ee..a8ced7bd0 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -554,6 +554,7 @@ static int irdma_setup_push_mmap_entries(struct irdma_ucontext *ucontext,
push_db_mmap_key);
if (!iwqp->push_db_mmap_entry) {
rdma_user_mmap_entry_remove(iwqp->push_wqe_mmap_entry);
+ iwqp->push_wqe_mmap_entry = NULL;
return -ENOMEM;
}
--
2.53.0
next reply other threads:[~2026-12-05 14:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 14:52 Yuansheng Yang [this message]
2026-12-05 15:09 ` [PATCH] RDMA/irdma: clear push_wqe_mmap_entry on error in irdma_setup_push_mmap_entries() sashiko-bot
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=20261205145247.1712139-1-0xbeac@gmail.com \
--to=0xbeac@gmail.com \
--cc=linux-rdma@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tatyana.e.nikolova@intel.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