]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
RDMA/irdma: Fix out-of-bounds write in irdma_copy_user_pgaddrs
authorJacob Moroni <jmoroni@google.com>
Tue, 12 May 2026 18:38:52 +0000 (18:38 +0000)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 25 May 2026 13:50:42 +0000 (10:50 -0300)
commit5ebb3ed757be3e04cf803026004aa0beaeb13e9b
treea8c6a58bf31d52834947269c66f87ce84c078aa3
parentd28654518c8db5d06d27bd3211c0e9a70c18f7c2
RDMA/irdma: Fix out-of-bounds write in irdma_copy_user_pgaddrs

The irdma_copy_user_pgaddrs function loops through all of the umem DMA
blocks to populate the PBLEs and will stop when either the last DMA
block is reached or palloc->total_cnt is reached. The issue is that
the logic for checking palloc->total_cnt would only work for non-zero
values.

When irdma_setup_pbles is called with lvl==0, it
calls irdma_copy_user_pgaddrs with palloc->total_cnt==0, which means
the only way to break out of the loop is to reach the last umem DMA
block, which means it could end up going beyond the fixed size of 4
iwmr->pgaddrmem array that is used in the lvl==0 case.

In the case of QP/CQ/SRQ rings, the value of lvl is determined by a
separate input (for example, req.cq_pages in the case of a CQ). So,
we must perform explicit checking to ensure we don't overflow the
pgaddrmem array if the user provides a umem that consists of more
blocks than their provided req.cq_pages.

Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
Link: https://patch.msgid.link/r/20260512183852.614045-1-jmoroni@google.com
Signed-off-by: Jacob Moroni <jmoroni@google.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/irdma/verbs.c