From be684be1ff4c08ca4a9ce42e7d9ad4e1405a9305 Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Fri, 12 Jun 2026 15:32:04 -0700 Subject: [PATCH] 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 Tested-by: Carlos Maiolino Reviewed-by: Carlos Maiolino --- block/blk.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/blk.h b/block/blk.h index b998a7761faf3..a99b1ff202c31 100644 --- a/block/blk.h +++ b/block/blk.h @@ -402,6 +402,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; }