This is a note to let you know that I've just added the patch titled blk-throttle: check for overflow in calculate_bytes_allowed to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: blk-throttle-check-for-overflow-in-calculate_bytes_allowed.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 2dd710d476f2f1f6eaca884f625f69ef4389ed40 Mon Sep 17 00:00:00 2001 From: Khazhismel Kumykov <khazhy@xxxxxxxxxxxx> Date: Fri, 20 Oct 2023 15:36:17 -0700 Subject: blk-throttle: check for overflow in calculate_bytes_allowed From: Khazhismel Kumykov <khazhy@xxxxxxxxxxxx> commit 2dd710d476f2f1f6eaca884f625f69ef4389ed40 upstream. Inexact, we may reject some not-overflowing values incorrectly, but they'll be on the order of exabytes allowed anyways. This fixes divide error crash on x86 if bps_limit is not configured or is set too high in the rare case that jiffy_elapsed is greater than HZ. Fixes: e8368b57c006 ("blk-throttle: use calculate_io/bytes_allowed() for throtl_trim_slice()") Fixes: 8d6bbaada2e0 ("blk-throttle: prevent overflow while calculating wait time") Signed-off-by: Khazhismel Kumykov <khazhy@xxxxxxxxxx> Acked-by: Tejun Heo <tj@xxxxxxxxxx> Link: https://lore.kernel.org/r/20231020223617.2739774-1-khazhy@xxxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- block/blk-throttle.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -723,6 +723,12 @@ static unsigned int calculate_io_allowed 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); } Patches currently in stable-queue which might be from khazhy@xxxxxxxxxxxx are queue-6.1/blk-throttle-check-for-overflow-in-calculate_bytes_allowed.patch