From: Keith Busch <kbusch@meta.com>
To: <linux-block@vger.kernel.org>, <linux-nvme@lists.infradead.org>,
<axboe@kernel.dk>, <asml.silence@gmail.com>
Cc: <hch@lst.de>, Keith Busch <kbusch@kernel.org>
Subject: [PATCH 1/2] block: reject dma-bufs larger than 4GiB
Date: Wed, 21 Oct 2026 11:46:57 -0700 [thread overview]
Message-ID: <20261021184658.644645-2-kbusch@meta.com> (raw)
In-Reply-To: <20261021184658.644645-1-kbusch@meta.com>
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;
if (!disk->fops->init_dma_buf_io_ctx)
return -EOPNOTSUPP;
if (bdev_has_integrity_csum(bdev))
--
2.52.0
next prev parent reply other threads:[~2026-10-21 18:47 UTC|newest]
Thread overview: 3+ 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 ` Keith Busch [this message]
2026-10-21 18:46 ` [PATCH 2/2] nvme-pci: detach dma-bufs only on removal Keith Busch
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=20261021184658.644645-2-kbusch@meta.com \
--to=kbusch@meta.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--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