Thread (42 messages) 42 messages, 9 authors, 2025-09-02

Re: [PATCHv3 1/8] block: check for valid bio while splitting

From: Christoph Hellwig <hch@lst.de>
Date: 2025-08-25 07:35:50
Also in: linux-fsdevel, linux-xfs, lkml

On Tue, Aug 19, 2025 at 09:49:15AM -0700, Keith Busch wrote:
quoted hunk ↗ jump to hunk
 		/*
 		 * If the queue doesn't support SG gaps and adding this
 		 * offset would create a gap, disallow it.
@@ -339,8 +343,16 @@ int bio_split_rw_at(struct bio *bio, const struct queue_limits *lim,
 	 * Individual bvecs might not be logical block aligned. Round down the
 	 * split size so that each bio is properly block size aligned, even if
 	 * we do not use the full hardware limits.
+	 *
+	 * Misuse may submit a bio that can't be split into a valid io. There
+	 * may either be too many discontiguous vectors for the max segments
+	 * limit, or contain virtual boundary gaps without having a valid block
+	 * sized split. Catch that condition by checking for a zero byte
+	 * result.
 	 */
 	bytes = ALIGN_DOWN(bytes, bio_split_alignment(bio, lim));
+	if (!bytes)
If this is just misuse it could be a WARN_ON_ONCE.  But I think we
can also trigger this when validating passthrough commands that need
to be built to hardware limits.  So maybe don't speak about misuse
here?

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help