[PATCH v15 22/35] arm64: dts: amlogic: a1: add crypto node
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Dec 2 03:04:42 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] crypto: amlogic: spurious 0-byte DMA descriptor kicked on
non-final update()
--
commit ff964c96b4100428730593b5607575d70a5cdce6
Author: Alexey Romanov <romanov.alexey2000 at gmail.com>
arm64: dts: amlogic: a1: add crypto node
This commit adds the crypto engine and clk81 device tree nodes for Amlogic
A1 SoCs to enable hardware SHA and AES acceleration.
> diff --git a/arch/arm64/boot/dts/amlogic/meson-a1.dtsi b/arch/arm64/boot/dts/amlogic/meson-a1.dtsi
> index 6f6a6145cba12..396260b7b3989 100644
> --- a/arch/arm64/boot/dts/amlogic/meson-a1.dtsi
> +++ b/arch/arm64/boot/dts/amlogic/meson-a1.dtsi
> @@ -686,6 +686,14 @@ sd_emmc: mmc at 10000 {
> assigned-clocks = <&clkc_periphs CLKID_SD_EMMC>;
> assigned-clock-rates = <24000000>;
> };
> +
> + crypto: crypto at 6000 {
> + compatible = "amlogic,a1-crypto";
> + reg = <0x0 0x6000 0x0 0x48>;
> + interrupts = <GIC_SPI 120 IRQ_TYPE_EDGE_RISING>;
> + clocks = <&clk81>;
> + power-domains = <&pwrc PWRC_DMA_ID>;
> + };
> };
[Severity: High]
Can a non-final SHA update() in the hasher driver (added earlier in this
series in commit "crypto: amlogic - Introduce hasher") queue and kick a
spurious 0-byte DMA descriptor at physical address 0?
drivers/crypto/amlogic/amlogic-gxl-hasher.c:meson_hasher_do_one_request() {
...
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;
}
}
For a non-final update() whose length is greater than one 64-byte block
but not a multiple of 64 (for example, 100 bytes), the first iteration
queues the 64-byte block at flow->tl[0], increments ctx.tloffset, and
leaves ctx.nbytes = 36. Because ctx.nbytes is non-zero,
meson_setup_data_descs() does not set DESC_LAST and does not kick the
hardware.
In the next iteration, the remaining 36 bytes are copied into
rctx->partial, setting ctx.nbytes = 0 while ctx.todo = 0 and
ctx.src_addr = 0. Because ctx.nbytes is 0, rctx->final_req is false, and
ctx.tloffset is non-zero, none of the three continue checks match.
Execution falls through to meson_setup_data_descs() and
meson_kick_hardware(), appending an extra 0-byte SHA descriptor with
t_src = 0 and DESC_LAST (without DESC_END) that corrupts the hardware SHA
digest state. The same happens on any subsequent non-final update()
shorter than blocksize once rctx->begin_req is false, because
meson_setup_state_descs() advances ctx.tloffset before buffering the tail
bytes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202100714.115460-1-jnieto.alaber@gmail.com?part=22
More information about the linux-amlogic
mailing list