[Devel] [PATCH RHEL9 COMMIT] dm-qcow2: fix bvec iteration macro that can get into an endless loop

Konstantin Khorenko khorenko at virtuozzo.com
Wed Sep 4 15:28:21 MSK 2024


The commit is pushed to "branch-rh9-5.14.0-427.33.1.vz9.72.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.33.1.vz9.72.1
------>
commit 1c5707be637d6ecb738659a408ee8a6ff5b84958
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Mon Sep 2 19:40:31 2024 +0300

    dm-qcow2: fix bvec iteration macro that can get into an endless loop
    
    qcow2_for_each_bvec tries to advance the bvec with bv_len but
    if bv_len is zero it goes into an endless loop.
    To fix this check for non zero bv_len, there is already check
    for size.
    
    https://virtuozzo.atlassian.net/browse/PSBM-157999
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
    
    Feature: dm-qcow2: block device over QCOW2 files driver
---
 drivers/md/dm-qcow2-map.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 137fb9a270cd..b40115b0fc5e 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -25,8 +25,8 @@
 
 #define qcow2_for_each_bvec(iter, bv, start_iter, from_bv)			\
 	for (iter = start_iter;							\
-	     iter.bi_size && ((bv = mp_bvec_iter_bvec(from_bv, iter)), 1);	\
-	     bvec_iter_advance(from_bv, &iter, bv.bv_len))
+	     iter.bi_size && ((bv = mp_bvec_iter_bvec(from_bv, iter)), 1)	\
+	     && bv.bv_len; bvec_iter_advance(from_bv, &iter, bv.bv_len))
 
 struct qcow2_map_item {
 	/*


More information about the Devel mailing list