From: Keith Busch Date: Fri, 12 Jun 2026 22:32:04 +0000 (-0700) Subject: block: check bio split for unaligned bvec X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b0c3673c88588d613d8f09f5931b2b466c6a83d;p=thirdparty%2Flinux.git block: check bio split for unaligned bvec Offsets and lengths need to be validated against the dma alignment. This check was skipped for sufficiently a small bio with a single bvec, which may allow an invalid request dispatched to the driver. Force the validation for an unaligned bvec by forcing the bio split path that handles this condition. Fixes: 7eac33186957 ("iomap: simplify direct io validity check") Fixes: 5ff3f74e145a ("block: simplify direct io validity check") Reported-by: Carlos Maiolino Signed-off-by: Keith Busch Link: https://patch.msgid.link/20260612223205.465913-1-kbusch@meta.com Signed-off-by: Jens Axboe --- diff --git a/block/blk.h b/block/blk.h index 507ab34a6e90a..25af8ac5ef0f7 100644 --- a/block/blk.h +++ b/block/blk.h @@ -408,6 +408,8 @@ static inline bool bio_may_need_split(struct bio *bio, bv = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); if (bio->bi_iter.bi_size > bv->bv_len - bio->bi_iter.bi_bvec_done) return true; + if ((bv->bv_offset | bv->bv_len) & lim->dma_alignment) + return true; return bv->bv_len + bv->bv_offset > lim->max_fast_segment_size; }