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=1796094398; b=5f5nEryzDndIZbpggvkpBJPbUSJjoDF9KnleW+SCqWJgYmG5R1Xy2qi9Lf8kUG7Z4w7W rBhoeN3rD4rH93+w2tL+3pC1kNI+Y4DaFHeU11gURtRz7KZAVFBhRDK+3MeXdiSMKwiAG +0FWZnSPs/8cbfOKUG40/5MvjHDUc2HeO5IB/dT1RyuwaBljpdSKPnBFVO2vi5ro+qkUB QwARMmrt90B6SnE6glzQgs/Cjd/Wbn1/qPeSw+vTXVXh1INHdpGEX37sHAyYZPr2n9YQg o7icksmYRGA2PnAz361X5K0KrTBR5aQa1sbXhZBnVaPGrO8/84S7gfZ0o4ITiKbmSPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796094398; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=VevCn9ztBRpUE9PTM7FEBbRi9gdst4yCznFh3sRZAdE=; b=Dyyqd+p0TMSrwAyEBaN82Us3W+IyWLS6i66bBCSBz2c+glTju26ztgBXVW/nitQtPMZ4 9jbDB87Hrl0Bs7LXtXG+80t1h8pfFNcDvLqc//R/96the67CpoZR20Snr7zuAciraaNBB Gm1IMCTj+DpbKjltHBZzsmiO4dOgnqaE7isNnXE3jgpMpsW7vwAu39J0hKph1sJtDoHE4 ZzLZsOrFUgaDtrtB2U/hwA5T29s+5n6VcJSZIwMN8cZerCQy3kbD9PZeL1RhA5PAfO3vV //VARD8PLRqpCZquSGGkIEiLputUGwxZEv38puh4AxHj62SERDawj4i+uiQPI2clnoA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MQaTVn0T; 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 C4A3A606A31A for ; Tue, 1 Dec 2026 03:06:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MQaTVn0T Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F9CA1F000C1; Tue, 1 Dec 2026 03:06:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796094398; bh=VevCn9ztBRpUE9PTM7FEBbRi9gdst4yCznFh3sRZAdE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=MQaTVn0TVNHzqGxHAIViF4KjdUSP4wpcF46AGRRUn5u3f6PuWqWBMv/xtlHtbT0nJ EkYVZL745zhp6cdqZPqQRG268csRP9VzLZSN9tnPkcMR1CHXl6IrYsAqlvZub0bMH8 i7L4GoAD4hcIOtuJE2j7T2HkU3XsS16W5U7R53hzraKOSLPBhssFQsxn4q5JL4BrzI GJdUfloiXw9rWabfKjcdkL3dL9OIwSQasjKoDWjUyOd8JfC0494I3P8uAESnJF2oHv lZ2o9a038ywnno+nn/6Lv5NbtsQecvBMzGxWaQXGYHCv2QwToF/DIpCKO1wXKjKaFp xMP9+8CZ8UnhA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 1/4] crypto: qce - Bound AEAD input DMA to the programmed segment Reply-To: sashiko-reviews@lists.linux.dev To: "Wenjia Zhang" , "Bartosz Golaszewski" , "Herbert Xu" , "David S. Miller" Cc: linux-crypto@vger.kernel.org, "Wenjia Zhang" In-Reply-To: <20261201-codex-qce-dma-bounds-upstream-20261201-v1-1-c15d01b45bce@oss.qualcomm.com> References: <20261201-codex-qce-dma-bounds-upstream-20261201-v1-0-c15d01b45bce@oss.qualcomm.com> <20261201-codex-qce-dma-bounds-upstream-20261201-v1-1-c15d01b45bce@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 03:06:37 +0000 X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] crypto: qce - unbounded src_sg on in-place CCM decrypt in qce_aead_ccm_prepare_buf() - [Low] crypto: qce - missing Fixes trailer in commit message -- commit f3b55d49bd062185aa02d0a7a7eedf329e6ab5f7 Author: Wenjia Zhang > crypto: qce - Bound AEAD input DMA to the programmed segment > > An AEAD source scatterlist can contain bytes beyond the input segment, > such as space reserved for an output authentication tag. > sg_nents_for_len() counts the entries covering a length but does not > shorten the final entry. Mapping the original list can therefore pass > those trailing bytes to BAM, exceeding the programmed crypto segment and > causing transfer errors or timeouts. > > Build a bounded source table for separately mapped input lists, > referencing the original pages and limiting the final entry to the > required length. Validate the total mapped input length against the > configured segment. Include the authentication tag for CCM decryption, > where hardware consumes it, but exclude it for authenc decryption, where > software verifies it. > > Handle the zero return from dma_map_sg() as a mapping failure and > release the allocated scatterlist tables on completion and preparation > or submission errors. > > Signed-off-by: Wenjia Zhang [Severity: Low] Since this fixes AEAD DMA mapping bugs, should it include a Fixes tag for 9363efb4181c ("crypto: qce - Add support for AEAD algorithms")? > diff --git a/drivers/crypto/qce/aead.c b/drivers/crypto/qce/aead.c > index 2065c46162c21..793913b33da6f 100644 > --- a/drivers/crypto/qce/aead.c > +++ b/drivers/crypto/qce/aead.c [ ... ] > @@ -336,8 +350,9 @@ static int qce_aead_ccm_prepare_buf(struct aead_reque= st *req) > =20 > cryptlen =3D rctx->cryptlen + ctx->authsize; > if (diff_dst) { > - rctx->src_nents =3D sg_nents_for_len(req->src, cryptlen); > - rctx->src_sg =3D req->src; > + ret =3D qce_aead_prepare_src_buf(req, cryptlen); > + if (ret) > + return ret; > sg =3D qce_aead_prepare_dst_buf(req); > if (IS_ERR(sg)) > return PTR_ERR(sg); [Severity: Medium] Does the !diff_dst branch just below this leave rctx->src_sg and rctx->dst_sg unbounded for in-place CCM decryption with zero assoclen? drivers/crypto/qce/aead.c:qce_aead_ccm_prepare_buf() { ... } else { rctx->src_nents =3D sg_nents_for_len(req->src, cryptlen); rctx->src_sg =3D req->src; rctx->dst_nents =3D rctx->src_nents; rctx->dst_sg =3D rctx->src_sg; } ... } Because req->src is used directly without clamping the final entry to cryptlen, any trailing bytes in the scatterlist remain mapped, causing the new qce_aead_check_input() check to see dma_len !=3D expected and reject the request with -EINVAL. The !diff_dst branch also skips checking for a negative return from sg_nents_for_len(), which would pass -EINVAL as nents to dma_map_sg() if req->src is shorter than cryptlen. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-codex-qce-= dma-bounds-upstream-20261201-v1-0-c15d01b45bce@oss.qualcomm.com?part=3D1