linux/drivers/base
Dmitry Vyukov 7865a1bfd2 firmware_loader: Fix recursive lock in device_cache_fw_images()
[ Upstream commit d3ec78f8f8 ]

A recursive locking deadlock can occur in the firmware loader's power
management notification handler.

During system suspend or hibernation preparation, fw_pm_notify() calls
device_cache_fw_images(). This function acquires fw_lock to set the
firmware cache state to FW_LOADER_START_CACHE and then iterates over all
devices using dpm_for_each_dev() while still holding the lock.

For each device, dev_cache_fw_image() schedules asynchronous work to cache
the firmware. If memory allocation for the async work entry fails (e.g., in
out-of-memory conditions), async_schedule_node_domain() falls back to
executing the work function synchronously in the current thread.

The synchronous execution path (__async_dev_cache_fw_image() ->
cache_firmware() -> request_firmware() -> assign_fw()) attempts to acquire
fw_lock again. Since the current thread already holds fw_lock, this results
in a recursive locking deadlock.

Fix this by releasing fw_lock immediately after updating the cache state
and before calling dpm_for_each_dev(). The lock is only needed to protect
the state update. Concurrent firmware requests will correctly see the
FW_LOADER_START_CACHE state and use the piggyback mechanism, which is
independently protected by its own fwc->name_lock.

Fixes: ac39b3ea73 ("firmware loader: let caching firmware piggyback on loading firmware")
Assisted-by: Gemini:gemini-3.1-pro-preview Gemini:gemini-3-flash-preview syzbot
Reported-by: syzbot+e70e4c6f6eee43357ba7@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e70e4c6f6eee43357ba7
Link: https://syzkaller.appspot.com/ai_job?id=8b4af9fd-24af-423f-8acb-1159fd34c1a5
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Link: https://patch.msgid.link/48b092a5-f49d-48a4-95f4-f65bebfc6bc3@mail.kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-07-24 15:51:33 +02:00
..
firmware_loader firmware_loader: Fix recursive lock in device_cache_fw_images() 2026-07-24 15:51:33 +02:00
power PM: sleep: Use complete() in device_pm_sleep_init() 2026-07-24 15:51:30 +02:00
regmap regmap: Synchronize cache for the page selector 2026-04-18 10:33:25 +02:00
test driver core: test_async: fix an error code 2023-09-19 12:22:45 +02:00
arch_numa.c memblock: drop memblock_free_early_nid() and memblock_free_early() 2025-03-13 12:50:07 +01:00
arch_topology.c arch_topology: Fix incorrect error check in topology_parse_cpu_capacity() 2025-10-29 14:03:15 +01:00
attribute_container.c driver core: attribute_container: fix W=1 warnings 2021-05-14 13:37:10 +02:00
auxiliary.c Merge 5.14-rc3 into driver-core-next 2021-07-27 09:22:08 +02:00
base.h software nodes: Split software_node_notify() 2021-07-16 19:17:05 +02:00
bus.c driver core: bus: Fix double free in driver API bus_register() 2024-12-14 19:51:14 +01:00
cacheinfo.c cacheinfo: clear cache_leaves(cpu) in free_cache_attributes() 2021-07-21 17:29:40 +02:00
class.c class: fix possible memory leak in __class_register() 2022-12-31 13:14:27 +01:00
component.c drivers: base: component: fix memory leak with using debugfs_lookup() 2023-03-11 13:57:38 +01:00
container.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
core.c driver core: Don't let a device probe until it's ready 2026-06-01 17:35:14 +02:00
cpu.c x86/vmscape: Enable the mitigation 2025-09-11 17:17:17 +02:00
dd.c driver core: Don't let a device probe until it's ready 2026-06-01 17:35:14 +02:00
devcoredump.c devcoredump: Fix circular locking dependency with devcd->mutex. 2025-10-29 14:03:15 +01:00
devres.c devres: fix missing node debug info in devm_krealloc() 2026-06-01 17:35:27 +02:00
devtmpfs.c devtmpfs regression fix: reconfigure on each mount 2022-01-20 09:13:13 +01:00
driver.c driver: platform: Add helper for safer setting of driver_override 2023-11-08 17:26:43 +01:00
firmware.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
hypervisor.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
init.c init: Initialize noop_backing_dev_info early 2022-06-22 14:22:02 +02:00
isa.c bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
Kconfig RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
Makefile devres: Enable trace events 2021-06-15 17:14:36 +02:00
map.c driver: base: Prefer unsigned int to bare use of unsigned 2021-07-21 17:30:09 +02:00
memory.c mm/hwpoison: avoid the impact of hwpoison_filter() return value on mce handler 2022-07-12 16:35:05 +02:00
module.c Revert "driver core: Fix uevent_show() vs driver detach race" 2024-11-08 16:25:54 +01:00
node.c drivers/base/node: fix double free in register_one_node() 2025-10-19 16:21:37 +02:00
pinctrl.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
platform-msi.c platform-msi: Add ABI to show msi_irqs of platform devices 2021-08-24 09:16:20 +02:00
platform.c driver: platform: Add helper for safer setting of driver_override 2023-11-08 17:26:43 +01:00
property.c device property: fix fwnode reference leak in fwnode_graph_get_endpoint_by_id() 2026-07-24 15:51:29 +02:00
soc.c soc: fix comment for freeing soc_dev_attr 2020-12-09 19:46:31 +01:00
swnode.c software node: Correct a OOB check in software_node_get_reference_args() 2025-06-27 11:05:32 +01:00
syscore.c syscore: Use pm_pr_dbg() for syscore_{suspend,resume}() 2020-09-08 13:32:06 +02:00
topology.c topology: Keep the cpumask unchanged when printing cpumap 2025-01-23 17:15:53 +01:00
trace.c devres: Enable trace events 2021-06-15 17:14:36 +02:00
trace.h devres: Enable trace events 2021-06-15 17:14:36 +02:00
transport_class.c drivers: base: transport_class: fix resource leak when transport_add_device() fails 2023-03-10 09:39:39 +01:00