[PATCH v15 25/35] arm64: dts: amlogic: axg: add crypto node

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Dec 2 02:58:08 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] crypto: amlogic: spurious 0-byte DMA desc in
  meson_hasher_do_one_request()
--

commit d6413ff29b6f1b6e862879e118ab3c6eaef958f4
Author: Alexey Romanov <romanov.alexey2000 at gmail.com>

arm64: dts: amlogic: axg: add crypto node

This commit adds the crypto engine device tree node to meson-axg.dtsi to
enable hardware SHA1/224/256 and AES support on Amlogic AXG SoCs.

> diff --git a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
> index 5b8ef98f6d03b..e755a019b384b 100644
> --- a/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
> +++ b/arch/arm64/boot/dts/amlogic/meson-axg.dtsi
> @@ -321,6 +321,13 @@ ethmac: ethernet at ff3f0000 {
>  			status = "disabled";
>  		};
>  
> +		crypto: crypto at ff63e000 {
> +			compatible = "amlogic,axg-crypto";
> +			reg = <0x0 0xff63e000 0x0 0x48>;
> +			interrupts = <GIC_SPI 180 IRQ_TYPE_EDGE_RISING>;
> +			clocks = <&clkc CLKID_CLK81>;
> +		};
> +
>  		pcie_phy: phy at ff644000 {
>  			compatible = "amlogic,axg-pcie-phy";
>  			reg = <0x0 0xff644000 0x0 0x1c>;

[Severity: High]
In commit "crypto: amlogic - Introduce hasher" earlier in this series, can
meson_hasher_do_one_request() emit and execute a spurious 0-byte DMA
descriptor with t_src = 0 during non-final SHA updates?

drivers/crypto/amlogic/amlogic-gxl-hasher.c:meson_hasher_do_one_request() {
	...
	for (;;) {
		...
		meson_setup_state_descs(&ctx);

		if (rctx->partial_size && rctx->partial_size < blocksize) {
			ret = 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 = len;
			ctx.nbytes -= len;
			ctx.src_offset += len;
		} else if (len) {
			...
		}
		...
		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 = meson_kick_hardware(&ctx);
			if (ret)
				goto fail;
		}
	}
}

When a non-final meson_sha_update() request has a length greater than
blocksize that is not a multiple of blocksize (for example, 100 bytes),
the first iteration queues the 64-byte block into flow->tl[0] without
DESC_LAST and increments ctx.tloffset to 1.  The second iteration copies
the remaining 36 bytes into rctx->partial, leaving ctx.nbytes = 0,
ctx.todo = 0, and ctx.src_addr = 0.  Because ctx.tloffset is non-zero, all
three continue checks fail and meson_setup_data_descs() appends a 0-byte
descriptor at t_src = 0 with DESC_LAST before kicking the hardware,
corrupting the intermediate hash state.

The same fallthrough happens on a subsequent sub-block update after
rctx->begin_req is false, because meson_setup_state_descs() increments
ctx.tloffset before the remaining bytes are buffered into rctx->partial
with ctx.todo = 0.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202100714.115460-1-jnieto.alaber@gmail.com?part=25



More information about the linux-amlogic mailing list