Skip to content

Commit f899787

Browse files
jgunthorperleon
authored andcommitted
RDMA/mlx4: Use ib_copy_validate_udata_in()
Follow the last member of each struct at the point MLX4_IB_UVERBS_ABI_VERSION was set to 4. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
1 parent 530b251 commit f899787

3 files changed

Lines changed: 10 additions & 13 deletions

File tree

drivers/infiniband/hw/mlx4/cq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,9 @@ int mlx4_ib_create_user_cq(struct ib_cq *ibcq,
168168
INIT_LIST_HEAD(&cq->send_qp_list);
169169
INIT_LIST_HEAD(&cq->recv_qp_list);
170170

171-
if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
172-
err = -EFAULT;
171+
err = ib_copy_validate_udata_in(udata, ucmd, db_addr);
172+
if (err)
173173
goto err_cq;
174-
}
175174

176175
if (ibcq->umem &&
177176
(dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SW_CQ_INIT))
@@ -336,8 +335,9 @@ static int mlx4_alloc_resize_umem(struct mlx4_ib_dev *dev, struct mlx4_ib_cq *cq
336335
if (cq->resize_umem)
337336
return -EBUSY;
338337

339-
if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
340-
return -EFAULT;
338+
err = ib_copy_validate_udata_in(udata, ucmd, buf_addr);
339+
if (err)
340+
return err;
341341

342342
cq->resize_buf = kmalloc_obj(*cq->resize_buf);
343343
if (!cq->resize_buf)

drivers/infiniband/hw/mlx4/qp.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,16 +1053,12 @@ static int create_qp_common(struct ib_pd *pd, struct ib_qp_init_attr *init_attr,
10531053

10541054
if (udata) {
10551055
struct mlx4_ib_create_qp ucmd;
1056-
size_t copy_len;
10571056
int shift;
10581057
int n;
10591058

1060-
copy_len = sizeof(struct mlx4_ib_create_qp);
1061-
1062-
if (ib_copy_from_udata(&ucmd, udata, copy_len)) {
1063-
err = -EFAULT;
1059+
err = ib_copy_validate_udata_in(udata, ucmd, sq_no_prefetch);
1060+
if (err)
10641061
goto err;
1065-
}
10661062

10671063
qp->inl_recv_sz = ucmd.inl_recv_sz;
10681064

drivers/infiniband/hw/mlx4/srq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ int mlx4_ib_create_srq(struct ib_srq *ib_srq,
111111
if (udata) {
112112
struct mlx4_ib_create_srq ucmd;
113113

114-
if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd)))
115-
return -EFAULT;
114+
err = ib_copy_validate_udata_in(udata, ucmd, db_addr);
115+
if (err)
116+
return err;
116117

117118
srq->umem =
118119
ib_umem_get(ib_srq->device, ucmd.buf_addr, buf_size, 0);

0 commit comments

Comments
 (0)