From: Pavel Begunkov <asml.silence@gmail.com>
To: Keith Busch <kbusch@meta.com>,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
axboe@kernel.dk
Cc: hch@lst.de, Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH 1/2] block: reject dma-bufs larger than 4GiB
Date: Tue, 27 Oct 2026 13:38:32 +0000 [thread overview]
Message-ID: <dc128acb-d033-43e0-adb0-f866c638c7ae@gmail.com> (raw)
In-Reply-To: <7c1599a8-31df-4797-a794-bf5ba3d75286@gmail.com>
On 10/23/26 18:52, Pavel Begunkov wrote:
> On 10/21/26 19:46, Keith Busch wrote:
>> From: Keith Busch <kbusch@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@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
next prev parent reply other threads:[~2026-10-27 13:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 18:46 [PATCH 0/2] block, nvme: minor fixes to dma-buf support Keith Busch
2026-10-21 18:46 ` [PATCH 1/2] block: reject dma-bufs larger than 4GiB Keith Busch
2026-10-23 17:52 ` Pavel Begunkov
2026-10-27 13:38 ` Pavel Begunkov [this message]
2026-10-21 18:46 ` [PATCH 2/2] nvme-pci: detach dma-bufs only on removal Keith Busch
2026-10-22 12:41 ` [PATCH 0/2] block, nvme: minor fixes to dma-buf support Jens Axboe
2026-10-27 14:28 ` Pavel Begunkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dc128acb-d033-43e0-adb0-f866c638c7ae@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kbusch@meta.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox