[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200102081442.8273-2-wenyang@linux.alibaba.com>
Date: Thu, 2 Jan 2020 16:14:40 +0800
From: Wen Yang <wenyang@...ux.alibaba.com>
To: Andrew Morton <akpm@...ux-foundation.org>, Qian Cai <cai@....pw>
Cc: xlpang@...ux.alibaba.com, Wen Yang <wenyang@...ux.alibaba.com>,
Tejun Heo <tj@...nel.org>, Jens Axboe <axboe@...nel.dk>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] mm/page-writeback.c: avoid potential division by zero in wb_min_max_ratio()
The variables 'min' and 'max' are unsigned long and
do_div truncates them to 32 bits, which means it can test
non-zero and be truncated to zero for division.
Fix this issue by using div64_ul() instead.
Fixes: 693108a8a667 ("writeback: make bdi->min/max_ratio handling cgroup writeback aware")
Signed-off-by: Wen Yang <wenyang@...ux.alibaba.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Qian Cai <cai@....pw>
Cc: Tejun Heo <tj@...nel.org>
Cc: Jens Axboe <axboe@...nel.dk>
Cc: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org
---
mm/page-writeback.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 50055d2..2d658b2 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -201,11 +201,11 @@ static void wb_min_max_ratio(struct bdi_writeback *wb,
if (this_bw < tot_bw) {
if (min) {
min *= this_bw;
- do_div(min, tot_bw);
+ min = div64_ul(min, tot_bw);
}
if (max < 100) {
max *= this_bw;
- do_div(max, tot_bw);
+ max = div64_ul(max, tot_bw);
}
}
--
1.8.3.1
Powered by blists - more mailing lists