From: Tejun Heo <tj@kernel.org>
To: Konstantin Ovsepian <ovs@ovs.to>
Cc: josef@toxicpanda.com, axboe@kernel.dk, cgroups@vger.kernel.org,
linux-block@vger.kernel.org, leitao@debian.org, ovs@meta.com
Subject: Re: [PATCH] blk_iocost: fix more out of bound shifts
Date: Mon, 26 Aug 2024 08:35:56 -1000 [thread overview]
Message-ID: <ZszLDKNSPsSAEXxr@slm.duckdns.org> (raw)
In-Reply-To: <20240822154137.2627818-1-ovs@ovs.to>
On Thu, Aug 22, 2024 at 08:41:36AM -0700, Konstantin Ovsepian wrote:
> Recently running UBSAN caught few out of bound shifts in the
> ioc_forgive_debts() function:
>
> UBSAN: shift-out-of-bounds in block/blk-iocost.c:2142:38
> shift exponent 80 is too large for 64-bit type 'u64' (aka 'unsigned long
> long')
> ...
> UBSAN: shift-out-of-bounds in block/blk-iocost.c:2144:30
> shift exponent 80 is too large for 64-bit type 'u64' (aka 'unsigned long
> long')
> ...
> Call Trace:
> <IRQ>
> dump_stack_lvl+0xca/0x130
> __ubsan_handle_shift_out_of_bounds+0x22c/0x280
> ? __lock_acquire+0x6441/0x7c10
> ioc_timer_fn+0x6cec/0x7750
> ? blk_iocost_init+0x720/0x720
> ? call_timer_fn+0x5d/0x470
> call_timer_fn+0xfa/0x470
> ? blk_iocost_init+0x720/0x720
> __run_timer_base+0x519/0x700
> ...
>
> Actual impact of this issue was not identified but I propose to fix the
> undefined behaviour.
> The proposed fix to prevent those out of bound shifts consist of
> precalculating exponent before using it the shift operations by taking
> min value from the actual exponent and maximum possible number of bits.
>
> Reported-by: Breno Leitao <leitao@debian.org>
> Signed-off-by: Konstantin Ovsepian <ovs@ovs.to>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
next prev parent reply other threads:[~2024-08-26 18:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 15:41 [PATCH] blk_iocost: fix more out of bound shifts Konstantin Ovsepian
2024-08-26 18:35 ` Tejun Heo [this message]
2024-08-26 20:13 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZszLDKNSPsSAEXxr@slm.duckdns.org \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=josef@toxicpanda.com \
--cc=leitao@debian.org \
--cc=linux-block@vger.kernel.org \
--cc=ovs@meta.com \
--cc=ovs@ovs.to \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox