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 E70BA3B637C; Tue, 21 Jul 2026 20:33:09 +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=1784665991; cv=none; b=YmW/oRQqMxT2zAF57eQa9/SXWtNEpHQqbKvPP43TfeLVL4GkoDUR76n5UralPmx/nLGeVduSNTl9WdIJ0t5OqE0JDtsX89SiqEJZFl/zMxxZxXVdYf4enoHLzDU6BRRouYRqyBKhBSp9Hd5Sr3Vp1vA7eRqWArFsPAM7ciKT1dk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784665991; c=relaxed/simple; bh=ytXeL0Xmw79kLp9l9XqVWaChUSvKe5UCj+PQFjZOnus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KMjMdtKD2zZxQxQ7/n3jcD+MQHclHjZlQzaLbwPcvu9aXNEQoz2lgbKAeEjnWSDJMsZ/8zqe65N93XMTj0Ajrh1uzILgzHKXGcCx/OCWKPMWrR+ZjUUBIFxsFh2PcRcTaH+63jvLdrvwWKLogwwpzlnTUDOT+9TW2nrzGnKXc6Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nu77+Dyl; 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="nu77+Dyl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 588481F000E9; Tue, 21 Jul 2026 20:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784665989; bh=sjJd+s4KOwYjO6fdoK4lznDbuSkOl8hpNCG9vjiawUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nu77+Dyl6q9xl64buroESeEXmKB7K80Ksj++nC9xpQQXUDGNbOQV5hmW0nXtceBP/ ve2aB+RksnCNEx5xLVYTvQKXnJPypHNajEBllJDWhBNmsZbCyNE9ISzpbDSXU8XLda 9rWEfOUhPUfkwCKO289f+VdtSEuAn6nY3VoyGMdI= 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.6 0514/1266] firmware_loader: Fix recursive lock in device_cache_fw_images() Date: Tue, 21 Jul 2026 17:15:51 +0200 Message-ID: <20260721152453.351008202@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@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.6-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 f3133ba831c5e0..4f4614811d0952 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c @@ -1506,9 +1506,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