[PATCH 1/2] block: reject dma-bufs larger than 4GiB
Pavel Begunkov
asml.silence at gmail.com
Tue Oct 27 06:38:32 PDT 2026
On 10/23/26 18:52, Pavel Begunkov wrote:
> On 10/21/26 19:46, Keith Busch wrote:
>> From: Keith Busch <kbusch at kernel.org>
>>
>> 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 <kbusch at kernel.org>
>> ---
>> block/fops.c | 3 ++++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/block/fops.c b/block/fops.c
>> index 46cb86dd36d23..a974b423869eb 100644
>> --- a/block/fops.c
>> +++ b/block/fops.c
>> @@ -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)
>> @@ -1009,6 +1010,9 @@ 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;
>
> Sounds good, should be reasonable for now. It'd also be good to
> move it to dma-buf-io* as it's not a block problem.
fwiw, I was wrong here assuming that iov_iter's offset is also u32.
--
Pavel Begunkov
More information about the Linux-nvme
mailing list