1
0
Fork 0
alistair23-linux/drivers/thermal
Wei Wang 7d967912c0 thermal: Fix deadlock in thermal thermal_zone_device_check
commit 163b00cde7 upstream.

1851799e1d ("thermal: Fix use-after-free when unregistering thermal zone
device") changed cancel_delayed_work to cancel_delayed_work_sync to avoid
a use-after-free issue. However, cancel_delayed_work_sync could be called
insides the WQ causing deadlock.

[54109.642398] c0   1162 kworker/u17:1   D    0 11030      2 0x00000000
[54109.642437] c0   1162 Workqueue: thermal_passive_wq thermal_zone_device_check
[54109.642447] c0   1162 Call trace:
[54109.642456] c0   1162  __switch_to+0x138/0x158
[54109.642467] c0   1162  __schedule+0xba4/0x1434
[54109.642480] c0   1162  schedule_timeout+0xa0/0xb28
[54109.642492] c0   1162  wait_for_common+0x138/0x2e8
[54109.642511] c0   1162  flush_work+0x348/0x40c
[54109.642522] c0   1162  __cancel_work_timer+0x180/0x218
[54109.642544] c0   1162  handle_thermal_trip+0x2c4/0x5a4
[54109.642553] c0   1162  thermal_zone_device_update+0x1b4/0x25c
[54109.642563] c0   1162  thermal_zone_device_check+0x18/0x24
[54109.642574] c0   1162  process_one_work+0x3cc/0x69c
[54109.642583] c0   1162  worker_thread+0x49c/0x7c0
[54109.642593] c0   1162  kthread+0x17c/0x1b0
[54109.642602] c0   1162  ret_from_fork+0x10/0x18
[54109.643051] c0   1162 kworker/u17:2   D    0 16245      2 0x00000000
[54109.643067] c0   1162 Workqueue: thermal_passive_wq thermal_zone_device_check
[54109.643077] c0   1162 Call trace:
[54109.643085] c0   1162  __switch_to+0x138/0x158
[54109.643095] c0   1162  __schedule+0xba4/0x1434
[54109.643104] c0   1162  schedule_timeout+0xa0/0xb28
[54109.643114] c0   1162  wait_for_common+0x138/0x2e8
[54109.643122] c0   1162  flush_work+0x348/0x40c
[54109.643131] c0   1162  __cancel_work_timer+0x180/0x218
[54109.643141] c0   1162  handle_thermal_trip+0x2c4/0x5a4
[54109.643150] c0   1162  thermal_zone_device_update+0x1b4/0x25c
[54109.643159] c0   1162  thermal_zone_device_check+0x18/0x24
[54109.643167] c0   1162  process_one_work+0x3cc/0x69c
[54109.643177] c0   1162  worker_thread+0x49c/0x7c0
[54109.643186] c0   1162  kthread+0x17c/0x1b0
[54109.643195] c0   1162  ret_from_fork+0x10/0x18
[54109.644500] c0   1162 cat             D    0  7766      1 0x00000001
[54109.644515] c0   1162 Call trace:
[54109.644524] c0   1162  __switch_to+0x138/0x158
[54109.644536] c0   1162  __schedule+0xba4/0x1434
[54109.644546] c0   1162  schedule_preempt_disabled+0x80/0xb0
[54109.644555] c0   1162  __mutex_lock+0x3a8/0x7f0
[54109.644563] c0   1162  __mutex_lock_slowpath+0x14/0x20
[54109.644575] c0   1162  thermal_zone_get_temp+0x84/0x360
[54109.644586] c0   1162  temp_show+0x30/0x78
[54109.644609] c0   1162  dev_attr_show+0x5c/0xf0
[54109.644628] c0   1162  sysfs_kf_seq_show+0xcc/0x1a4
[54109.644636] c0   1162  kernfs_seq_show+0x48/0x88
[54109.644656] c0   1162  seq_read+0x1f4/0x73c
[54109.644664] c0   1162  kernfs_fop_read+0x84/0x318
[54109.644683] c0   1162  __vfs_read+0x50/0x1bc
[54109.644692] c0   1162  vfs_read+0xa4/0x140
[54109.644701] c0   1162  SyS_read+0xbc/0x144
[54109.644708] c0   1162  el0_svc_naked+0x34/0x38
[54109.845800] c0   1162 D 720.000s 1->7766->7766 cat [panic]

Fixes: 1851799e1d ("thermal: Fix use-after-free when unregistering thermal zone device")
Cc: stable@vger.kernel.org
Signed-off-by: Wei Wang <wvw@google.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-12-13 08:43:21 +01:00
..
broadcom Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
intel Merge branch 'for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux 2019-09-27 11:35:13 -07:00
qcom drivers: thermal: qcom: tsens: Fix memory leak from qfprom read 2019-08-28 21:05:08 +08:00
samsung treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
st treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
tegra thermal: tegra: Fix a typo 2019-08-28 17:56:45 +08:00
ti-soc-thermal treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 336 2019-06-05 17:37:07 +02:00
Kconfig thermal: db8500: Finalize device tree conversion 2019-09-24 22:54:49 -07:00
Makefile thermal: Introduce Amazon's Annapurna Labs Thermal Driver 2019-05-14 07:00:26 -07:00
armada_thermal.c thermal: armada: Fix -Wshift-negative-value 2019-08-28 16:41:02 +08:00
clock_cooling.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 285 2019-06-05 17:36:37 +02:00
cpu_cooling.c cpufreq: Use per-policy frequency QoS 2019-10-21 02:05:21 +02:00
da9062-thermal.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
db8500_thermal.c thermal: db8500: Rewrite to be a pure OF sensor 2019-09-24 22:59:22 -07:00
devfreq_cooling.c trace: thermal: add another parameter 'power' to the tracing function 2017-05-05 15:54:45 +08:00
dove_thermal.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
fair_share.c thermal/drivers/core: Use governor table to initialize 2019-06-27 21:22:14 +08:00
gov_bang_bang.c thermal/drivers/core: Use governor table to initialize 2019-06-27 21:22:14 +08:00
hisi_thermal.c thermal/drivers/hisi: Fix number of sensors on hi3660 2018-12-10 20:13:09 -08:00
imx_thermal.c thermal: imx: save one condition block for normal case of nvmem initialization 2019-01-02 04:47:12 -08:00
kirkwood_thermal.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
max77620_thermal.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 422 2019-06-05 17:37:15 +02:00
mtk_thermal.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
of-thermal.c of: thermal: Improve print information 2019-05-13 20:35:34 -07:00
power_allocator.c thermal/drivers/core: Use governor table to initialize 2019-06-27 21:22:14 +08:00
qoriq_thermal.c thermal: qoriq: Use __maybe_unused instead of #if CONFIG_PM_SLEEP 2019-08-28 16:33:27 +08:00
rcar_gen3_thermal.c thermal: rcar_gen3_thermal: Replace devm_add_action() followed by failure action with devm_add_action_or_reset() 2019-08-28 17:51:26 +08:00
rcar_thermal.c thermal: rcar_thermal: update calculation formula for R-Car Gen3 SoCs 2019-05-14 07:00:42 -07:00
rockchip_thermal.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
spear_thermal.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
step_wise.c thermal/drivers/core: Use governor table to initialize 2019-06-27 21:22:14 +08:00
tango_thermal.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
thermal-generic-adc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
thermal_core.c thermal: Fix deadlock in thermal thermal_zone_device_check 2019-12-13 08:43:21 +01:00
thermal_core.h thermal/drivers/core: Use governor table to initialize 2019-06-27 21:22:14 +08:00
thermal_helpers.c drivers: thermal: Update license to SPDX format 2018-05-30 14:46:17 +08:00
thermal_hwmon.c thermal_hwmon: Sanitize thermal_zone type 2019-09-24 09:56:08 +08:00
thermal_hwmon.h thermal: hwmon: inline helpers when CONFIG_THERMAL_HWMON is not set 2019-01-02 04:43:00 -08:00
thermal_mmio.c thermal: thermal_mmio: remove some dead code 2019-09-22 13:44:52 -07:00
thermal_sysfs.c thermal: Fix locking in cooling device sysfs update cur_state 2018-11-30 16:57:51 +08:00
uniphier_thermal.c thermal: uniphier: Convert to SPDX identifier 2019-01-02 04:47:16 -08:00
user_space.c thermal/drivers/core: Use governor table to initialize 2019-06-27 21:22:14 +08:00
zx2967_thermal.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00