All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: chinayanlei2002@163.com
Cc: herbert@gondor.apana.org.au, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
	linux-crypto@vger.kernel.org, Yan Lei <yan_lei@dahuatech.com>
Subject: Re: [PATCH] x86: crypto: fix Using uninitialized value walk.flags
Date: Mon, 18 Apr 2022 12:30:11 -0700	[thread overview]
Message-ID: <Yl28Qyy1hP+5Scjx@sol.localdomain> (raw)
In-Reply-To: <20220410060757.4009-1-chinayanlei2002@163.com>

On Sun, Apr 10, 2022 at 02:07:57PM +0800, chinayanlei2002@163.com wrote:
> From: Yan Lei <yan_lei@dahuatech.com>
> 
> ----------------------------------------------------------
> Using uninitialized value "walk.flags" when calling "skcipher_walk_virt".
> 
> Signed-off-by: Yan Lei <yan_lei@dahuatech.com>
> ---
>  arch/x86/crypto/sm4_aesni_avx_glue.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/crypto/sm4_aesni_avx_glue.c b/arch/x86/crypto/sm4_aesni_avx_glue.c
> index 7800f77d6..417e3bbfe 100644
> --- a/arch/x86/crypto/sm4_aesni_avx_glue.c
> +++ b/arch/x86/crypto/sm4_aesni_avx_glue.c
> @@ -40,7 +40,7 @@ static int sm4_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
>  
>  static int ecb_do_crypt(struct skcipher_request *req, const u32 *rkey)
>  {
> -	struct skcipher_walk walk;
> +	struct skcipher_walk walk = { 0 };
>  	unsigned int nbytes;
>  	int err;
>  

This caller is no different from any other caller of skcipher_walk_virt().  So
this is not the proper place to fix this.  Can you do the following instead?

	1. Audit all callers of skcipher_walk_virt() to verify that they would be
	   okay with walk->flags being initialized to 0.  I.e., verify that no
	   callers are intentionally initializing the flags to something else.

	2. Update skcipher_walk_virt() to initialize walk->flags to 0, rather
	   than doing 'walk->flags &= ~SKCIPHER_WALK_PHYS' as it does currently.

- Eric

      reply	other threads:[~2022-04-18 19:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-10  6:07 [PATCH] x86: crypto: fix Using uninitialized value walk.flags chinayanlei2002
2022-04-18 19:30 ` Eric Biggers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yl28Qyy1hP+5Scjx@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=bp@alien8.de \
    --cc=chinayanlei2002@163.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=yan_lei@dahuatech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.