[Devel] [PATCH RHEL7 COMMIT] ploop: Fix crash in purge_lru_warn()

Vasily Averin vvs at virtuozzo.com
Wed Nov 11 09:46:22 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.43
------>
commit a2ed38f07f597d7a92dcff9e1489eebc2938d325
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Wed Nov 11 09:46:22 2020 +0300

    ploop: Fix crash in purge_lru_warn()
    
    do_div() works wrong in case of the second argument is long.
    We don't need remainder, so we don't need do_div() at all.
    
    https://jira.sw.ru/browse/PSBM-122035
    
    Reported-by: Evgenii Shatokhin <eshatokhin at virtuozzo.com>
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    Reviewed-by: Evgenii Shatokhin <eshatokhin at virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 drivers/block/ploop/io_direct_map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/ploop/io_direct_map.c b/drivers/block/ploop/io_direct_map.c
index 5528e86..8f09ab0 100644
--- a/drivers/block/ploop/io_direct_map.c
+++ b/drivers/block/ploop/io_direct_map.c
@@ -377,7 +377,7 @@ static inline void purge_lru_warn(struct extent_map_tree *tree)
 	loff_t ratio = i_size_read(tree->mapping->host) * 100;
 	long images_size = atomic_long_read(&ploop_io_images_size) ? : 1;
 
-	do_div(ratio, images_size);
+	ratio /= images_size;
 
 	printk(KERN_WARNING "Purging lru entry from extent tree for inode %ld "
 	       "(map_size=%d ratio=%lld%%)\n",


More information about the Devel mailing list