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

Submitted by Vasily Averin on Nov. 11, 2020, 6:46 a.m.

Details

Message ID 202011110646.0AB6kMNZ012192@vz7build.vvs.sw.ru
State New
Series "ploop: Fix crash in purge_lru_warn()"
Headers show

Commit Message

Vasily Averin Nov. 11, 2020, 6:46 a.m.
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@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@virtuozzo.com>
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    Reviewed-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 drivers/block/ploop/io_direct_map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

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",