[folded-merged] mm-fix-div-by-zero-in-bdi_ratio_from_pages-v3.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The quilt patch titled
     Subject: mm-fix-div-by-zero-in-bdi_ratio_from_pages-v3
has been removed from the -mm tree.  Its filename was
     mm-fix-div-by-zero-in-bdi_ratio_from_pages-v3.patch

This patch was dropped because it was folded into mm-fix-div-by-zero-in-bdi_ratio_from_pages.patch

------------------------------------------------------
From: Stefan Roesch <shr@xxxxxxxxxxxx>
Subject: mm-fix-div-by-zero-in-bdi_ratio_from_pages-v3
Date: Wed, 8 Jan 2025 22:34:11 -0800

During testing it has been detected, that it is possible to get div by
zero error in bdi_set_min_bytes. The error is caused by the function
bdi_ratio_from_pages(). bdi_ratio_from_pages() calls
global_dirty_limits. If the dirty threshold is 0, the div by zero is
raised. This can happen if the root user is setting:

echo 0 > /proc/sys/vm/dirty_ratio

The following is a test case:

echo 0 > /proc/sys/vm/dirty_ratio
cd /sys/class/bdi/<device>
echo 1 > strict_limit
echo 8192 > min_bytes

==> error is raised.

The problem is addressed by returning -EINVAL if dirty_ratio or
dirty_bytes is set to 0.

Link: https://lkml.kernel.org/r/20250109063411.6591-1-shr@xxxxxxxxxxxx
Reported-by: cheung wall <zzqq0103.hey@xxxxxxxxx>
Closes: https://lore.kernel.org/linux-mm/87pll35yd0.fsf@xxxxxxxxxxxx/T/#t
Signed-off-by: Stefan Roesch <shr@xxxxxxxxxxxx>
Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/page-writeback.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

--- a/mm/page-writeback.c~mm-fix-div-by-zero-in-bdi_ratio_from_pages-v3
+++ a/mm/page-writeback.c
@@ -792,15 +792,15 @@ int bdi_set_min_bytes(struct backing_dev
 {
 	int ret;
 	unsigned long pages = min_bytes >> PAGE_SHIFT;
-	unsigned long min_ratio;
+	long min_ratio;
 
 	ret = bdi_check_pages_limit(pages);
 	if (ret)
 		return ret;
 
 	min_ratio = bdi_ratio_from_pages(pages);
-	if (min_ratio == -EINVAL)
-		return -EINVAL;
+	if (min_ratio < 0)
+		return min_ratio;
 	return __bdi_set_min_ratio(bdi, min_ratio);
 }
 
@@ -813,15 +813,15 @@ int bdi_set_max_bytes(struct backing_dev
 {
 	int ret;
 	unsigned long pages = max_bytes >> PAGE_SHIFT;
-	unsigned long max_ratio;
+	long max_ratio;
 
 	ret = bdi_check_pages_limit(pages);
 	if (ret)
 		return ret;
 
 	max_ratio = bdi_ratio_from_pages(pages);
-	if (max_ratio == -EINVAL)
-		return -EINVAL;
+	if (max_ratio < 0)
+		return max_ratio;
 	return __bdi_set_max_ratio(bdi, max_ratio);
 }
 
_

Patches currently in -mm which might be from shr@xxxxxxxxxxxx are

mm-fix-div-by-zero-in-bdi_ratio_from_pages.patch





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux