Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/hns: Use ib_copy_validate_udata_in()

Follow the last struct member from the commit when the struct was
added to the kernel.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

authored by

Jason Gunthorpe and committed by
Leon Romanovsky
d5c8f2f3 0453bf09

+8 -45
+1 -15
drivers/infiniband/hw/hns/hns_roce_cq.c
··· 350 350 return 0; 351 351 } 352 352 353 - static int get_cq_ucmd(struct hns_roce_cq *hr_cq, struct ib_udata *udata, 354 - struct hns_roce_ib_create_cq *ucmd) 355 - { 356 - struct ib_device *ibdev = hr_cq->ib_cq.device; 357 - int ret; 358 - 359 - ret = ib_copy_from_udata(ucmd, udata, min(udata->inlen, sizeof(*ucmd))); 360 - if (ret) { 361 - ibdev_err(ibdev, "failed to copy CQ udata, ret = %d.\n", ret); 362 - return ret; 363 - } 364 - 365 - return 0; 366 - } 367 353 368 354 static void set_cq_param(struct hns_roce_cq *hr_cq, u32 cq_entries, int vector, 369 355 struct hns_roce_ib_create_cq *ucmd) ··· 414 428 goto err_out; 415 429 416 430 if (udata) { 417 - ret = get_cq_ucmd(hr_cq, udata, &ucmd); 431 + ret = ib_copy_validate_udata_in(udata, ucmd, db_addr); 418 432 if (ret) 419 433 goto err_out; 420 434 }
+2 -2
drivers/infiniband/hw/hns/hns_roce_main.c
··· 36 36 #include <rdma/ib_smi.h> 37 37 #include <rdma/ib_user_verbs.h> 38 38 #include <rdma/ib_cache.h> 39 + #include <rdma/uverbs_ioctl.h> 39 40 #include "hns_roce_common.h" 40 41 #include "hns_roce_device.h" 41 42 #include "hns_roce_hem.h" ··· 434 433 resp.qp_tab_size = hr_dev->caps.num_qps; 435 434 resp.srq_tab_size = hr_dev->caps.num_srqs; 436 435 437 - ret = ib_copy_from_udata(&ucmd, udata, 438 - min(udata->inlen, sizeof(ucmd))); 436 + ret = ib_copy_validate_udata_in(udata, ucmd, reserved); 439 437 if (ret) 440 438 goto error_out; 441 439
+2 -6
drivers/infiniband/hw/hns/hns_roce_qp.c
··· 1130 1130 } 1131 1131 1132 1132 if (udata) { 1133 - ret = ib_copy_from_udata(ucmd, udata, 1134 - min(udata->inlen, sizeof(*ucmd))); 1135 - if (ret) { 1136 - ibdev_err(ibdev, 1137 - "failed to copy QP ucmd, ret = %d\n", ret); 1133 + ret = ib_copy_validate_udata_in(udata, *ucmd, reserved); 1134 + if (ret) 1138 1135 return ret; 1139 - } 1140 1136 1141 1137 uctx = rdma_udata_to_drv_context(udata, struct hns_roce_ucontext, 1142 1138 ibucontext);
+3 -22
drivers/infiniband/hw/hns/hns_roce_srq.c
··· 346 346 int ret; 347 347 348 348 if (udata) { 349 - ret = ib_copy_from_udata(&ucmd, udata, 350 - min(udata->inlen, sizeof(ucmd))); 351 - if (ret) { 352 - ibdev_err(&hr_dev->ib_dev, 353 - "failed to copy SRQ udata, ret = %d.\n", 354 - ret); 349 + ret = ib_copy_validate_udata_in(udata, ucmd, que_addr); 350 + if (ret) 355 351 return ret; 356 - } 357 352 } 358 353 359 354 ret = alloc_srq_idx(hr_dev, srq, udata, ucmd.que_addr); ··· 382 387 free_srq_idx(hr_dev, srq); 383 388 } 384 389 385 - static int get_srq_ucmd(struct hns_roce_srq *srq, struct ib_udata *udata, 386 - struct hns_roce_ib_create_srq *ucmd) 387 - { 388 - struct ib_device *ibdev = srq->ibsrq.device; 389 - int ret; 390 - 391 - ret = ib_copy_from_udata(ucmd, udata, min(udata->inlen, sizeof(*ucmd))); 392 - if (ret) { 393 - ibdev_err(ibdev, "failed to copy SRQ udata, ret = %d.\n", ret); 394 - return ret; 395 - } 396 - 397 - return 0; 398 - } 399 390 400 391 static void free_srq_db(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, 401 392 struct ib_udata *udata) ··· 411 430 int ret; 412 431 413 432 if (udata) { 414 - ret = get_srq_ucmd(srq, udata, &ucmd); 433 + ret = ib_copy_validate_udata_in(udata, ucmd, que_addr); 415 434 if (ret) 416 435 return ret; 417 436