FAILED: patch "[PATCH] RDMA/umem: Fix truncation for block sizes >= 4G" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 15fe76e23615f502d051ef0768f86babaf08746c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026061513-rimless-afoot-0214@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 15fe76e23615f502d051ef0768f86babaf08746c Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Mon, 1 Jun 2026 13:52:31 -0300
Subject: [PATCH] RDMA/umem: Fix truncation for block sizes >= 4G
When the iommu is used the linearization of the mapping can give a single block that is very large split across multiple SG entries.
When __rdma_block_iter_next() reassembles the split SG entries it is overflowing the 32 bit stack values and computed the wrong DMA addresses for blocks after the truncation.
Use the right types to hold DMA addresses.
drivers/infiniband/core/iter.c +2 -2
@@ -19,8 +19,8 @@ EXPORT_SYMBOL(__rdma_block_iter_start);bool __rdma_block_iter_next (struct ib_block_iter *biter) { -unsigned int block_offset; -unsigned int delta; +dma_addr_t block_offset; +dma_addr_t delta;if (!biter->__sg_nents || !biter->__sg)return false;
Sasha Levin
maintainerPATCH 1/3 RDMA/umem: fix kernel-doc warnings
From: Randy Dunlap <[email protected]>
[ Upstream commit ff46d1392750444fab5ae5a0194764ffdc4ac0d2 ]
Add or correct kernel-doc comments to eliminate warnings:
Warning: include/rdma/ib_umem.h:104 function parameter 'biter' not
described in 'rdma_umem_for_each_dma_block'
Warning: include/rdma/ib_umem.h:140 function parameter 'pgsz_bitmap' not
described in 'ib_umem_find_best_pgoff'
Warning: include/rdma/ib_umem.h:141 No description found for return
value of 'ib_umem_find_best_pgoff'
Stable-dep-of: 15fe76e23615 ("RDMA/umem: Fix truncation for block sizes >= 4G")
--- include/rdma/ib_umem.h | 1 + 1 file changed, 1 insertion(+)
include/rdma/ib_umem.h +1 -0
@@ -57,6 +57,7 @@ static inline void __rdma_umem_block_iter_start(struct ib_block_iter *biter,/** * rdma_umem_for_each_dma_block - iterate over contiguous DMA blocks of the umem * @umem: umem to iterate over +* @biter: block iterator variable * @pgsz: Page size to split the list into * * pgsz must be <= PAGE_SIZE or computed by ib_umem_find_best_pgsz(). The
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 RDMA: Move DMA block iterator logic into dedicated files
From: Leon Romanovsky <[email protected]>
[ Upstream commit 6094ea64c69520ed1e770e7c79c43412de202bfa ]
The DMA iterator logic was mixed into verbs and umem-specific code, forcing all users to include rdma/ib_umem.h. Move the block iterator logic into iter.c and rdma/iter.h so that rdma/ib_umem.h and rdma/ib_verbs.h can be separated in a follow-up patch.
Stable-dep-of: 15fe76e23615 ("RDMA/umem: Fix truncation for block sizes >= 4G")
--- drivers/infiniband/core/Makefile | 2 +- drivers/infiniband/core/iter.c | 43 +++++++++++ drivers/infiniband/core/verbs.c | 37 --------- drivers/infiniband/hw/bnxt_re/qplib_res.c | 2 +- drivers/infiniband/hw/cxgb4/mem.c | 2 +- drivers/infiniband/hw/efa/efa_verbs.c | 2 +- drivers/infiniband/hw/hns/hns_roce_alloc.c | 2 +- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 1 + drivers/infiniband/hw/mlx4/mr.c | 1 + drivers/infiniband/hw/mlx5/mem.c | 1 + drivers/infiniband/hw/mthca/mthca_provider.c | 2 +- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- drivers/infiniband/hw/qedr/verbs.c | 2 +- drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 2 +- include/rdma/ib_umem.h | 24 ------ include/rdma/ib_verbs.h | 47 ------------ include/rdma/iter.h | 80 ++++++++++++++++++++ 17 files changed, 135 insertions(+), 117 deletions(-) create mode 100644 drivers/infiniband/core/iter.c create mode 100644 include/rdma/iter.h
drivers/infiniband/core/Makefile +1 -1
@@ -12,7 +12,7 @@ ib_core-y := packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \ roce_gid_mgmt.o mr_pool.o addr.o sa_query.o \ multicast.o mad.o smi.o agent.o mad_rmpp.o \ nldev.o restrack.o counters.o ib_core_uverbs.o \ - trace.o lag.o + trace.o lag.o iter.o ib_core-$(CONFIG_SECURITY_INFINIBAND) += security.o ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o
drivers/infiniband/core/iter.c new file +43 -0
43 lines not on this page · raw message
drivers/infiniband/core/verbs.c +0 -37
@@ -2896,40 +2896,3 @@ int rdma_init_netdev(struct ib_device *device, u8 port_num, netdev, params.param); }EXPORT_SYMBOL (rdma_init_netdev); - -void __rdma_block_iter_start (struct ib_block_iter *biter, -struct scatterlist *sglist,unsigned int nents, -unsigned long pgsz) -{ -memset (biter,0 ,sizeof (struct ib_block_iter )); - biter->__sg = sglist; - biter->__sg_nents = nents; - -/* Driver provides best block size to use */ - biter->__pg_bit =__fls (pgsz); -} -EXPORT_SYMBOL (__rdma_block_iter_start); - -bool __rdma_block_iter_next (struct ib_block_iter *biter) -{ -unsigned int block_offset; -unsigned int sg_delta; - -if (!biter->__sg_nents || !biter->__sg) -return false; - - biter->__dma_addr =sg_dma_address (biter->__sg) + biter->__sg_advance; - block_offset = biter->__dma_addr & (BIT_ULL (biter->__pg_bit) -1 ); - sg_delta =BIT_ULL (biter->__pg_bit) - block_offset; - -if (sg_dma_len (biter->__sg) - biter->__sg_advance > sg_delta) { - biter->__sg_advance += sg_delta; - }else { - biter->__sg_advance =0 ; - biter->__sg =sg_next (biter->__sg); - biter->__sg_nents--; - } - -return true; -} -EXPORT_SYMBOL (__rdma_block_iter_next);
drivers/infiniband/hw/bnxt_re/qplib_res.c +1 -1
@@ -46,7 +46,7 @@#include <linux/if_vlan.h> #include <linux/vmalloc.h> #include <rdma/ib_verbs.h> -#include <rdma/ib_umem.h> +#include <rdma/iter.h> #include "roce_hsi.h" #include "qplib_res.h"
drivers/infiniband/hw/cxgb4/mem.c +1 -1
@@ -32,9 +32,9 @@#include <linux/module.h> #include <linux/moduleparam.h> -#include <rdma/ib_umem.h> #include <linux/atomic.h> #include <rdma/ib_user_verbs.h> +#include <rdma/iter.h> #include "iw_cxgb4.h"
drivers/infiniband/hw/efa/efa_verbs.c +1 -1
@@ -7,9 +7,9 @@#include <linux/log2.h> #include <rdma/ib_addr.h> -#include <rdma/ib_umem.h> #include <rdma/ib_user_verbs.h> #include <rdma/ib_verbs.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include "efa.h"
drivers/infiniband/hw/hns/hns_roce_alloc.c +1 -1
@@ -34,7 +34,7 @@#include <linux/platform_device.h> #include <linux/vmalloc.h> #include "hns_roce_device.h" -#include <rdma/ib_umem.h> +#include <rdma/iter.h> int hns_roce_bitmap_alloc (struct hns_roce_bitmap *bitmap,unsigned long *obj) {
drivers/infiniband/hw/i40iw/i40iw_verbs.c +1 -0
@@ -45,6 +45,7 @@#include <rdma/iw_cm.h> #include <rdma/ib_user_verbs.h> #include <rdma/ib_umem.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include "i40iw.h"
drivers/infiniband/hw/mlx4/mr.c +1 -0
@@ -33,6 +33,7 @@#include <linux/slab.h> #include <rdma/ib_user_verbs.h> +#include <rdma/iter.h> #include "mlx4_ib.h"
drivers/infiniband/hw/mlx5/mem.c +1 -0
@@ -33,6 +33,7 @@#include <linux/module.h> #include <rdma/ib_umem.h> #include <rdma/ib_umem_odp.h> +#include <rdma/iter.h> #include "mlx5_ib.h" #include <linux/jiffies.h>
drivers/infiniband/hw/mthca/mthca_provider.c +1 -1
@@ -35,8 +35,8 @@*/ #include <rdma/ib_smi.h> -#include <rdma/ib_umem.h> #include <rdma/ib_user_verbs.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include <linux/sched.h>
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1 -1
@@ -44,9 +44,9 @@#include <rdma/ib_verbs.h> #include <rdma/ib_user_verbs.h> #include <rdma/iw_cm.h> -#include <rdma/ib_umem.h> #include <rdma/ib_addr.h> #include <rdma/ib_cache.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include "ocrdma.h"
drivers/infiniband/hw/qedr/verbs.c +1 -1
@@ -39,9 +39,9 @@#include <rdma/ib_verbs.h> #include <rdma/ib_user_verbs.h> #include <rdma/iw_cm.h> -#include <rdma/ib_umem.h> #include <rdma/ib_addr.h> #include <rdma/ib_cache.h> +#include <rdma/iter.h> #include <rdma/uverbs_ioctl.h> #include <linux/qed/common_hsi.h>
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +1 -1
@@ -53,8 +53,8 @@#include <linux/pci.h> #include <linux/semaphore.h> #include <linux/workqueue.h> -#include <rdma/ib_umem.h> #include <rdma/ib_verbs.h> +#include <rdma/iter.h> #include <rdma/vmw_pvrdma-abi.h> #include "pvrdma_ring.h"
include/rdma/ib_umem.h +0 -24
@@ -46,30 +46,6 @@ static inline size_t ib_umem_num_pages(struct ib_umem *umem) {return ib_umem_num_dma_blocks (umem,PAGE_SIZE ); } - -static inline void __rdma_umem_block_iter_start (struct ib_block_iter *biter, -struct ib_umem *umem, -unsigned long pgsz) -{ -__rdma_block_iter_start (biter, umem->sg_head.sgl, umem->nmap, pgsz); -} - -/** -* rdma_umem_for_each_dma_block - iterate over contiguous DMA blocks of the umem -* @umem: umem to iterate over -* @biter: block iterator variable -* @pgsz: Page size to split the list into -* -* pgsz must be <= PAGE_SIZE or computed by ib_umem_find_best_pgsz(). The -* returned DMA blocks will be aligned to pgsz and span the range: -* ALIGN_DOWN(umem->address, pgsz) to ALIGN(umem->address + umem->length, pgsz) -* -* Performs exactly ib_umem_num_dma_blocks() iterations. -*/ -#define rdma_umem_for_each_dma_block (umem, biter, pgsz) \ - for (__rdma_umem_block_iter_start(biter, umem, pgsz); \ - __rdma_block_iter_next(biter);) -#ifdef CONFIG_INFINIBAND_USER_MEM struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr,
include/rdma/ib_verbs.h +0 -47
59 lines not on this page · raw message
include/rdma/iter.h new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 RDMA/umem: Fix truncation for block sizes >= 4G
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 15fe76e23615f502d051ef0768f86babaf08746c ]
When the iommu is used the linearization of the mapping can give a single block that is very large split across multiple SG entries.
When __rdma_block_iter_next() reassembles the split SG entries it is overflowing the 32 bit stack values and computed the wrong DMA addresses for blocks after the truncation.
Use the right types to hold DMA addresses.
--- drivers/infiniband/core/iter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/iter.c +2 -2
@@ -19,8 +19,8 @@ EXPORT_SYMBOL(__rdma_block_iter_start);bool __rdma_block_iter_next (struct ib_block_iter *biter) { -unsigned int block_offset; -unsigned int delta; +dma_addr_t block_offset; +dma_addr_t delta;if (!biter->__sg_nents || !biter->__sg)return false;
Signature · 1 line
2.53.0