[Devel] [RFC PATCH vz9 v6 55/62] dm-ploop: catch if we try to advance pio past bio end

Alexander Atanasov alexander.atanasov at virtuozzo.com
Fri Dec 6 00:56:28 MSK 2024


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 54aaf648d16e..c47fa48f1da6 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -267,8 +267,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