Skip to content

thermal/core: Protect thermal device operations against removal

Guenter Roeck linux-pm lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest9 patches 2 repliesIn review
  2. v19 patches 15 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9thermal/core: Destroy thermal zone device mutex in release functiondrivers/thermal/thermal_core.c+1 -10 replies
2/9thermal/core: Delete device under thermal device zone lockdrivers/thermal/thermal_core.c+6 -10 replies
3/9thermal/core: Ensure that thermal device is registered in thermal_zone_get_tempdrivers/thermal/thermal_helpers.c+6 -10 replies
4/9thermal/core: Move parameter validation from __thermal_zone_get_temp to thermal_zone_get_tempdrivers/thermal/thermal_helpers.c+23 -30 replies
5/9thermal/core: Introduce locked version of thermal_zone_device_updatedrivers/thermal/thermal_core.c+31 -260 replies
6/9thermal/core: Protect hwmon accesses to thermal operations with thermal zone mutexdrivers/thermal/thermal_hwmon.c+9 -10 replies
7/9thermal/core: Protect sysfs accesses to thermal operations with thermal zone mutexdrivers/thermal/thermal_core.c drivers/thermal/thermal_core.h drivers/thermal/thermal_sysfs.c+69 -160 replies
8/9thermal/core: Remove thermal_zone_set_trips()drivers/thermal/thermal_core.h drivers/thermal/thermal_helpers.c+15 -200 replies
9/9thermal/core: Protect thermal device operations against thermal device removaldrivers/thermal/thermal_core.c+11 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/9] thermal/core: Protect thermal device operations against removal

Accesses to thermal zones, and with it to thermal zone device operations, are still possible after the thermal zone device has been unregistered. For example, thermal_zone_get_temp() can be called from temp_show() in thermal_sysfs.c if the sysfs attribute was opened before the thermal device was unregistered. This is problematic and may result in crashes since the operations data structure and the underlying code may be gone when the calls are made.

The following series solves the problem by protecting accesses to thermal device operations with the thermal device mutex, and by verifying that the thermal device is still registered after the mutex has been acquired.

This was previously sent as RFC/RFT as single patch [1]. The code was reworked to match thermal subsystem changes made between v6.0 and v6.1, and it was split into several patches to simplify review.

[1] https://lore.kernel.org/linux-pm/[email protected]/

v2: Improved documentation, rearranged code.
No functional changes. See individual patches for details.

----------------------------------------------------------------
Guenter Roeck (9):
thermal/core: Destroy thermal zone device mutex in release function thermal/core: Delete device under thermal device zone lock
thermal/core: Ensure that thermal device is registered in thermal_zone_get_temp thermal/core: Move parameter validation from __thermal_zone_get_temp to thermal_zone_get_temp thermal/core: Introduce locked version of thermal_zone_device_update thermal/core: Protect hwmon accesses to thermal operations with thermal zone mutex thermal/core: Protect sysfs accesses to thermal operations with thermal zone mutex thermal/core: Remove thermal_zone_set_trips()
thermal/core: Protect thermal device operations against thermal device removal

 drivers/thermal/thermal_core.c    | 76 +++++++++++++++++++++++--------------
 drivers/thermal/thermal_core.h    |  3 +-
 drivers/thermal/thermal_helpers.c | 67 +++++++++++++++++++++------------
 drivers/thermal/thermal_hwmon.c   | 10 ++++-
 drivers/thermal/thermal_sysfs.c   | 79 ++++++++++++++++++++++++++++++++-------
 5 files changed, 168 insertions(+), 67 deletions(-)