Merge tag 'block-6.6-2023-10-27' of git://git.kernel.dk/linux
Merge commit. Changes below are compared with the first parent: 832328c9.
Changes
1 files changed · +6 −0
| File | Status | Add | Del | Content |
|---|---|---|---|---|
| block/blk-throttle.c | modified | +6 | −0 | View file |
block/blk-throttle.c
View filediff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 38a881c..13e4377 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -723,6 +723,12 @@ static unsigned int calculate_io_allowed(u32 iops_limit,
static u64 calculate_bytes_allowed(u64 bps_limit, unsigned long jiffy_elapsed)
{
+ /*
+ * Can result be wider than 64 bits?
+ * We check against 62, not 64, due to ilog2 truncation.
+ */
+ if (ilog2(bps_limit) + ilog2(jiffy_elapsed) - ilog2(HZ) > 62)
+ return U64_MAX;
return mul_u64_u64_div_u64(bps_limit, (u64)jiffy_elapsed, (u64)HZ);
}