[PATCH v15 16/35] crypto: amlogic - Add support for AXG-series

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Dec 2 02:44:00 PST 2026


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

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

crypto: amlogic - Add support for AXG-series

This commit adds platform data and the device tree match entry for the
Amlogic AXG crypto accelerator, enabling hardware hashing with three setup
descriptors.

> diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c
> index 0fb0da20e06b2..08d89db14788a 100644
> --- a/drivers/crypto/amlogic/amlogic-gxl-core.c
> +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c
> @@ -290,6 +290,14 @@ static const struct meson_pdata meson_g12a_pdata = {
>  	.support_192bit_key = false,
>  };
>  
> +static const struct meson_pdata meson_axg_pdata = {
> +	.descs_reg = 0x0,
> +	.status_reg = 0x8,
> +	.setup_desc_cnt = 3,
> +	.hasher_supported = true,
> +	.support_192bit_key = true,
> +};

[Severity: High]
Can enabling hasher_supported here submit a bogus 0-byte SHA DMA descriptor
from physical address 0 in meson_hasher_do_one_request() during incremental
crypto_ahash_update() calls, corrupting the hash state?

On any non-final update after the first block has been hashed (so
rctx->begin_req and rctx->final_req are both false),
meson_setup_state_descs() runs at the start of the loop and advances
ctx.tloffset by setup_desc_cnt (3 on AXG) before checking whether a full
block is ready.  When the update only provides len < blocksize bytes, the
loop copies them into rctx->partial and sets ctx.nbytes to 0, leaving
ctx.todo and ctx.src_addr at 0 while ctx.tloffset is non-zero:

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;
		}
    ...
		if (!ctx.todo && ctx.nbytes)
			continue;

		if (!ctx.todo && !rctx->final_req && !ctx.tloffset)
			continue;

		if (meson_setup_data_descs(&ctx)) {
			ret = meson_kick_hardware(&ctx);
    ...
}

Because ctx.nbytes is 0 and ctx.tloffset is non-zero, both continue checks
are skipped and meson_setup_data_descs() queues and kicks a 0-length data
descriptor with ctx.src_addr == 0.  Later commit "crypto: amlogic: hasher:
add one-shot digest path" adds a check for rctx->final_req, but non-final
updates still fall through.

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



More information about the linux-amlogic mailing list