diff options
author | Zhang Rui <rui.zhang@intel.com> | 2023-03-08 11:07:11 +0800 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2023-03-17 19:22:44 +0100 |
commit | 2a96243e22f880ad53a977e09680aee276dc50b5 (patch) | |
tree | 9231cdbd69be3172dd812b8a8a10bf382930cab5 /drivers/thermal/thermal_netlink.c | |
parent | eeac8ede17557680855031c6f305ece2378af326 (diff) |
thermal: intel: x86_pkg_temp_thermal: Add lower bound check for sysfs input
When setting a trip point temperature from sysfs, there is an upper
bound check on the user input, but no lower bound check.
As hardware register has 7 bits for a trip point temperature, the offset
to tj_max of the input temperature must be equal to/less than 0x7f.
Or else,
1. bogus temperature is updated into the trip temperature bits.
2. the upper bits of the register can be polluted.
For example,
$ rdmsr 0x1b2
2000003
$ echo -180000 > /sys/class/thermal/thermal_zone1/trip_point_1_temp
$ rdmsr 0x1b2
3980003
Not only the trip point temp is set to 76C on this platform (tj_max is
100), the Power Notification (Bit 24) is also enabled erronously.
Fix the problem by adding lower bound check for sysfs input.
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/all/add7a378-4d50-4ba1-81d3-a0c17db25a0b@kili.mountain/
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/thermal/thermal_netlink.c')
0 files changed, 0 insertions, 0 deletions