linux/drivers/base/firmware_loader
Mukesh Ojha b48373c901 firmware_loader: do not queue completed sysfs fallback requests
fw_load_sysfs_fallback() calls device_add() before adding the fw_priv to
pending_fw_head. device_add() publishes the fallback loading interface, so
a userspace helper which discovers the device by scanning sysfs can write 0
to the loading attribute and complete the request before it is queued as
pending.

In that interleaving firmware_loading_store() calls fw_state_done() while
pending_list still points to itself, so it cannot remove an entry from
pending_fw_head. The subsequent unconditional list_add() then queues an
already-completed fw_priv. Once the request is released, pending_fw_head
can retain a pointer to freed memory and the next fallback request can
fault while validating the list.

Only in-flight fallback requests need suspend or reboot abort handling. If
the request is already DONE after device_add(), return success from the
fallback path without sending another uevent, waiting again, or queueing it
as pending. This preserves the invariant that pending_fw_head contains only
active fallback requests.

Fixes: 75d95e2e39 ("firmware_loader: fix use-after-free in firmware_fallback_sysfs")
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Link: https://patch.msgid.link/20260716081601.1674470-1-mukesh.ojha@oss.qualcomm.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-08-06 23:38:16 +02:00
..
builtin firmware_loader: builtin: fail build on empty firmware 2026-07-12 02:25:08 +02:00
fallback_platform.c firmware: Store opt_flags in fw_priv 2020-10-05 13:37:04 +02:00
fallback_table.c treewide: const qualify ctl_tables where applicable 2025-01-28 13:48:37 +01:00
fallback.c firmware_loader: do not queue completed sysfs fallback requests 2026-08-06 23:38:16 +02:00
fallback.h firmware_loader: Refactor kill_pending_fw_fallback_reqs() 2023-10-27 13:30:38 +02:00
firmware.h firmware_loader: Abort all upcoming firmware load request once reboot triggered 2023-10-27 13:30:38 +02:00
Kconfig firmware_loader: make RUST_FW_LOADER_ABSTRACTIONS select FW_LOADER 2025-11-26 14:32:10 +01:00
main.c sound updates for 7.2-rc1 2026-06-17 11:18:45 +01:00
Makefile firmware_loader: Add firmware-upload support 2022-04-26 12:34:28 +02:00
sysfs_upload.c firmware_loader: fix device reference leak in firmware_upload_register() 2026-05-07 00:44:52 +02:00
sysfs_upload.h firmware_loader: Move definitions from sysfs_upload.h to sysfs.h 2022-04-29 16:49:44 +02:00
sysfs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
sysfs.h module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00