summaryrefslogtreecommitdiff
path: root/drivers/infiniband/hw/hfi1/user_sdma.c
diff options
context:
space:
mode:
authorPhilipp Stanner <pstanner@redhat.com>2023-11-02 20:13:09 +0100
committerLeon Romanovsky <leon@kernel.org>2023-11-13 10:21:33 +0200
commitc170d4ff21a8a525d782e3d1bc58d9538d95afe6 (patch)
tree306432a287d74b2d41ed82a4df6a6ae3c6e7d274 /drivers/infiniband/hw/hfi1/user_sdma.c
parent476b7c7e00ec3d909bacaeaf1dc53eb2b2d0c41d (diff)
downloadlinux-c170d4ff21a8a525d782e3d1bc58d9538d95afe6.tar.gz
linux-c170d4ff21a8a525d782e3d1bc58d9538d95afe6.tar.bz2
linux-c170d4ff21a8a525d782e3d1bc58d9538d95afe6.zip
RDMA/hfi1: Copy userspace arrays safely
Currently, memdup_user() is utilized at two positions to copy userspace arrays. This is done without overflow checks. Use the new wrapper memdup_array_user() to copy the arrays more safely. Suggested-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Philipp Stanner <pstanner@redhat.com> Link: https://lore.kernel.org/r/20231102191308.52046-2-pstanner@redhat.com Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/user_sdma.c')
-rw-r--r--drivers/infiniband/hw/hfi1/user_sdma.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c
index 6a4aa59c0cbc..b72625283fcf 100644
--- a/drivers/infiniband/hw/hfi1/user_sdma.c
+++ b/drivers/infiniband/hw/hfi1/user_sdma.c
@@ -494,8 +494,8 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
* equal to the pkt count. However, there is no way to
* tell at this point.
*/
- tmp = memdup_user(iovec[idx].iov_base,
- ntids * sizeof(*req->tids));
+ tmp = memdup_array_user(iovec[idx].iov_base,
+ ntids, sizeof(*req->tids));
if (IS_ERR(tmp)) {
ret = PTR_ERR(tmp);
SDMA_DBG(req, "Failed to copy %d TIDs (%d)",