diff options
| author | Guenter Roeck <linux@roeck-us.net> | 2026-10-30 20:33:12 -0700 |
|---|---|---|
| committer | Guenter Roeck <linux@roeck-us.net> | 2026-11-03 09:40:35 -0800 |
| commit | 321dcb9ae937c4c537020d12a0ef0cace5157dcc (patch) | |
| tree | 5619cc0e2e81b2f68f5bf272f6a29a1bb56aedfb /tools/perf/scripts/python | |
| parent | c221091f7e30c64280e4cbfa27dc4c05edc96d0c (diff) | |
hwmon: (acpi_power_meter) Fix missing locking in sysfs show callbacks and resume
During system resume, acpi_power_meter_resume() calls free_capabilities()
and read_capabilities() without acquiring resource->lock. Because ACPI
notifications run on the non-freezable kacpi_notify_wq workqueue, a
concurrent METER_NOTIFY_CONFIG notification during resume can race with
acpi_power_meter_resume() and trigger a double-free or use-after-free on
the model_number, serial_number, and oem_info strings as well as
concurrently overwrite resource->caps. When CONFIG_SUSPEND_FREEZER is
disabled, concurrent sysfs readers can also dereference the freed
capability strings mid-update.
In addition, none of the extra sysfs attribute show callbacks acquire
res->lock:
- power1_average_min_show() and power1_average_max_show() read the 64-bit
res->trip[] entries twice without locking while set_trip() modifies
them under res->lock (including temporarily storing a candidate value
before evaluating _PTP and rolling it back on failure). On 32-bit
architectures this exposes torn 64-bit reads, and on all architectures
it exposes uncommitted trip values and a TOCTOU race between the < 0
check and multiplication (emitting "-1000" instead of "unknown" if
set_trip() rolls back to -1).
- power1_model_number_show(), power1_oem_info_show(),
power1_serial_number_show(), power1_cap_hyst_show(),
power1_accuracy_show(), and power1_is_battery_show() read capability
strings and 64-bit capability fields without synchronization against
resume updates.
Acquire resource->lock using guard(mutex) in acpi_power_meter_resume()
and in all extra sysfs show callbacks. Also return -ENODATA in the
capability string show callbacks if a string pointer is NULL after a
failed capability re-read.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Fixes: de584afa5e18 ("hwmon driver for ACPI 4.0 power meters")
Fixes: 16746ce8adfe ("hwmon: (acpi_power_meter) Replace the deprecated hwmon_device_register")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
