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

Kirill Tkhai ktkhai at virtuozzo.com
Tue Nov 10 17:47:32 MSK 2020


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>
---
 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 5528e86aab43..8f09ab083315 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