diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-10-28 03:01:59 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-10-28 03:01:59 +0300 |
commit | 2dc4e0f45593abc53d58d0073b3b314f864c522b (patch) | |
tree | 98ae9b3133303a5c9ee48c655f8947ec269b33ae | |
parent | 832328c9f8aa4b41423f29a53ba7080eb7214976 (diff) | |
parent | 2dd710d476f2f1f6eaca884f625f69ef4389ed40 (diff) | |
download | linux-2dc4e0f45593abc53d58d0073b3b314f864c522b.tar.xz |
Merge tag 'block-6.6-2023-10-27' of git://git.kernel.dk/linux
Pull block fix from Jens Axboe:
"Just a single fix for a potential divide-by-zero, introduced in this
cycle"
* tag 'block-6.6-2023-10-27' of git://git.kernel.dk/linux:
blk-throttle: check for overflow in calculate_bytes_allowed
-rw-r--r-- | block/blk-throttle.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 38a881cf97d0..13e4377a8b28 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); } |