linux/drivers/thermal/intel
Zhang Rui 2a96243e22 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>
2023-03-17 19:22:44 +01:00
..
int340x_thermal thermal: intel: int340x: processor_thermal: Fix deadlock 2023-03-03 20:34:49 +01:00
intel_bxt_pmic_thermal.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
intel_hfi.c thermal: Remove core header inclusion from drivers 2023-02-15 17:29:48 +01:00
intel_hfi.h thermal: intel: hfi: Enable notification interrupt 2022-02-03 19:50:49 +01:00
intel_menlow.c thermal: intel: menlow: Update function descriptions 2023-01-18 21:02:36 +01:00
intel_pch_thermal.c thermal: intel: intel_pch: Drop struct board_info 2023-02-02 21:06:24 +01:00
intel_powerclamp.c thermal: intel: powerclamp: Add two module parameters 2023-02-09 21:01:06 +01:00
intel_quark_dts_thermal.c thermal: intel: quark_dts: fix error pointer dereference 2023-03-01 19:28:57 +01:00
intel_soc_dts_iosf.c thermal: intel: Fix unsigned comparison with less than zero 2023-01-10 20:33:26 +01:00
intel_soc_dts_iosf.h thermal: intel: intel_soc_dts_iosf: Utilize for_each_set_clump8 macro 2019-12-04 19:44:12 -08:00
intel_soc_dts_thermal.c thermal: Convert to new X86 CPU match macros 2020-03-24 21:33:53 +01:00
intel_tcc_cooling.c thermal/intel/intel_tcc_cooling: Use Intel TCC library 2022-12-30 19:57:38 +01:00
intel_tcc.c thermal/intel: Introduce Intel TCC library 2022-12-30 19:57:38 +01:00
Kconfig thermal: intel: BXT_PMIC: select REGMAP instead of depending on it 2023-03-01 19:32:00 +01:00
Makefile thermal/intel: Introduce Intel TCC library 2022-12-30 19:57:38 +01:00
therm_throt.c thermal: intel: Don't set HFI status bit to 1 2022-12-14 14:50:15 +01:00
thermal_interrupt.h thermal: intel: Protect clearing of thermal status bits 2022-11-23 20:09:06 +01:00
x86_pkg_temp_thermal.c thermal: intel: x86_pkg_temp_thermal: Add lower bound check for sysfs input 2023-03-17 19:22:44 +01:00