[Devel] [PATCH vz9 v1 49/63] dm-ploop: catch if we try to advance pio past bio end

Alexander Atanasov alexander.atanasov at virtuozzo.com
Fri Jan 24 18:36:23 MSK 2025


Do not advance pio past bio end - this should not happen
but try to catch and log it as an error.

https://virtuozzo.atlassian.net/browse/VSTOR-91821
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 7d531564b24c..fc2d99c3a8d0 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -271,8 +271,17 @@ static void ploop_pio_advance(struct pio *pio, unsigned int bytes)
 
 	if (op_is_discard(pio->bi_op))
 		iter->bi_size -= bytes;
-	else
+	else {
+		if (bytes > iter->bi_size) {
+			struct ploop *ploop = pio->ploop;
+
+			PL_ERR("advance past bio end\n");
+			bytes = iter->bi_size;
+			if (!bytes)
+				return;
+		}
 		bvec_iter_advance(pio->bi_io_vec, iter, bytes);
+	}
 }
 
 static struct pio *ploop_split_and_chain_pio(struct ploop *ploop,
-- 
2.43.0



More information about the Devel mailing list