* [PATCH] RDMA/siw: Fix use-after-free in siw_accept()
@ 2026-08-01 21:36 Shuangpeng Bai
2026-08-06 10:50 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Shuangpeng Bai @ 2026-08-01 21:36 UTC (permalink / raw)
To: bernard.metzler, jgg, leon
Cc: linux-rdma, linux-kernel, Shuangpeng Bai, stable
siw_accept() looks up the QP supplied by userspace. If that QP is
already in RTS, the function jumps to error cleanup before associating
the incoming CEP with it.
The cleanup tests whether qp->cep is non-NULL and assumes the current
call installed the association. However, qp->cep can point to the CEP
of an existing connection. The cleanup then drops a reference from the
incoming cep, not qp->cep. Once the incoming endpoint loses its
remaining references, this can free it before the subsequent cep->qp
store, causing a use-after-free. It also clears the existing QP
association.
Only release the association reference when qp->cep is the incoming
CEP. This preserves an existing association and avoids accessing the
freed endpoint.
Fixes: 6c52fdc244b5 ("rdma/siw: connection management")
Cc: stable@vger.kernel.org
Signed-off-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
---
drivers/infiniband/sw/siw/siw_cm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c
index 87c79527ac09..0245b25e7271 100644
--- a/drivers/infiniband/sw/siw/siw_cm.c
+++ b/drivers/infiniband/sw/siw/siw_cm.c
@@ -1751,7 +1751,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)
cep->state = SIW_EPSTATE_CLOSED;
siw_free_cm_id(cep);
- if (qp->cep) {
+ if (qp->cep == cep) {
siw_cep_put(cep);
qp->cep = NULL;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] RDMA/siw: Fix use-after-free in siw_accept()
2026-08-01 21:36 [PATCH] RDMA/siw: Fix use-after-free in siw_accept() Shuangpeng Bai
@ 2026-08-06 10:50 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-08-06 10:50 UTC (permalink / raw)
To: bernard.metzler, jgg, Shuangpeng Bai; +Cc: linux-rdma, linux-kernel, stable
On Sat, 01 Aug 2026 17:36:32 -0400, Shuangpeng Bai wrote:
> siw_accept() looks up the QP supplied by userspace. If that QP is
> already in RTS, the function jumps to error cleanup before associating
> the incoming CEP with it.
>
> The cleanup tests whether qp->cep is non-NULL and assumes the current
> call installed the association. However, qp->cep can point to the CEP
> of an existing connection. The cleanup then drops a reference from the
> incoming cep, not qp->cep. Once the incoming endpoint loses its
> remaining references, this can free it before the subsequent cep->qp
> store, causing a use-after-free. It also clears the existing QP
> association.
>
> [...]
Applied, thanks!
[1/1] RDMA/siw: Fix use-after-free in siw_accept()
https://git.kernel.org/rdma/rdma/c/a9394971825933
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-06 10:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-01 21:36 [PATCH] RDMA/siw: Fix use-after-free in siw_accept() Shuangpeng Bai
2026-08-06 10:50 ` Leon Romanovsky
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.