linux-stable/drivers/thermal/int340x_thermal
Aaron Hill a99e0377cc 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:58:48 +01:00
..
acpi_thermal_rel.c treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
acpi_thermal_rel.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
int340x_thermal_zone.c - Error path bug fix for overflow tests (Dan) 2018-06-12 18:28:00 -07:00
int340x_thermal_zone.h thermal: int340x: New Interface to read trip and notify 2016-09-27 14:37:14 +08:00
int3400_thermal.c thermal: int3400_thermal: fix error handling in int3400_thermal_probe() 2018-01-13 21:19:25 +08:00
int3402_thermal.c thermal: int340x: New Interface to read trip and notify 2016-09-27 14:37:14 +08:00
int3403_thermal.c thermal: int3403_thermal: Fix NULL pointer deref on module load / probe 2018-04-24 20:50:43 +08:00
int3406_thermal.c Thermal: int3406_thermal: fix thermal sysfs I/F 2017-09-01 09:03:29 +08:00
Kconfig Thermal / ACPI / video: add INT3406 thermal driver 2016-05-11 02:15:31 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
processor_thermal_device.c drivers: thermal: int340x_thermal: Fix sysfs race condition 2019-03-05 17:58:48 +01:00