* [PATCH] block: check bio split for unaligned bvec
@ 2026-06-12 22:32 Keith Busch
2026-06-13 12:36 ` Jens Axboe
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Keith Busch @ 2026-06-12 22:32 UTC (permalink / raw)
To: linux-block, axboe; +Cc: hch, Keith Busch, Carlos Maiolino
From: Keith Busch <kbusch@kernel.org>
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 <cem@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
block/blk.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/blk.h b/block/blk.h
index 1a2d9101bba04..004048fa0c5a8 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -404,6 +404,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;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] block: check bio split for unaligned bvec
2026-06-12 22:32 [PATCH] block: check bio split for unaligned bvec Keith Busch
@ 2026-06-13 12:36 ` Jens Axboe
2026-06-15 9:37 ` Carlos Maiolino
2026-06-15 13:35 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2026-06-13 12:36 UTC (permalink / raw)
To: linux-block, Keith Busch; +Cc: hch, Keith Busch, Carlos Maiolino
On Fri, 12 Jun 2026 15:32:04 -0700, Keith Busch wrote:
> 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.
>
>
> [...]
Applied, thanks!
[1/1] block: check bio split for unaligned bvec
commit: 9b0c3673c88588d613d8f09f5931b2b466c6a83d
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: check bio split for unaligned bvec
2026-06-12 22:32 [PATCH] block: check bio split for unaligned bvec Keith Busch
2026-06-13 12:36 ` Jens Axboe
@ 2026-06-15 9:37 ` Carlos Maiolino
2026-06-15 13:35 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Carlos Maiolino @ 2026-06-15 9:37 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-block, axboe, hch, Keith Busch
On Fri, Jun 12, 2026 at 03:32:04PM -0700, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> 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 <cem@kernel.org>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
Jens was quick enough but if needed anyway, I've tested this locally,
so:
Tested-by: Carlos Maiolino <cem@kernel.org>
Reviewed-by: Carlos Maiolino <cem@kernel.org>
> ---
> block/blk.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/block/blk.h b/block/blk.h
> index 1a2d9101bba04..004048fa0c5a8 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -404,6 +404,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;
> }
>
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: check bio split for unaligned bvec
2026-06-12 22:32 [PATCH] block: check bio split for unaligned bvec Keith Busch
2026-06-13 12:36 ` Jens Axboe
2026-06-15 9:37 ` Carlos Maiolino
@ 2026-06-15 13:35 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-06-15 13:35 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-block, axboe, Keith Busch, Carlos Maiolino
On Fri, Jun 12, 2026 at 03:32:04PM -0700, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> 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.
This fix itself looks good, but we'll also need something similar
for bio-based drivers that never call into the splitting helper.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-15 13:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-12 22:32 [PATCH] block: check bio split for unaligned bvec Keith Busch
2026-06-13 12:36 ` Jens Axboe
2026-06-15 9:37 ` Carlos Maiolino
2026-06-15 13:35 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.