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 4F1E13DCD9C; Thu, 17 Sep 2026 18:57:39 +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=1789671464; cv=none; b=CFeRBjE0M2Lcefomj8xkmkjZPk6583mZSygWXNTqqLtSDJNxe5e6FMINZo6wI1joQojagLF2uoiHfodwJf08KRP6s0jTzqD9k3SHk2q3HPv8QWNux06U8sxYWSzwfywfvbv2VOdSOqxxUs51RB5oq/K00oko4ojN5+PqtnJBwfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789671464; c=relaxed/simple; bh=vBJIz1TntnL67QIuRJEubJYk8TAL5PSmDDVe09Z9Tsw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lajqMU4syBRoQpZinLF5untkA2RxQhxn0eZPtyVFatbcUU3Pf985btgQ6c9oPrT6O6828hEVq+4RYi6lJeLeTOVp79VluXTi5kkOhIFBWUuxCMWrAK0PsyAHnKaUf53pydUWWEWdwSrr1rBvg1EYcIjg31G+BD5eZH9zHpiB7fQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=X1OHmb/X; 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="X1OHmb/X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 964661F000FF; Thu, 17 Sep 2026 18:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789671459; bh=3R5c82QI/6DxAtHSV2pnLgdHGwj65FmOaV3UYUIDyOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=X1OHmb/X19/hsh6qNlrfBUQFEfMS+8tdaFskLfpGFK0wl6olOZb3tNh2vW450nil2 mrVtwlJ3TvtTZvKLVNjkstuT1JGsL5ltHVqo8uxHT2uN+ZFW8uAHAcmnh1jMoZF7Nc laXPbXtWOPdbe9FTjHSC66k5XTRSBhTp/eN1MCbs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thorsten Blum , Herbert Xu , Sasha Levin Subject: [PATCH 6.12 0983/1102] crypto: atmel-ecc - avoid stale fallback key after set_secret failure Date: Thu, 17 Sep 2026 16:15:26 +0100 Message-ID: <20260917151605.382622691@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151539.408551884@linuxfoundation.org> References: <20260917151539.408551884@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: Thorsten Blum [ Upstream commit f07a0d251db7606e4792d2610788fbcc7b2c0d12 ] Clear ->do_fallback before decoding a new ECDH secret and enable it only after the software fallback accepts a caller-provided private key. This avoids using a stale fallback key should crypto_kpp_set_secret() fail. Fixes: 11105693fa05 ("crypto: atmel-ecc - introduce Microchip / Atmel ECC driver") Cc: stable@vger.kernel.org Signed-off-by: Thorsten Blum Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/atmel-ecc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/crypto/atmel-ecc.c +++ b/drivers/crypto/atmel-ecc.c @@ -84,6 +84,7 @@ static int atmel_ecdh_set_secret(struct kfree(ctx->public_key); ctx->public_key = NULL; + ctx->do_fallback = false; if (crypto_ecdh_decode_key(buf, len, ¶ms) < 0) { dev_err(&ctx->client->dev, "crypto_ecdh_decode_key failed\n"); @@ -91,8 +92,9 @@ static int atmel_ecdh_set_secret(struct } if (params.key_size) { - ctx->do_fallback = true; - return crypto_kpp_set_secret(ctx->fallback, buf, len); + ret = crypto_kpp_set_secret(ctx->fallback, buf, len); + ctx->do_fallback = !ret; + return ret; } cmd = kmalloc(sizeof(*cmd), GFP_KERNEL); @@ -103,8 +105,6 @@ static int atmel_ecdh_set_secret(struct if (!public_key) goto free_cmd; - ctx->do_fallback = false; - atmel_i2c_init_genkey_cmd(cmd, DATA_SLOT_2); ret = atmel_i2c_send_receive(ctx->client, cmd);