Re: [PATCH] io_uring/dma-buf: reject dma-bufs larger than UINT_MAX

From: Pavel Begunkov

Date: Thu Dec 03 2026 - 07:19:23 EST


On 12/1/26 06:39, Bilal Hashim wrote:
__io_register_dmabuf() currently validates dmabuf->size using
io_validate_user_buf_range(0, dmabuf->size), which permits buffers up to
SZ_1T (1 TiB) on 64-bit systems.

As Anuj mentioned, it's a problem of the block layer and
Keith already patched it there.

However, when dma-buf I/O is submitted to the block layer,
bio_iov_iter_set() assigns the 64-bit iter->iov_offset directly into
bio->bi_iter.bi_offset, which is a 32-bit unsigned int in struct
bvec_iter. Similarly, nvme_rq_setup_dmabuf_map() computes the DMA page
index from the 32-bit bi_offset, and bio splitting/advancement performs
32-bit arithmetic on bi_offset.

If userspace registers a dma-buf larger than 4 GiB and submits fixed
read/write requests at an offset >= 4 GiB (or crossing the 4 GiB
boundary), bi_offset silently truncates modulo 4 GiB, causing NVMe DMA
to access the wrong region of the dma-buf and corrupt data.

--
Pavel Begunkov