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 287581D7E5C; Sat, 12 Sep 2026 14:55:49 +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=1789224950; cv=none; b=ILYxMwK1LsPHINjUfvFKWSi4+25oV2mXYYZFM8SESLyRubbZz677Y9rrSmQjS9bUUqqHbOvKCs9WOQoUnQ3YIOtzMoie8B6q+CuCKy4OdzzG1FulyI34Z0CV1dudYIxQf8sy83UBBN5/RR37C8gOoZNLc6L3R5G9jmmAvNU/CMQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789224950; c=relaxed/simple; bh=Ztk4YnZ2YPIoJtBmTdNFBDEwjAEL3wc1q8ngUPZ/cSc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nwc6k9zchzBk4H6ZinEfTWlAi4k0C0CT+JByALoY6hQL8+ht9Du50leX3Dhkvg2ukAaZCwY42y0XLJLA6eVFWvLefWm5uwsIwui51aAiXQpFzkRBKLQQmr4t4Y9r9RqNSCfGxpnrdF8cHP5yGnzTKtChRTnLF6giPINyVJsdfdk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yxoe6tYx; 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="yxoe6tYx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00FEE1F000FF; Sat, 12 Sep 2026 14:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789224948; bh=6ALrtTQaoJ+euV9rVGUpIf8zpM93mT43TEZz/HE/k0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yxoe6tYxsSu7m+S6hgJ45pSkkSE+Rb6uV0Kc1btdNReuNwrrp42gbXY8RuPhbkqnH ccmPGn8j7YWzVHq6C5DJ5If8Xu0ethCepLOWxASTHoUVBQOeTcGpmfuxyBKJB3henU eRrmigsaGmEs1BQZm7YixGCS3VBhmFijzo47mqpE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mukesh Ojha , Danilo Krummrich , Sasha Levin Subject: [PATCH 6.6 1099/1424] firmware_loader: do not queue completed sysfs fallback requests Date: Sat, 12 Sep 2026 08:58:51 +0200 Message-ID: <20260912065631.918695726@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@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: Mukesh Ojha [ Upstream commit b48373c901951fad1a26bd7c33ad91172b3945b5 ] 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: 75d95e2e39b2 ("firmware_loader: fix use-after-free in firmware_fallback_sysfs") Signed-off-by: Mukesh Ojha Link: https://patch.msgid.link/20260716081601.1674470-1-mukesh.ojha@oss.qualcomm.com Signed-off-by: Danilo Krummrich Signed-off-by: Sasha Levin --- drivers/base/firmware_loader/fallback.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c index bf68e39478147..b66a529fd041d 100644 --- a/drivers/base/firmware_loader/fallback.c +++ b/drivers/base/firmware_loader/fallback.c @@ -91,6 +91,16 @@ static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, long timeout) retval = -EINTR; goto out; } + + /* + * device_add() exposes the loading interface before pending_list is + * linked into pending_fw_head, so fw_state_done() may run first. + */ + if (fw_state_is_done(fw_priv)) { + mutex_unlock(&fw_lock); + goto out; + } + list_add(&fw_priv->pending_list, &pending_fw_head); mutex_unlock(&fw_lock); -- 2.53.0