Re: [PATCH] crypto: tegra - Fix empty message check on cmac final()
From: Thierry Reding
Date: Sun Dec 06 2026 - 06:18:51 EST
> The fallback tfm is being called on tegra_cmac_do_final() with the assumption
> that the message with nbytes == 0 is empty, however tegra_cmac_do_update()
> always keeps the last block of the message, full or partial, in the residue
> buffer for tegra_cmac_do_final(), while req->nbytes is always set to 0 by
> crypto_ahash_final(), meaning we have a request with nbytes == 0 but
> residue.size > 0.
>
> Checked on a NVIDIA Orin IGX system during its self-test:
>
> alg: ahash: tegra-se-cmac test failed (wrong result) on test vector 1,
> cfg="init+update+final aligned buffer"
> alg: self-tests for cmac(aes) using tegra-se-cmac failed (rc=-22)
>
> And no self-tests failures after the patch applied. From /proc/crypto:
>
> driver : tegra-se-cmac
> module : tegra_se
> ...
> selftest : passed
>
> This commit changes the check to use the residue size instead of req->nbytes and
> also free the residue buffer on the fallback path, which was being skipped,
> leaking it on every CMAC of an empty message.
>
> Fixes: 0880bb3b00c8 ("crypto: tegra - Add Tegra Security Engine driver")
> Cc: stable@xxxxxxxxxxxxxxx
> Suggested-by: Thomas Huth <thuth@xxxxxxxxxx>
> Signed-off-by: Bruno Meneguele <bmeneg@xxxxxxxxxx>
Seems fine:
Acked-by: Thierry Reding <treding@xxxxxxxxxx>
--
Thierry Reding <treding@xxxxxxxxxx>