]> git.baikalelectronics.ru Git - kernel.git/commit
powercap: intel_rapl: fix UBSAN shift-out-of-bounds issue
authorChao Qin <chao.qin@intel.com>
Tue, 20 Sep 2022 06:08:26 +0000 (14:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:47 +0000 (13:22 +0200)
commitd9edd5ec780fc4bfe613740a1961d2c18cc91294
tree9fdce0c58e6851406c611774fb1ebed287da1f40
parentcbe11c59de404e97fa505913d579a8fc244a0379
powercap: intel_rapl: fix UBSAN shift-out-of-bounds issue

[ Upstream commit 51738d1c3a4dfd4090df35a54f63109cf0c15ab7 ]

When value < time_unit, the parameter of ilog2() will be zero and
the return value is -1. u64(-1) is too large for shift exponent
and then will trigger shift-out-of-bounds:

shift exponent 18446744073709551615 is too large for 32-bit type 'int'
Call Trace:
 rapl_compute_time_window_core
 rapl_write_data_raw
 set_time_window
 store_constraint_time_window_us

Signed-off-by: Chao Qin <chao.qin@intel.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/powercap/intel_rapl_common.c