Commit 70398e31 authored by Chao Qin's avatar Chao Qin Committed by Jialin Zhang
Browse files

powercap: intel_rapl: fix UBSAN shift-out-of-bounds issue

stable inclusion
from stable-v5.10.150
commit 708b9abe1b4a2f050a483db4b7edfc446b13df1f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6D0XA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=708b9abe1b4a2f050a483db4b7edfc446b13df1f



--------------------------------

[ Upstream commit 2d935400 ]

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: default avatarChao Qin <chao.qin@intel.com>
Acked-by: default avatarZhang Rui <rui.zhang@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parent 8ee5323f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment