From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795025110; b=KWNwkziUekt4VGXMl4/XhfcXTyHYRUqM2NTM9nKsn85qvYyRUZ1NxwGDurp84yX2v4Mk 0nuXA1pMblCLqfkuH6I+ySWzqnWxGZDka6uYXqUMYCLQslwGGbfomeTnQWxTMUIvT/jgS MVtAbqOFxKjFb9UtjGdhslXaOUP3Lh8PA9jFoHr07Hv/E5QextAzRDjFePhWRoMrcb15H porjRHe7jqhxzYFXGQtryl65lFebesTGGeWaB2ik+hqnOWMid5UWl0foLl1IG+EqNab44 hB76pn1T+MQF1Scdx34fn7rwDGskDvk+OAl6sHIRTdqMWxKpo4F7XY+9ubeljPMfheQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795025110; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=7mOzigX3p3Co3D3Zp4/gzScOsFG1u/OXuvu+m1RdPzQ=; b=kYCoS04yiy1CNyqo2zno6E15t4rcssB+OkoNoJ8ZvEFxr5dga6I4yYQIvzy4y7XLPykU SYBMjl6QJFoPIgRHy73yLCNbGmKUzgrOLoFf3rWyvjgvwLdCJLFkJWRGH31ZTZ5h0UV+4 dlEwnON4BERa/cMBzZPyKaJ2IlF6Q4Mj5qirjGMTbkS/iMwOjl4UdfLgFKioOFt45c3mK Fp5NC07DABmytP3RVU19dZX5jDwWjudxK9prqmw/Tljnr4T8CsmZqvs7CcQy/7lK2/hzi NTSNgEON1tr7k+rGS6wL7Qn8jsBgc/JDyLi7JKDmFNuTBykHuOVN2rbVRRWbb0i4b5w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=iet5DfD3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8659E606A32A; Wed, 18 Nov 2026 18:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=iet5DfD3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D87F11F000C4; Wed, 18 Nov 2026 18:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795025110; bh=7mOzigX3p3Co3D3Zp4/gzScOsFG1u/OXuvu+m1RdPzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iet5DfD3ljU1IxdqPB0a93uR7GMByeGJfwqtONpicFj3zK7olM9c2oLgZaaKjt9Bs FETbI//PGaz24qLsgj3ECEWSk7kLjNniozPbOTaHYh97YCOkSeowRhrU2wSf/Zzfy5 Pu0Cq26Q0bG/254mdLa03WLNbnWpqIH0AQORu1qM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Karl Mehltretter , Herbert Xu , Sasha Levin Subject: [PATCH 6.18 0962/2151] crypto: atmel - handle authenc requests without plaintext Date: Wed, 18 Nov 2026 15:44:57 +0100 Message-ID: <20261118150157.567270379@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150121.603863898@linuxfoundation.org> References: <20261118150121.603863898@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Karl Mehltretter [ Upstream commit ccbd95b3efbc0580b6abde2a905823417ca56022 ] Authenc permits a nonempty associated-data string with no plaintext. The Atmel driver accepts such a request, has SHA process the associated data, and then unconditionally asks AES DMA to transfer zero bytes. The Atmel DMA engines reject the zero-length descriptor, so the valid request fails, normally with -ENOMEM. Skip the AES transfer when textlen is zero and proceed directly to SHA finalization. Once an HMAC transform has cached its inner and outer states, SHA can complete this path synchronously. The forced ahash completion callback then invokes the AES finalizer through a void function and discards its return value. This loses -EBADMSG for a mismatched tag and reports successful decryption. For synchronous SHA completion, release the SHA device without invoking the ahash callback and call the AES finalizer directly. Its result then propagates through the synchronous call chain. Keep the existing callback path for asynchronous completion. On a SAM9X75, the unpatched driver failed valid AAD-only requests and returned success for a bad tag after the transform had been used once. With this change, bad tags return -EBADMSG for both fresh and reused transforms. Fixes: 89a82ef87e01 ("crypto: atmel-authenc - add support to authenc(hmac(shaX), Y(aes)) modes") Assisted-by: LLM Signed-off-by: Karl Mehltretter Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/atmel-aes.c | 2 ++ drivers/crypto/atmel-sha.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index e057be7fc7130..70e5a6b5c4961 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c @@ -1831,6 +1831,8 @@ static int atmel_aes_authenc_transfer(struct atmel_aes_dev *dd, int err, dd->is_async = true; if (err) return atmel_aes_complete(dd, err); + if (!rctx->textlen) + return atmel_aes_authenc_digest(dd); /* Prepare src and dst scatter-lists to transfer cipher/plain texts. */ src = scatterwalk_ffwd(rctx->src, req->src, req->assoclen); diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c index f8281a175a779..550055004b317 100644 --- a/drivers/crypto/atmel-sha.c +++ b/drivers/crypto/atmel-sha.c @@ -2395,11 +2395,25 @@ static int atmel_sha_authenc_final_done(struct atmel_sha_dev *dd) { struct ahash_request *req = dd->req; struct atmel_sha_authenc_reqctx *authctx = ahash_request_ctx(req); + atmel_aes_authenc_fn_t cb; + struct atmel_aes_dev *aes_dev; size_t i, num_words = authctx->digestlen / sizeof(u32); for (i = 0; i < num_words; ++i) authctx->digest[i] = atmel_sha_read(dd, SHA_REG_DIGEST(i)); + if (!dd->is_async) { + /* + * Return the AES finalizer's status directly for synchronous requests. + * The ahash callback cannot propagate it. + */ + cb = authctx->cb; + aes_dev = authctx->aes_dev; + dd->force_complete = false; + (void)atmel_sha_complete(dd, 0); + return cb(aes_dev, 0, false); + } + return atmel_sha_complete(dd, 0); } -- 2.53.0