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=1796210177; b=QC8Rt1Am9k+gW8xtiovb+HElrB16fvJX/sfvQG+Wr6/AtsJvYjMfzPfZucquEzXN55iO F83kyh2xUIH5iZsFuly+ZwrKjdEXhpFJyNxTzZFDtShXeiwgSy+yBhOGa2dx8C6YPpace PT7sbyA1E/ydrTjBgXcvW7dt/g4EV8UkMGeM4TjIuV2iRZD8US/rrn5rrxZbu0qfNEWDW /BmLbT26EzqnpDfcf508dpGdqdZJqdklcNI5CjQp0Og+PAPYazGUtKANUWkxr/iJkIY59 kNksU7IBwNEZqEq2IJlxXwao1T06FkNaszffW04iiyhcFRig2pa2Vxn8twjUdFksL5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796210177; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=48vZUQfv/wHhpPQQFcY1q0/r4DDrn3pV4z6AGb1wQJQ=; b=boawCxTP6CgMeDlp+RnBBRbjdl+jGms8y0/kF2ei95i1U3c5oEUrQZSLHQQsry/M1WVR ULf445ntCVWdCcncJjZIn4B9IBHFJHBKR7VSPMev/VZlCEjiMP5JSVpEo/IOLgvISE/7T D0JCZhS7PwLRQM75XcTYGkpig8YWK+DXHUzbqcikAPGcqe/3DdVnS6v+3zqJ3xaFUDm7N r5PiZUP1VM/hpIEOzy8GppqhssKjSytLJ80oAzk4kYIfDIyyy3jRulcLfpxHQCM86cmhv 7zLMrRyi6Cxo2aPuZ+ZKzpdrdmPqcAXQ6h/KcA8vBOFEGqy70yF8Nww/OXMJVjK4cuQ== 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=fiIWudzc; 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 51C2E606A31A; Wed, 2 Dec 2026 11:16:17 +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=fiIWudzc Received: by smtp.kernel.org (Postfix) with ESMTPSA id A908E1F00893; Wed, 2 Dec 2026 11:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796210177; bh=48vZUQfv/wHhpPQQFcY1q0/r4DDrn3pV4z6AGb1wQJQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=fiIWudzcejJIZny0vylRyFsWr0uq9en2thMKOQM6qM3vDs5kTLcywKp5LfSpBSkud RXZ9WFnRop14pDucYUqQV+fDV9JeZBbYu/ouD5/q4fr+JHyJyxbYf+/ckpV9Ey300N /svaMOVrXfV9UukzIah+1lkIJ7jiVKkGj+ZQlfiogqQy1MmYxpyow49ojA9WymFJpB frLTFlsMy4rZTJvPZy7IdN1Qf+DY2twokLHftRKfYUghTBTqehOgHDK+oeQETsMTk8 DJh2aehISb9/FkEmpnoqloIRiJoSJlLk1XwhqYCWbr/8OjOv3UdvffmXujqJrNBFsu HsiLVqap8sWOg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v15 24/35] arm64: dts: amlogic: g12: add crypto node Reply-To: sashiko-reviews@lists.linux.dev To: "Jose Nieto" , "Corentin Labbe" , "Herbert Xu" , "David S . Miller" Cc: linux-crypto@vger.kernel.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, "Neil Armstrong" , "Kevin Hilman" , "Jerome Brunet" , "Martin Blumenstingl" , "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "Alexey Romanov" In-Reply-To: <20261202101036.116145-4-jnieto.alaber@gmail.com> References: <20261202100714.115460-1-jnieto.alaber@gmail.com> <20261202101036.116145-1-jnieto.alaber@gmail.com> <20261202101036.116145-4-jnieto.alaber@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 11:16:16 +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: - [High] crypto: amlogic: zero-byte SHA DMA descriptor in meson_hasher_do_one_request() -- commit 18b8829be9e0e0ec6161e2647564d932e0a23c0f Author: Alexey Romanov arm64: dts: amlogic: g12: add crypto node This series adds hardware SHA1, SHA224, and SHA256 hashing support to the Amlogic crypto driver and enables the crypto controller on Amlogic G12, A1, and S4 SoCs. > diff --git a/drivers/crypto/amlogic/amlogic-gxl-hasher.c b/drivers/crypto= /amlogic/amlogic-gxl-hasher.c > new file mode 100644 > index 0000000000000..978cdcd8a4f91 > --- /dev/null > +++ b/drivers/crypto/amlogic/amlogic-gxl-hasher.c [ ... ] > +static unsigned int meson_setup_data_descs(struct hasher_ctx *ctx) > +{ > + struct ahash_request *req =3D ahash_request_cast(ctx->areq); > + struct meson_hasher_req_ctx *rctx =3D ahash_request_ctx(req); > + struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(req); > + struct meson_hasher_tfm_ctx *tctx =3D crypto_ahash_ctx_dma(tfm); > + struct meson_dev *mc =3D tctx->mc; > + struct meson_flow *flow =3D &mc->chanlist[rctx->flow]; > + struct hash_alg_common *alg =3D crypto_hash_alg_common(tfm); > + struct meson_alg_template *algt =3D container_of(alg, > + struct meson_alg_template, alg.ahash.base.halg); > + struct meson_desc *desc =3D &flow->tl[ctx->tloffset]; > + u32 v; > + > + ctx->tloffset++; > + > + v =3D DESC_OWN | DESC_ENCRYPTION | DESC_OPMODE_SHA | > + ctx->todo | algt->blockmode; > + if (rctx->begin_req) { > + rctx->begin_req =3D false; > + v |=3D DESC_BEGIN; > + } > + > + if (!ctx->nbytes && rctx->final_req) { > + rctx->final_req =3D false; > + v |=3D DESC_END; > + } > + > + if (!ctx->nbytes || ctx->tloffset =3D=3D MAXDESC || rctx->partial_mappe= d) > + v |=3D DESC_LAST; > + > + desc->t_src =3D cpu_to_le32(ctx->src_addr); > + desc->t_dst =3D cpu_to_le32(ctx->state_addr); > + desc->t_status =3D cpu_to_le32(v); > + > + return v & DESC_LAST; > +} [ ... ] > +static int meson_hasher_do_one_request(struct crypto_engine *engine, voi= d *areq) > +{ [ ... ] > + for (;;) { > + unsigned int len =3D ctx.src_sg ? > + min(sg_dma_len(ctx.src_sg) - ctx.src_offset, ctx.nbytes) : 0; > + > + ctx.src_addr =3D 0; > + ctx.todo =3D 0; > + > + if (!rctx->final_req && !ctx.nbytes) > + break; > + > + meson_setup_state_descs(&ctx); > + > + if (rctx->partial_size && rctx->partial_size < blocksize) { > + ret =3D meson_fill_partial_buffer(&ctx, len); > + if (ret) > + goto fail; > + } else if (len && len < blocksize) { > + memcpy(rctx->partial, sg_virt(ctx.src_sg) + ctx.src_offset, len); > + > + rctx->partial_size =3D len; > + ctx.nbytes -=3D len; > + ctx.src_offset +=3D len; > + } else if (len) { > + ctx.src_addr =3D sg_dma_address(ctx.src_sg) + ctx.src_offset; > + ctx.todo =3D min(rounddown(DESC_MAXLEN, blocksize), > + rounddown(len, blocksize)); > + ctx.nbytes -=3D ctx.todo; > + ctx.src_offset +=3D ctx.todo; > + } > + > + if (ctx.src_sg && ctx.src_offset =3D=3D sg_dma_len(ctx.src_sg)) { > + ctx.src_offset =3D 0; > + ctx.src_sg =3D sg_next(ctx.src_sg); > + } > + > + if (!ctx.todo && ctx.nbytes) > + continue; > + > + if (!ctx.todo && rctx->final_req && rctx->partial_size) > + continue; > + > + if (!ctx.todo && !rctx->final_req && !ctx.tloffset) > + continue; > + > + if (meson_setup_data_descs(&ctx)) { > + ret =3D meson_kick_hardware(&ctx); > + if (ret) > + goto fail; > + } > + } [Severity: High] Can meson_hasher_do_one_request() append a spurious 0-byte SHA DMA descriptor with t_src =3D=3D 0 and kick the hardware during an incremental crypto_ahash_update() call? When an update request has both full blocks and trailing sub-block bytes (for example, 70 bytes =3D 64 + 6), the first iteration queues the 64-byte descriptor in meson_setup_data_descs() without setting DESC_LAST because ctx->nbytes is still 6, leaving ctx.tloffset > 0. On the next iteration, the remaining 6 bytes are copied into rctx->partial, setting ctx.nbytes to 0 while ctx.todo and ctx.src_addr remain 0. The same state is reached on a subsequent update call (after rctx->begin_req has been cleared) that only buffers sub-block data into rctx->partial: meson_setup_state_descs() runs before the partial-buffer check and advances ctx.tloffset by mc->pdata->setup_desc_cnt, after which ctx.nbytes becomes 0 with ctx.todo =3D=3D 0. In both cases, ctx.todo is 0, ctx.nbytes is 0, rctx->final_req is false, and ctx.tloffset is non-zero. None of the three continue conditions match, so meson_setup_data_descs() writes a 0-length SHA descriptor at physical address 0 with DESC_LAST set and meson_kick_hardware() submits it to the DMA engine, corrupting the hash state. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202100714.1154= 60-1-jnieto.alaber@gmail.com?part=3D24