From 2ee0cc79ef75a20e3854b134b58297ac7d46dc3e Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 25 Aug 2020 20:03:25 +0800 Subject: [PATCH] blk-iocost: fix incorrect vtime comparison in iocg_is_idle() mainline inclusion from mainline-5.6-rc6 commit dcd6589b11d3b1e71f516a87a7b9646ed356b4c0 category: feature bugzilla: 38688 CVE: NA --------------------------- vtimes may wrap and time_before/after64() should be used to determine whether a given vtime is before or after another. iocg_is_idle() was incorrectly using plain "<" comparison do determine whether done_vtime is before vtime. Here, the only thing we're interested in is whether done_vtime matches vtime which indicates that there's nothing in flight. Let's test for inequality instead. Signed-off-by: Tejun Heo Fixes: 7caa47151ab2 ("blkcg: implement blk-iocost") Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Jens Axboe Signed-off-by: Yu Kuai Reviewed-by: Hou Tao Signed-off-by: Yang Yingliang --- block/blk-iocost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 466f1fff00ec..64bd98c5b970 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -1318,7 +1318,7 @@ static bool iocg_is_idle(struct ioc_gq *iocg) return false; /* is something in flight? */ - if (atomic64_read(&iocg->done_vtime) < atomic64_read(&iocg->vtime)) + if (atomic64_read(&iocg->done_vtime) != atomic64_read(&iocg->vtime)) return false; return true; -- GitLab