From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE52C408039; Tue, 21 Jul 2026 19:26:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784661983; cv=none; b=fDgY7aGBt6USxu8LlMg/OxDuDQEoS+Bv7ysSor/mM1vL2pQeIY+HdT81dXfuko2w+8946ggGzt8zHbYsVpqklhAb4BWwJFH3Qr2UAK1vxJqnanpMpGei6KKhEEONsw5UCFWzXGkAb2Zn40CTrB574ozBy5kmLdsBveewXw5oQMU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784661983; c=relaxed/simple; bh=VgFG57xrTpjf4iE8pdcOkMLbougabLN6bjgLHy11dhs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=egN6WYFf5iFifbvCzdk3Y5mRfODbJ4IDqy5LQx2R6lpkzGSp0rjlCdP4ef/Q9cFCNlwvF9FHsXbcg+n2AEQkQYVHnujuzYoU/AxEl0ytYI+jS0/J0bBpEHbWeCHAqWNr5C/4b1eD7fE9DLQ1IkvAVaIZP5pvXPWV5/+FIQOwk1s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k1dRVtlW; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="k1dRVtlW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 312CF1F000E9; Tue, 21 Jul 2026 19:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784661982; bh=bIiiwi/wcrO7DaeeEXTDkeYngz2F1janPhtCA+ORYD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=k1dRVtlWh2rPIEIEjtscSUH1tIKAiU5p5St5a4VXKW9Dv2kBSdacRq2vbIe+WfzF4 PGZIyN3AsdBTnbLzd1T8NYrgrrDSP+kOeDR9efqu0IJkzra4XvoBGzgiG19I9YWcXG KIzd/yShCiAfFLLCtzlZjqgsePl14cPbyw1+Ofs4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+e70e4c6f6eee43357ba7@syzkaller.appspotmail.com, Dmitry Vyukov , Danilo Krummrich , Sasha Levin Subject: [PATCH 6.12 0270/1276] firmware_loader: Fix recursive lock in device_cache_fw_images() Date: Tue, 21 Jul 2026 17:11:53 +0200 Message-ID: <20260721152452.122411858@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Vyukov [ Upstream commit d3ec78f8f8d48a04a9fac38d47275c34645e5103 ] 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: ac39b3ea73aa ("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 Link: https://patch.msgid.link/48b092a5-f49d-48a4-95f4-f65bebfc6bc3@mail.kernel.org Signed-off-by: Danilo Krummrich Signed-off-by: Sasha Levin --- drivers/base/firmware_loader/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c index c6664a78796979..b4c4a532957074 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c @@ -1547,9 +1547,10 @@ static void device_cache_fw_images(void) mutex_lock(&fw_lock); fwc->state = FW_LOADER_START_CACHE; - dpm_for_each_dev(NULL, dev_cache_fw_image); mutex_unlock(&fw_lock); + dpm_for_each_dev(NULL, dev_cache_fw_image); + /* wait for completion of caching firmware for all devices */ async_synchronize_full_domain(&fw_cache_domain); -- 2.53.0