From bcbd808652e127a704c21fa44d908eb56cbcda03 Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Wed, 21 Oct 2026 11:46:57 -0700 Subject: [PATCH] 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: 839231d19393 ("block: add dma-buf support for raw bdev") Signed-off-by: Keith Busch Link: https://patch.msgid.link/20261021184658.644645-2-kbusch@meta.com Signed-off-by: Jens Axboe --- block/fops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/fops.c b/block/fops.c index 49ae0302f123..01bc8afe3b48 100644 --- a/block/fops.c +++ b/block/fops.c @@ -19,6 +19,7 @@ #include #include #include +#include #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))