block: reject dma-bufs larger than 4GiB

The dma-buf offset is set in the 32-bit bvec_iter bi_offset. Reject
buffers that can carry an offset that would wrap.

Fixes: 839231d193 ("block: add dma-buf support for raw bdev")
Signed-off-by: Keith Busch <kbusch@kernel.org>
Link: https://patch.msgid.link/20261021184658.644645-2-kbusch@meta.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Keith Busch 2026-10-21 11:46:57 -07:00 committed by Jens Axboe
parent f57b957778
commit bcbd808652

View File

@ -19,6 +19,7 @@
#include <linux/iomap.h>
#include <linux/module.h>
#include <linux/io_uring/cmd.h>
#include <linux/dma-buf-io.h>
#include "blk.h"
static inline struct inode *bdev_file_inode(struct file *file)
@ -942,6 +943,8 @@ static int blkdev_init_dma_buf_io_ctx(struct file *file,
if (!(file->f_flags & O_DIRECT))
return -EINVAL;
if (ctx->dmabuf->size > UINT_MAX)
return -EINVAL;
if (!disk->fops->init_dma_buf_io_ctx)
return -EOPNOTSUPP;
if (bdev_has_integrity_csum(bdev))