[PATCH v15 17/35] crypto: amlogic - Add support for A1-series
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Dec 2 03:01:50 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] crypto: amlogic - 0-length SHA DMA descriptor on partial update
--
commit be66e1e9ce951d55cbc35bb5ee6540ded856ef0f
Author: Alexey Romanov <romanov.alexey2000 at gmail.com>
crypto: amlogic - Add support for A1-series
This commit adds platform data and device tree compatible strings for the
Amlogic A1 and S4 crypto engines, with hardware hasher support enabled.
> diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c
> index 08d89db14788a..3a6bac10bb04b 100644
> --- a/drivers/crypto/amlogic/amlogic-gxl-core.c
> +++ b/drivers/crypto/amlogic/amlogic-gxl-core.c
> @@ -298,6 +298,14 @@ static const struct meson_pdata meson_axg_pdata = {
> .support_192bit_key = true,
> };
>
> +static const struct meson_pdata meson_a1_pdata = {
> + .descs_reg = 0x0,
> + .status_reg = 0x8,
> + .setup_desc_cnt = 1,
> + .hasher_supported = true,
> + .support_192bit_key = false,
> +};
[Severity: High]
With hasher_supported enabled here, can a non-final SHA update request
with a trailing partial block kick a 0-length DMA descriptor reading from
physical address 0x0 in meson_hasher_do_one_request()?
For example, when an update request passes 74 bytes (one 64-byte block
plus 10 trailing bytes), the first loop iteration queues the 64-byte data
descriptor (incrementing ctx.tloffset) without kicking hardware because
ctx.nbytes is still 10. On the second iteration, the remaining 10 bytes
are copied into rctx->partial, leaving ctx.nbytes = 0, ctx.todo = 0, and
ctx.src_addr = 0:
drivers/crypto/amlogic/amlogic-gxl-hasher.c:meson_hasher_do_one_request() {
...
} 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.tloffset is non-zero, neither continue branch is taken, and
meson_setup_data_descs() appends an extra descriptor with length 0,
t_src = 0, and DESC_LAST before kicking the hardware, corrupting the SHA
state or causing a DMA error. The same happens on a subsequent small
update after hardware has already run once (rctx->begin_req is false),
because meson_setup_state_descs() sets ctx.tloffset = setup_desc_cnt
before checking whether a full block is ready to be processed.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202100714.115460-1-jnieto.alaber@gmail.com?part=17
More information about the linux-amlogic
mailing list