Re: [PATCH 0/7] crypto: Proper Initialization of `struct skcipher_walk` in x86 Glue Files

From: Eric Biggers
Date: Thu Nov 02 2023 - 00:20:51 EST


Hi Yuran,

On Thu, Nov 02, 2023 at 09:34:08AM +0530, Yuran Pereira wrote:
> In multiple `*_encrypt`, `*_crypt`, `*_decrypt` functions within the x86/crypto
> glue files, the `skcipher_walk` structs being used are not properly initialized
> prior their usage which can lead to undefined behaviour if the `flags` field of
> this structure were to contain junk values at the time of its usage.
>
> This patch series ensures that instances of `struct skcipher_walk` are correctly
> initialized across different x86/crypto glue files.
>
> Yuran Pereira (7):
> crypto: Fixes uninitialized skcipher_walk use in sm4_aesni_avx_glue
> crypto: Fixes uninitialized skcipher_walk use in des3_ede_glue
> crypto: Fixes uninitialized skcipher_walk use in chacha_glue
> crypto: Fixes uninitialized skcipher_walk use in aesni-intel_glue
> crypto: Fixes uninitialized skcipher_walk use in aria_aesni_avx2_glue
> crypto: Fixes uninitialized skcipher_walk use in aria_aesni_avx_glue
> crypto: Fixes uninitialized skcipher_walk use in aria_gfni_avx512_glue

Updating all callers of skcipher_walk_virt() seems like the wrong approach.
Shouldn't skcipher_walk_virt() be fixed to initialize the flags to 0 instead?

Also, does this fix affect any behavior, or is it just to fix a KMSAN warning?
It needs to be fixed either way, but it's helpful to understand the effect of
the fix so that people can decide whether it needs to be backported or not.

- Eric