Skip to content

Commit 5019b23

Browse files
Adit Ranadivegregkh
authored andcommitted
RDMA/vmw_pvrdma: Fix usage of user response structures in ABI file
commit 1f5a6c4 upstream. This ensures that we return the right structures back to userspace. Otherwise, it looks like the reserved fields in the response structures in userspace might have uninitialized data in them. Fixes: 8b10ba7 ("RDMA/vmw_pvrdma: Add shared receive queue support") Fixes: 29c8d9e ("IB: Add vmw_pvrdma driver") Suggested-by: Jason Gunthorpe <jgg@mellanox.com> Reviewed-by: Bryan Tan <bryantan@vmware.com> Reviewed-by: Aditya Sarwade <asarwade@vmware.com> Reviewed-by: Jorgen Hansen <jhansen@vmware.com> Signed-off-by: Adit Ranadive <aditr@vmware.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 957435b commit 5019b23

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev,
114114
union pvrdma_cmd_resp rsp;
115115
struct pvrdma_cmd_create_cq *cmd = &req.create_cq;
116116
struct pvrdma_cmd_create_cq_resp *resp = &rsp.create_cq_resp;
117+
struct pvrdma_create_cq_resp cq_resp = {0};
117118
struct pvrdma_create_cq ucmd;
118119

119120
BUILD_BUG_ON(sizeof(struct pvrdma_cqe) != 64);
@@ -198,6 +199,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev,
198199

199200
cq->ibcq.cqe = resp->cqe;
200201
cq->cq_handle = resp->cq_handle;
202+
cq_resp.cqn = resp->cq_handle;
201203
spin_lock_irqsave(&dev->cq_tbl_lock, flags);
202204
dev->cq_tbl[cq->cq_handle % dev->dsr->caps.max_cq] = cq;
203205
spin_unlock_irqrestore(&dev->cq_tbl_lock, flags);
@@ -206,7 +208,7 @@ struct ib_cq *pvrdma_create_cq(struct ib_device *ibdev,
206208
cq->uar = &(to_vucontext(context)->uar);
207209

208210
/* Copy udata back. */
209-
if (ib_copy_to_udata(udata, &cq->cq_handle, sizeof(__u32))) {
211+
if (ib_copy_to_udata(udata, &cq_resp, sizeof(cq_resp))) {
210212
dev_warn(&dev->pdev->dev,
211213
"failed to copy back udata\n");
212214
pvrdma_destroy_cq(&cq->ibcq);

‎drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ struct ib_pd *pvrdma_alloc_pd(struct ib_device *ibdev,
444444
union pvrdma_cmd_resp rsp;
445445
struct pvrdma_cmd_create_pd *cmd = &req.create_pd;
446446
struct pvrdma_cmd_create_pd_resp *resp = &rsp.create_pd_resp;
447+
struct pvrdma_alloc_pd_resp pd_resp = {0};
447448
int ret;
448449
void *ptr;
449450

@@ -472,9 +473,10 @@ struct ib_pd *pvrdma_alloc_pd(struct ib_device *ibdev,
472473
pd->privileged = !context;
473474
pd->pd_handle = resp->pd_handle;
474475
pd->pdn = resp->pd_handle;
476+
pd_resp.pdn = resp->pd_handle;
475477

476478
if (context) {
477-
if (ib_copy_to_udata(udata, &pd->pdn, sizeof(__u32))) {
479+
if (ib_copy_to_udata(udata, &pd_resp, sizeof(pd_resp))) {
478480
dev_warn(&dev->pdev->dev,
479481
"failed to copy back protection domain\n");
480482
pvrdma_dealloc_pd(&pd->ibpd);

0 commit comments

Comments
 (0)