aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/sw/siw/siw_verbs.c
diff options
context:
space:
mode:
authorBernard Metzler <bmt@zurich.ibm.com>2022-09-20 10:25:03 +0200
committerLeon Romanovsky <leon@kernel.org>2022-09-20 21:23:52 +0300
commita3c278807a459e6f50afee6971cabe74cccfb490 (patch)
treee00a8456e4073ddf394684609a74a827b72bd719 /drivers/infiniband/sw/siw/siw_verbs.c
parentRDMA/siw: Always consume all skbuf data in sk_data_ready() upcall. (diff)
downloadlinux-dev-a3c278807a459e6f50afee6971cabe74cccfb490.tar.xz
linux-dev-a3c278807a459e6f50afee6971cabe74cccfb490.zip
RDMA/siw: Fix QP destroy to wait for all references dropped.
Delay QP destroy completion until all siw references to QP are dropped. The calling RDMA core will free QP structure after successful return from siw_qp_destroy() call, so siw must not hold any remaining reference to the QP upon return. A use-after-free was encountered in xfstest generic/460, while testing NFSoRDMA. Here, after a TCP connection drop by peer, the triggered siw_cm_work_handler got delayed until after QP destroy call, referencing a QP which has already freed. Fixes: 303ae1cdfdf7 ("rdma/siw: application interface") Reported-by: Olga Kornievskaia <kolga@netapp.com> Signed-off-by: Bernard Metzler <bmt@zurich.ibm.com> Link: https://lore.kernel.org/r/20220920082503.224189-1-bmt@zurich.ibm.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'drivers/infiniband/sw/siw/siw_verbs.c')
-rw-r--r--drivers/infiniband/sw/siw/siw_verbs.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
index 8dedae7ae79e..3e814cfb298c 100644
--- a/drivers/infiniband/sw/siw/siw_verbs.c
+++ b/drivers/infiniband/sw/siw/siw_verbs.c
@@ -480,6 +480,8 @@ int siw_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs,
list_add_tail(&qp->devq, &sdev->qp_list);
spin_unlock_irqrestore(&sdev->lock, flags);
+ init_completion(&qp->qp_free);
+
return 0;
err_out_xa:
@@ -624,6 +626,7 @@ int siw_destroy_qp(struct ib_qp *base_qp, struct ib_udata *udata)
qp->scq = qp->rcq = NULL;
siw_qp_put(qp);
+ wait_for_completion(&qp->qp_free);
return 0;
}