* [PATCH] RDMA/irdma: clear push_wqe_mmap_entry on error in irdma_setup_push_mmap_entries()
@ 2026-12-05 14:52 Yuansheng Yang
2026-12-05 15:09 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Yuansheng Yang @ 2026-12-05 14:52 UTC (permalink / raw)
To: Tatyana Nikolova; +Cc: linux-rdma, stable
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] RDMA/irdma: clear push_wqe_mmap_entry on error in irdma_setup_push_mmap_entries()
2026-12-05 14:52 [PATCH] RDMA/irdma: clear push_wqe_mmap_entry on error in irdma_setup_push_mmap_entries() Yuansheng Yang
@ 2026-12-05 15:09 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-05 15:09 UTC (permalink / raw)
To: Yuansheng Yang; +Cc: linux-rdma
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205145247.1712139-1-0xbeac@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-05 15:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 14:52 [PATCH] RDMA/irdma: clear push_wqe_mmap_entry on error in irdma_setup_push_mmap_entries() Yuansheng Yang
2026-12-05 15:09 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox