All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: veygax <veyga@veygax.dev>, Ming Lei <ming.lei@redhat.com>,
	Jens Axboe <axboe@kernel.dk>,
	"io-uring@vger.kernel.org" <io-uring@vger.kernel.org>,
	Caleb Sander Mateos <csander@purestorage.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] io_uring/rsrc: fix slab-out-of-bounds in io_buffer_register_bvec
Date: Mon, 22 Dec 2025 07:29:31 +0800	[thread overview]
Message-ID: <aUiC2615oUTgF_PT@kbusch-mbp> (raw)
In-Reply-To: <aUTjxJEDYYfOT_QG@infradead.org>

On Thu, Dec 18, 2025 at 09:33:56PM -0800, Christoph Hellwig wrote:
> On Thu, Dec 18, 2025 at 08:56:43AM +0800, Keith Busch wrote:
> > On Thu, Dec 18, 2025 at 12:37:47AM +0000, veygax wrote:
> > > 	/*
> > > 	 * Add pages to bio manually.
> > > 	 * We use physically contiguous pages to trick blk_rq_nr_phys_segments
> > > 	 * into returning 1 segment.
> > > 	 * We use multiple bvec entries to trick the loop in io_buffer_register_bvec
> > > 	 * into writing out of bounds.
> > > 	 */
> > > 	for (i = 0; i < num_bvecs; i++) {
> > > 		struct bio_vec *bv = &bio->bi_io_vec[i];
> > > 		bv->bv_page = page + i;
> > > 		bv->bv_len = PAGE_SIZE;
> > > 		bv->bv_offset = 0;
> > > 		bio->bi_vcnt++;
> > > 		bio->bi_iter.bi_size += PAGE_SIZE;
> > > 	}
> > 
> > I believe you're supposed to use the bio_add_page() API rather than open
> > code the bvec setup.
> 
> The above is simply an open coded version of doing repeated
> __bio_add_page calls.  Which would be rather suboptimal, but perfectly
> valid.

Yeah, there's nothing stopping someone from using it that way, but a
quick survey of __bio_add_page() users appear to be special cases that
allocate a single vector bio, so its existing use is a short-cut that
bio_add_page() will inevitiably reach anyway. Did you intend for it to
be called directly for multiple vector uses too? It is suboptimal as you
said, so it still feels like a misuse if someone did that.

  reply	other threads:[~2025-12-21 23:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17 21:04 [PATCH] io_uring/rsrc: fix slab-out-of-bounds in io_buffer_register_bvec veygax
2025-12-17 21:22 ` Caleb Sander Mateos
2025-12-18  0:32 ` Ming Lei
2025-12-18  0:37   ` veygax
2025-12-18  0:56     ` Keith Busch
2025-12-18  1:13       ` veygax
2025-12-18  2:58         ` Ming Lei
2025-12-18 23:00         ` Keith Busch
2025-12-19  3:28           ` Jens Axboe
2025-12-19  5:33       ` Christoph Hellwig
2025-12-21 23:29         ` Keith Busch [this message]
2025-12-22 22:08           ` Christoph Hellwig
2025-12-22  1:02         ` veygax

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=aUiC2615oUTgF_PT@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=hch@infradead.org \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=veyga@veygax.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.