mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Bilal Hashim <AeeSec@126.com>, Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] io_uring/dma-buf: reject dma-bufs larger than UINT_MAX
Date: Thu, 3 Dec 2026 12:19:14 +0000	[thread overview]
Message-ID: <c4a43fb9-f787-40be-86a1-8c5628a03ed3@gmail.com> (raw)
In-Reply-To: <179610714926.42980.6300011710027404841@126.com>

On 12/1/26 06:39, Bilal Hashim wrote:
> __io_register_dmabuf() currently validates dmabuf->size using
> io_validate_user_buf_range(0, dmabuf->size), which permits buffers up to
> SZ_1T (1 TiB) on 64-bit systems.

As Anuj mentioned, it's a problem of the block layer and
Keith already patched it there.

> However, when dma-buf I/O is submitted to the block layer,
> bio_iov_iter_set() assigns the 64-bit iter->iov_offset directly into
> bio->bi_iter.bi_offset, which is a 32-bit unsigned int in struct
> bvec_iter. Similarly, nvme_rq_setup_dmabuf_map() computes the DMA page
> index from the 32-bit bi_offset, and bio splitting/advancement performs
> 32-bit arithmetic on bi_offset.
> 
> If userspace registers a dma-buf larger than 4 GiB and submits fixed
> read/write requests at an offset >= 4 GiB (or crossing the 4 GiB
> boundary), bi_offset silently truncates modulo 4 GiB, causing NVMe DMA
> to access the wrong region of the dma-buf and corrupt data.

-- 
Pavel Begunkov


      parent reply	other threads:[~2026-12-03 12:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  6:39 Bilal Hashim
     [not found] ` <CGME20261203051712epcas5p4c1e58cf6006d0e5e48c5487482eb8fca@epcas5p4.samsung.com>
2026-12-03  5:15   ` Anuj Gupta
2026-12-03 12:19 ` Pavel Begunkov [this message]

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=c4a43fb9-f787-40be-86a1-8c5628a03ed3@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=AeeSec@126.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®