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=1796094150; b=lfTJlm1gC9TiYmPfEySf7YXFVPGKLFT7ujCpnxccoKGJE3hbftz3vnzVzvJ64miFcROX PO/n7hoQiiZBuTRygf3I52egsOEVrKfD363CpcnN8TnZgvyuq+QFKTw5pcpeFgnQOom0e yKhekd/FTpTn61xP9QhzY9RZ5i5KLj5xznOnioWFVFM9xmMsoC8fOlOeVugzTf/ttkFIX tByye3zFuMzGMGqr21pDjb8yXBhM4BOv0Q0p/zEfJ1sUJa0iFGFMo+wHY2Wn7Dm7iQrb4 99+BiX9OiobQXl24oIocwQPlvxRMkw8plhvmYgKuu5tur0TZxQClUi+OspBv09oDGnw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796094150; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=FfX/0hrCwKJ+oh0gDab5rgQTRij1GbnUPJ3gwGOrj0o=; b=SwzMQFJA81v7RLl9BfjUH0p9y2BjxSJDhL6W8wJiHAWODzBDP9XMCarba7okdazagX9q yhnFnifQ3p+Fu+pmU+ZBMP+RhGTXP1ddYOM3wKUtTadMZsdTs75ZFwOr6jElfCPObgfrL CMnqhFrmVAY3bdYkAwA143M7tfj7cxvxuNT4gnoMc6u6zeyosZZGXur8PTUU3Oy/i5Ad3 1f9PdjcWPlZj4s4pT4/n0h0d/OwWCHVFCQVhwDMntbN8ow6cFDQ02qfCtIqkBZtCHH3t5 o9YO965/C0VEaiQlCzpjAXczH0AN9uVTjBAVabygqezQdNSGXP/JNKKHBqdfDt+RrtQ== 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=Y8QQ3na5; 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 D8F63606A31A for ; Tue, 1 Dec 2026 03:02:30 +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=Y8QQ3na5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A03D1F00897; Tue, 1 Dec 2026 03:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796094150; bh=FfX/0hrCwKJ+oh0gDab5rgQTRij1GbnUPJ3gwGOrj0o=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Y8QQ3na5V6B9wN8CrJwhDecKeLNISBdo3/q30QOzip4uwT9jByhaktTqxrdvOjEcq lax7UgSSnGQ221l59J5ohvz6kc7Kgrb9gRz4q8GBIsoqT7gXWrvVrDHg+t6ntWCyL1 RccfIg9m5nPv5HWLGCgg8uh7QxQ/9O/b964ctjETZuxEGcdBOlpA0B+mXI4rErJC5n vGKjreH4N0cW2k1TRCNbDek5DcaZECUZR9/veeNp4xwFBcBXmA/Qw4VqvV0J2Yd7qn lU8PZPKfiVX/kHLEusY2E9heD+CtPmQPqwPweaTWChrJhF69rjYhzcIDIxHkvHBe4e bCJO4uDT6Q26w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 3/4] crypto: qce - Bound ahash input DMA to the current 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-3-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-3-c15d01b45bce@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 03:02:29 +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: missing CRYPTO_ALG_ALLOCATES_MEMORY in qce_ahash_register_one() - [Low] crypto: qce: missing Fixes trailer for ahash input DMA bounding fix -- commit 1b196f099887dc46df99e46259af8be85b93abbd Author: Wenjia Zhang > crypto: qce - Bound ahash input DMA to the current segment > > Hash updates submit complete blocks and retain any remaining bytes for a > later submission. Reducing req->nbytes to the current segment does not > shorten the source scatterlist. sg_nents_for_len() only counts entries, > so mapping the last entry in full can send the retained bytes to BAM as > well. The DMA input then exceeds the programmed hash segment and the > request can fail. > > Build a source table bounded to req->nbytes for each hardware submission > and validate its total mapped length. Pass the mapped entry count to DMA > descriptor preparation, while retaining the original entry count for > unmapping. > > Free the table on completion and submission failure, and restore the > caller's original source list and byte count if submission fails. > > Signed-off-by: Wenjia Zhang [Severity: Low] Since this fixes a bug present since the driver was added, should it include a Fixes tag? Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver") > diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c > index 3dca00e53e473..1f7ed0e15afdf 100644 > --- a/drivers/crypto/qce/sha.c > +++ b/drivers/crypto/qce/sha.c > @@ -31,6 +31,47 @@ static const u32 std_iv_sha256[SHA256_DIGEST_SIZE / si= zeof(u32)] =3D { > SHA256_H4, SHA256_H5, SHA256_H6, SHA256_H7 > }; > =20 > +static int qce_ahash_prepare_src(struct ahash_request *req) > +{ > + struct qce_sha_reqctx *rctx =3D ahash_request_ctx_dma(req); > + struct scatterlist *sg; > + gfp_t gfp; > + int ret; > + > + rctx->src_nents =3D sg_nents_for_len(req->src, req->nbytes); > + if (rctx->src_nents <=3D 0) > + return rctx->src_nents ?: -EINVAL; > + > + gfp =3D (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? > + GFP_KERNEL : GFP_ATOMIC; > + ret =3D sg_alloc_table(&rctx->src_tbl, rctx->src_nents, gfp); [Severity: Medium] Should qce_ahash_register_one() now set CRYPTO_ALG_ALLOCATES_MEMORY in base->cra_flags (like qce_skcipher_register_one() and qce_aead_register_one() do)? qce_ahash_prepare_src() now calls sg_alloc_table() during request processing, while qce_ahash_register_one() still sets only CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY. Block I/O callers such as dm-integrity that mask out CRYPTO_ALG_ALLOCATES_MEMORY when calling crypto_alloc_ahash() can bind to QCE ahash algorithms and trigger GFP_KERNEL allocations from a GFP_NOIO block I/O context when CRYPTO_TFM_REQ_MAY_SLEEP is set, risking memory reclaim recursion deadlocks. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-codex-qce-= dma-bounds-upstream-20261201-v1-0-c15d01b45bce@oss.qualcomm.com?part=3D3