* [PATCH rdma-next] RDMA/qedr: Fix null-pointer dereference when calling rdma_user_mmap_get_offset
@ 2019-11-18 15:06 Michal Kalderon
2019-11-19 20:18 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Michal Kalderon @ 2019-11-18 15:06 UTC (permalink / raw)
To: dledford, jgg, ariel.elior, michal.kalderon; +Cc: linux-rdma
When running against rdma-core that doesn't support doorbell
recovery, the rdma_user_mmap_entry won't be allocated for
doorbell recovery related mappings.
We have a flag indicating whether rdma-core supports doorbell
recovery or not which was used during initialization, however
some cases didn't check that the rdma_user_mmap_entry exists
before attempting to acquire it's offset.
Fixes: 97f612509294 ("RDMA/qedr: Add doorbell overflow recovery support")
Signed-off-by: Ariel Elior <ariel.elior@marvell.com>
Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com>
---
drivers/infiniband/hw/qedr/verbs.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index 9c0887c61f72..3f3f0ef2f901 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -697,7 +697,9 @@ static int qedr_copy_cq_uresp(struct qedr_dev *dev,
uresp.db_offset = db_offset;
uresp.icid = cq->icid;
- uresp.db_rec_addr = rdma_user_mmap_get_offset(cq->q.db_mmap_entry);
+ if (cq->q.db_mmap_entry)
+ uresp.db_rec_addr =
+ rdma_user_mmap_get_offset(cq->q.db_mmap_entry);
rc = qedr_ib_copy_to_udata(udata, &uresp, sizeof(uresp));
if (rc)
@@ -1026,7 +1028,7 @@ int qedr_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
if (udata) {
qedr_free_pbl(dev, &cq->q.pbl_info, cq->q.pbl_tbl);
ib_umem_release(cq->q.umem);
- if (ctx)
+ if (cq->q.db_mmap_entry)
rdma_user_mmap_entry_remove(cq->q.db_mmap_entry);
} else {
dev->ops->common->chain_free(dev->cdev, &cq->pbl);
@@ -1259,7 +1261,9 @@ static void qedr_copy_rq_uresp(struct qedr_dev *dev,
}
uresp->rq_icid = qp->icid;
- uresp->rq_db_rec_addr = rdma_user_mmap_get_offset(qp->urq.db_mmap_entry);
+ if (qp->urq.db_mmap_entry)
+ uresp->rq_db_rec_addr =
+ rdma_user_mmap_get_offset(qp->urq.db_mmap_entry);
}
static void qedr_copy_sq_uresp(struct qedr_dev *dev,
@@ -1274,8 +1278,9 @@ static void qedr_copy_sq_uresp(struct qedr_dev *dev,
else
uresp->sq_icid = qp->icid + 1;
- uresp->sq_db_rec_addr =
- rdma_user_mmap_get_offset(qp->usq.db_mmap_entry);
+ if (qp->usq.db_mmap_entry)
+ uresp->sq_db_rec_addr =
+ rdma_user_mmap_get_offset(qp->usq.db_mmap_entry);
}
static int qedr_copy_qp_uresp(struct qedr_dev *dev,
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH rdma-next] RDMA/qedr: Fix null-pointer dereference when calling rdma_user_mmap_get_offset
2019-11-18 15:06 [PATCH rdma-next] RDMA/qedr: Fix null-pointer dereference when calling rdma_user_mmap_get_offset Michal Kalderon
@ 2019-11-19 20:18 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2019-11-19 20:18 UTC (permalink / raw)
To: Michal Kalderon; +Cc: dledford, ariel.elior, linux-rdma
On Mon, Nov 18, 2019 at 05:06:45PM +0200, Michal Kalderon wrote:
> When running against rdma-core that doesn't support doorbell
> recovery, the rdma_user_mmap_entry won't be allocated for
> doorbell recovery related mappings.
> We have a flag indicating whether rdma-core supports doorbell
> recovery or not which was used during initialization, however
> some cases didn't check that the rdma_user_mmap_entry exists
> before attempting to acquire it's offset.
>
> Fixes: 97f612509294 ("RDMA/qedr: Add doorbell overflow recovery support")
> Signed-off-by: Ariel Elior <ariel.elior@marvell.com>
> Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com>
> ---
> drivers/infiniband/hw/qedr/verbs.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-19 20:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 15:06 [PATCH rdma-next] RDMA/qedr: Fix null-pointer dereference when calling rdma_user_mmap_get_offset Michal Kalderon
2019-11-19 20:18 ` Jason Gunthorpe
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.