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=1796094104; b=Y6346vpQYDUY5QTsiAY9HPPpQLfG7P8njffqRzNkynbjD6aOZsM2jzNz+RJlV2+Tc1dT /z+l7CR05VnCiCt4GTgCxMONOUpWW2rmq90DXMZw9XNGifoj1r+mzoY9jRUtFVeL0RVNY 7YSvOZVN0UvH4SexQRT8aKAwNL8bJgmcYkiUqPIQvSDZkWsvctShXzmqPwoKtdWmR2rfs VxGrkRnB9/UyRgPjBqSWt/lOaF+gMstc+HJGZX30hLl1JZqUO8Qod4D/id1dS9kGDglEd p0ruiRdCMYlyP3POZFHxtiAPRP+Umn+2mA6sNe2HrtfScJ4StruGyFNPyYq7VZFFD0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796094104; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=J1wvo6p7whWAI1qqU92OUsEvEjt50ThBtKY9AzvCS6Q=; b=HMEAQlvdEsWQCStN914QqhPl7OO8/HWFDkrdW+HN3BzkzNQ6Ll1T4rZExzArKe4r8+mQ ME1Xz0M4Omx6XGIOYz/6sTcVssqb1whKhprQEmi2XdJPrWBXP89ZTENyYOtnwtcwqHuhy uyAKArtnXYY2V282Jz2pwHSh2W7DTKFtL9jAZpmMcLBtH/WuPC5NeoVdaLG9PP8y9BF5H doasYqqLDN80jDueNHntX+B5FoOqUHV9M677jnBNW6JxI+KWBNi4r96o/4nYb3+Dk8gYj U2fOX/iaIrEqWu1l203N6/bSr4O5mki+pw/wjjm7QLje30OQ3jKoz3mcLabj9Bur0BQ== 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=cviYPXVg; 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 8E98D606A31A for ; Tue, 1 Dec 2026 03:01:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cviYPXVg Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7D8F1F000C1; Tue, 1 Dec 2026 03:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796094104; bh=J1wvo6p7whWAI1qqU92OUsEvEjt50ThBtKY9AzvCS6Q=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=cviYPXVguwgCn8TczyYj3n5NpQz8ubF3lqnM+XWyF32jKoArQJABO/Zt5lvW2jaa8 NySzdhjfPfi3goQdtju58QTsR6IL9w8xdVo5qAhY11eo+HzAGJ90ctuBiYurTI1dSd lsrw28IJs6UO+VE7gOA1KkHzcPwc6++awknnRwHg3wxakoRRJrGE6wx/pRb5HmiNBK fPL5xKWEq+EmFWruP+YsYDfYPeEq96uB+xEOn94N5k/7QyLokAQFUth93f3/hOeg1+ uUN27KRhbR1ocQ0mR7xsIkxfQtiZVeT13Uc/8+il/9Zg7TewnHBd0077Ii3uZXeJ1G 4fxr0fSDYdj+A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 4/4] crypto: qce - Bound skcipher input DMA to cryptlen 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-4-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-4-c15d01b45bce@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 03:01:43 +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 1 potential issue to consider: - [Low] crypto: qce: missing Fixes trailer for unbounded req->src DMA mapping It also noticed 1 related pre-existing issue this patch does not introduce: - [Critical] crypto: qce: error code inversion in qce_skcipher_async_req_handle() [1] -- commit a975096f0c2cdacb9670c485b8f959458f058af4 Author: Wenjia Zhang > crypto: qce - Bound skcipher input DMA to cryptlen > > When a skcipher request uses different source and destination lists, the > driver maps the source entries returned by sg_nents_for_len(). That > helper does not shorten the last entry to cryptlen. A request whose > final entry extends beyond the payload therefore sends excess data to > BAM and can fail because the input exceeds the programmed segment. This > also affects in-place requests using two lists for the same pages. > > Build a separate source table bounded to cryptlen for this path, > referencing the existing pages without copying the payload. Validate the > total mapped input length before starting the engine, including the path > that shares the destination mapping. > > Unmap the owned source table and free it on completion and every > submission error path. > > Signed-off-by: Wenjia Zhang [Severity: Low] Since this fixes unbounded DMA mapping of req->src that has been present since the driver was introduced, should this include a Fixes tag? Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver") > diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c > index 7067c4c20c1e7..150a140287df5 100644 > --- a/drivers/crypto/qce/skcipher.c > +++ b/drivers/crypto/qce/skcipher.c [ ... ] > @@ -131,17 +169,25 @@ qce_skcipher_async_req_handle(struct crypto_async_r= equest *async_req) > } > =20 > if (diff_dst) { > - src_nents =3D dma_map_sg(qce->dma_dev, req->src, rctx->src_nents, dir_= src); > + ret =3D qce_skcipher_prepare_src(req, gfp); > + if (ret) > + goto error_unmap_dst; [Severity: Critical] This problem wasn't introduced by this patch, but earlier in qce_skcipher_async_req_handle() [1], doesn't returning -rctx->dst_nents when rctx->dst_nents < 0 invert the negative error code from sg_nents_for_len() into a positive value? drivers/crypto/qce/skcipher.c:qce_skcipher_async_req_handle() { ... if (rctx->dst_nents < 0) { dev_err(qce->dev, "Invalid numbers of dst SG.\n"); return -rctx->dst_nents; } ... } When a request provides a destination scatterlist shorter than req->cryptlen, sg_nents_for_len() returns -EINVAL, and negating it causes callers such as AF_ALG to treat the failed request as a positive byte count and read uninitialized destination memory. [1] https://sashiko.dev/#/bug/linux-0ba52c88-bdb7-4c9e-8c47-2ec58cfe9437 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-codex-qce-= dma-bounds-upstream-20261201-v1-0-c15d01b45bce@oss.qualcomm.com?part=3D4