Skip to content

Commit 9b0c367

Browse files
keithbuschaxboe
authored andcommitted
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: 7eac331 ("iomap: simplify direct io validity check") Fixes: 5ff3f74 ("block: simplify direct io validity check") Reported-by: Carlos Maiolino <cem@kernel.org> Signed-off-by: Keith Busch <kbusch@kernel.org> Link: https://patch.msgid.link/20260612223205.465913-1-kbusch@meta.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent d532cdd commit 9b0c367

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

block/blk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ static inline bool bio_may_need_split(struct bio *bio,
408408
bv = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
409409
if (bio->bi_iter.bi_size > bv->bv_len - bio->bi_iter.bi_bvec_done)
410410
return true;
411+
if ((bv->bv_offset | bv->bv_len) & lim->dma_alignment)
412+
return true;
411413
return bv->bv_len + bv->bv_offset > lim->max_fast_segment_size;
412414
}
413415

0 commit comments

Comments
 (0)