Re: [PATCH] block: bio: check offset/length sanity in {__,}bio_add_page()

From: Christoph Hellwig

Date: Fri Jun 26 2026 - 02:12:31 EST


On Wed, Jun 24, 2026 at 11:33:26PM +0300, Sergey Shtylyov wrote:
> Sum of the *struct* bio_vec's fields bv_offset and bv_len is calculated in
> some functions in block/{blk-merge.c,blk.h> (and that sum is often compared
> to PAGE_SIZE) -- that sum may overflow (and so the comparison yield a wrong
> result) if some bad arguments were previusly passed to {__,}bio_add_page().
> Add a check that the sum of the offset and length parameters won't overflow
> to {__,}bio_add_page()...

I'm not really sure there's much of a point in this, because the
error handling isn't really going to help to recover either. I think
we have to trust our programmers to at least get the very basics
right.