mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 04:46:30 -04:00
RDMA/mana_ib: drain QP references after partial table insertion
mana_table_store_ud_qp() publishes a QP at its send-queue id before
inserting the receive-queue id, dropping the XArray lock between the two
xa_insert_irq() calls. A concurrent completion handler can look up the QP
and take a transient reference. When the second insertion fails, the
rollback erased only the send-queue entry and returned, leaving both the
initial table reference and the transient reference outstanding while RDMA
core frees the QP, causing a use-after-free.
Drain the reference as normal destruction does: drop the initial reference
and wait for qp->free, releasing the QP only after every concurrent lookup
returns its reference.
Fixes: 8001e9257e ("RDMA/mana_ib: extend mana QP table")
Link: https://patch.msgid.link/20260721-if-mana-table-store-qp-qids-partiall-v1-1-8fb3d2d2b559@nvidia.com
Reviewed-by: Konstantin Taranov <kotaranov@microsoft.com>
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
This commit is contained in:
committed by
Leon Romanovsky
parent
63d6c2d10c
commit
97f7c2262c
@@ -472,6 +472,12 @@ static void mana_table_remove_rc_qp(struct mana_ib_dev *mdev, struct mana_ib_qp
|
||||
xa_erase_irq(&mdev->qp_table_wq, qp->ibqp.qp_num);
|
||||
}
|
||||
|
||||
static void mana_table_drain_qp_ref(struct mana_ib_qp *qp)
|
||||
{
|
||||
mana_put_qp_ref(qp);
|
||||
wait_for_completion(&qp->free);
|
||||
}
|
||||
|
||||
static int mana_table_store_ud_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *qp)
|
||||
{
|
||||
u32 qids = qp->ud_qp.queues[MANA_UD_SEND_QUEUE].id | MANA_SENDQ_MASK;
|
||||
@@ -490,6 +496,7 @@ static int mana_table_store_ud_qp(struct mana_ib_dev *mdev, struct mana_ib_qp *q
|
||||
|
||||
remove_sq:
|
||||
xa_erase_irq(&mdev->qp_table_wq, qids);
|
||||
mana_table_drain_qp_ref(qp);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -537,8 +544,7 @@ static void mana_table_remove_qp(struct mana_ib_dev *mdev,
|
||||
qp->ibqp.qp_type);
|
||||
return;
|
||||
}
|
||||
mana_put_qp_ref(qp);
|
||||
wait_for_completion(&qp->free);
|
||||
mana_table_drain_qp_ref(qp);
|
||||
}
|
||||
|
||||
static int mana_ib_create_rc_qp(struct ib_qp *ibqp, struct ib_pd *ibpd,
|
||||
|
||||
Reference in New Issue
Block a user