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 617874CCDE4; Mon, 31 Aug 2026 14:05:16 +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=1788185117; cv=none; b=MaE94vUIDH4aNU+oJ24pe42o8mYZeg1cxiNJeX/+roxTLB1/hYurXMc0tRivTtfSyMV6qpYcvYIK1YFfIrjLzqzKYwU+e6l/q7QoUjNaMBES6QQFSA3MVpSoZToenvsksK+nCo60Vo+02YcGUv+Bc3YsWJmEsgalG+RZ5l5I7us= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788185117; c=relaxed/simple; bh=0+bErX1I+bXge9DPk8tfZ7stUtwq7nU1FSKufMAgSm4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mxjf9ctyxVdmuQW4zOheU9/JLIVjFH+xZ1iJ5YWo+MFvUk6LoVAfMD/esi8GPnD69A1ngSZt4nboxk3+iNiBQ1r2Ky/tr6yFCd/POo8TihK32C47DGvd2LSjt2AvOi6ESftjxZxbuDBYf951utVZg9gMZrAjgquCW7ZZgvyMXt4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TPAGGbB5; 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="TPAGGbB5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C5ED1F00A3D; Mon, 31 Aug 2026 14:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788185116; bh=psVHp3xLWyZDtVJF3uaL6p2QXXHzsEoWgiGVksF6hT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TPAGGbB5J+q8eYDwqnJvFX5Wwel2SDD2dEC+84TxuLuxj1qai8Mma5HczIjLZl3UG m/diyMnc+lRc6cctS1M18/7OZeIKFtIklbtNeBoHmOGXhgs7TVjSIGchobXT0fVfv+ 4WaF+2owiuv5/kFNHvWQ8wGGKx2yfjpKXl6aWqlA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Md Sadre Alam , Bartosz Golaszewski , Herbert Xu Subject: [PATCH 5.15 58/69] crypto: qce - fix CCM AAD buffer underallocation Date: Mon, 31 Aug 2026 15:35:31 +0200 Message-ID: <20260831133401.642080291@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831133358.601894154@linuxfoundation.org> References: <20260831133358.601894154@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Md Sadre Alam commit 7f2345f47dd189625f657cd72437179ab4170ee1 upstream. The AAD buffer allocated in qce_aead_ccm_prepare_buf_assoclen() can be smaller than the length later programmed into the DMA scatterlist. The allocation size is currently calculated as: ALIGN(assoclen, 16) + MAX_CCM_ADATA_HEADER_LEN while the DMA length is set to: ALIGN(assoclen + adata_header_len, 16) Since ALIGN() does not distribute over addition, the allocation can be smaller than the DMA length. For example, when assoclen = 32 and adata_header_len = 2: allocation = ALIGN(32, 16) + 6 = 38 DMA length = ALIGN(32 + 2, 16) = 48 As a result, the QCE hardware can read beyond the allocated buffer while computing the CBC-MAC over the associated data. The extra bytes are folded into the authentication tag, resulting in an incorrect tag and causing CCM self-test failures such as: alg: aead: ccm-aes-qce encryption test failed (wrong result) on test vector 8 Fix the allocation by adding the maximum possible AAD header length before alignment: ALIGN(assoclen + MAX_CCM_ADATA_HEADER_LEN, 16) This guarantees that the allocated buffer is large enough for the fully padded AAD data for all supported header sizes. Cc: stable@vger.kernel.org Fixes: 9363efb4181c ("crypto: qce - Add support for AEAD algorithms") Signed-off-by: Md Sadre Alam Reviewed-by: Bartosz Golaszewski Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/qce/aead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/crypto/qce/aead.c +++ b/drivers/crypto/qce/aead.c @@ -203,7 +203,7 @@ qce_aead_ccm_prepare_buf_assoclen(struct /* Get the msg */ msg_sg = scatterwalk_ffwd(__sg, req->src, req->assoclen); - rctx->adata = kzalloc((ALIGN(assoclen, 16) + MAX_CCM_ADATA_HEADER_LEN) * + rctx->adata = kzalloc(ALIGN(assoclen + MAX_CCM_ADATA_HEADER_LEN, 16) * sizeof(unsigned char), GFP_ATOMIC); if (!rctx->adata) return -ENOMEM;