From: Wen Yang wenyang@linux.alibaba.com
mainline inclusion from mainline-5.5-rc7 commit 0a5d1a7f64702c351d1f47ef159a0df8c71be0b0 category: bugfix bugzilla: 28317 CVE: NA
------------------------------------------------- Use div64_ul() instead of do_div() if the divisor is unsigned long, to avoid truncation to 32-bit on 64-bit platforms.
Link: http://lkml.kernel.org/r/20200102081442.8273-4-wenyang@linux.alibaba.com Signed-off-by: Wen Yang wenyang@linux.alibaba.com Reviewed-by: Andrew Morton akpm@linux-foundation.org Cc: Qian Cai cai@lca.pw Cc: Tejun Heo tj@kernel.org Cc: Jens Axboe axboe@kernel.dk Signed-off-by: Andrew Morton akpm@linux-foundation.org Signed-off-by: Linus Torvalds torvalds@linux-foundation.org (cherry picked from commit 0a5d1a7f64702c351d1f47ef159a0df8c71be0b0) Signed-off-by: Kefeng Wang wangkefeng.wang@huawei.com Reviewed-by: Jing Xiangfeng jingxiangfeng@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- mm/page-writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 566df02..43e8393 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1101,7 +1101,7 @@ static void wb_update_write_bandwidth(struct bdi_writeback *wb, bw = written - min(written, wb->written_stamp); bw *= HZ; if (unlikely(elapsed > period)) { - do_div(bw, elapsed); + bw = div64_ul(bw, elapsed); avg = bw; goto out; }