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 EBE025221EE; Mon, 31 Aug 2026 13:44:10 +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=1788183852; cv=none; b=kn6GPAv7JhCMe9XMFEDd6DE3SOeMtCgdALTktMsztmpX1WJebkI/T7T2Sa9T1y0F+gfQkF52fL8jLTbGR8hq5Gmb1SWFRxSXgHtewZqX1erVFmgEwdQRekq4u0Ds1tRJTWut6ImZupD1NtxmKZeKsnd+mFCT+jyEFTYQol1YK2I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788183852; c=relaxed/simple; bh=okKj+y3sKCajXRlA8WQ3QdPklD7bh7izF4c3uCMLSwE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C/jLpKH1uCltiRYcHp/gEwcHMM51Bjs7fRWOmAYDY/NPUgybJDiPPW+dArQOz/8n9RBwGMuiP+WsNiOHtHDlnyuf0v6zENtq1Rwhz0Va3VImjREvB3uHD9G19+3RPJR/xYV9UTUHj2ezhKrYZdJxYqy08pznwmxhSzzVy3XdmRQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pN0Q4Gny; 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="pN0Q4Gny" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 317171F00ACA; Mon, 31 Aug 2026 13:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788183850; bh=lOWEG+l9778uLJK13P28K3Bxy3I3neCtGP5LgctDy74=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pN0Q4GnyM0itz4LFoJesVKTvT32LjTswgd8fy6HQMAp34G9oYl1JDWUIYixH0ic32 yozThzMulN05Tf8AZ+rMXBOS1mqeWt4ZWMJcL+wEUOXadIrrBpBqspcG5dnkgywAFn UdPn9N+rKDs6BgJJ7i40iSjtIFmf/1FvbMmT6ZBs= 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 7.1 62/76] crypto: qce - fix CCM AAD buffer underallocation Date: Mon, 31 Aug 2026 15:34:34 +0200 Message-ID: <20260831133402.646876043@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831133359.185608553@linuxfoundation.org> References: <20260831133359.185608553@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 7.1-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 @@ -198,7 +198,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;