linux-stable/drivers/thermal
Aaron Hill 311acb0a9f drivers: thermal: int340x_thermal: Fix sysfs race condition
[ Upstream commit 129699bb8c ]

Changes since V1:
* Use dev_info instead of printk
* Use dev_warn instead of BUG_ON

Previously, sysfs_create_group was called before all initialization had
fully run - specifically, before pci_set_drvdata was called. Since the
sysctl group is visible to userspace as soon as sysfs_create_group
returns, a small window of time existed during which a process could read
from an uninitialized/partially-initialized device.

This commit moves the creation of the sysctl group to after all
initialized is completed. This ensures that it's impossible for
userspace to read from a sysctl file before initialization has fully
completed.

To catch any future regressions, I've added a check to ensure
that proc_thermal_emum_mode is never PROC_THERMAL_NONE when a process
tries to read from a sysctl file. Previously, the aforementioned race
condition could result in the 'else' branch
running while PROC_THERMAL_NONE was set,
leading to a null pointer deference.

Signed-off-by: Aaron Hill <aa1ronham@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-03-05 17:57:05 +01:00
..
int340x_thermal drivers: thermal: int340x_thermal: Fix sysfs race condition 2019-03-05 17:57:05 +01:00
qcom
samsung thermal: exynos: fix setting rising_threshold for Exynos5433 2018-08-03 07:55:23 +02:00
st
tegra
ti-soc-thermal
Kconfig thermal: fix INTEL_SOC_DTS_IOSF_CORE dependencies 2018-02-25 11:05:52 +01:00
Makefile
armada_thermal.c
clock_cooling.c
cpu_cooling.c
db8500_cpufreq_cooling.c
db8500_thermal.c
devfreq_cooling.c
dove_thermal.c
fair_share.c
gov_bang_bang.c
hisi_thermal.c thermal/drivers/hisi: Fix multiple alarm interrupts firing 2017-12-25 14:23:46 +01:00
imx_thermal.c thermal: imx: Fix race condition in imx_thermal_probe() 2018-04-24 09:34:14 +02:00
intel_bxt_pmic_thermal.c
intel_pch_thermal.c
intel_powerclamp.c
intel_quark_dts_thermal.c
intel_soc_dts_iosf.c
intel_soc_dts_iosf.h
intel_soc_dts_thermal.c
kirkwood_thermal.c
max77620_thermal.c
mtk_thermal.c
of-thermal.c thermal: of-thermal: disable passive polling when thermal zone is disabled 2018-10-03 17:01:51 -07:00
power_allocator.c thermal: power_allocator: fix one race condition issue for thermal_instances list 2018-04-13 19:48:08 +02:00
qcom-spmi-temp-alarm.c
qoriq_thermal.c
rcar_thermal.c
rockchip_thermal.c
spear_thermal.c
step_wise.c thermal/drivers/step_wise: Fix temperature regulation misbehavior 2017-12-20 10:07:30 +01:00
tango_thermal.c
thermal-generic-adc.c thermal: generic-adc: Fix adc to temp interpolation 2019-02-12 19:44:59 +01:00
thermal_core.c Thermal: do not clear passive state during system sleep 2019-02-12 19:44:53 +01:00
thermal_core.h
thermal_hwmon.c
thermal_hwmon.h thermal: hwmon: inline helpers when CONFIG_THERMAL_HWMON is not set 2019-02-12 19:44:59 +01:00
user_space.c
x86_pkg_temp_thermal.c