Re: [PATCH] io_uring/rsrc: fix slab-out-of-bounds in io_buffer_register_bvec

From: Christoph Hellwig

Date: Fri Dec 19 2025 - 00:33:58 EST


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.