linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/aesni: fix uninit value for skcipher_walk
@ 2024-11-27 23:43 Ragavendra
  2024-11-27 23:55 ` Eric Biggers
  0 siblings, 1 reply; 2+ messages in thread
From: Ragavendra @ 2024-11-27 23:43 UTC (permalink / raw)
  To: herbert, davem, tglx, mingo, bp, dave.hansen, hpa
  Cc: x86, linux-crypto, linux-kernel, Ragavendra

In crypto/aesni-intel_glue.c most declarations of struct
skcipher_walk are unitialized. This causes one of the values
in the struct to be left uninitialized in the later usages.

This patch fixes it by adding initializations to the struct
skcipher_walk walk variable.

Fixes bugs reported in the Coverity scan with CID 139545,
1518179, 1585019 and 1598915.

Signed-off-by: Ragavendra Nagraj <ragavendra.bn@gmail.com>
---
---
 arch/x86/crypto/aesni-intel_glue.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index b0dd83555499..168edb21a6c4 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -398,7 +398,7 @@ static int ctr_crypt(struct skcipher_request *req)
 	struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
 	struct crypto_aes_ctx *ctx = aes_ctx(crypto_skcipher_ctx(tfm));
 	u8 keystream[AES_BLOCK_SIZE];
-	struct skcipher_walk walk;
+	struct skcipher_walk walk = {};
 	unsigned int nbytes;
 	int err;
 
@@ -447,7 +447,7 @@ static int xctr_crypt(struct skcipher_request *req)
 	struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
 	struct crypto_aes_ctx *ctx = aes_ctx(crypto_skcipher_ctx(tfm));
 	u8 keystream[AES_BLOCK_SIZE];
-	struct skcipher_walk walk;
+	struct skcipher_walk walk = {};
 	unsigned int nbytes;
 	unsigned int byte_ctr = 0;
 	int err;
@@ -517,7 +517,7 @@ xts_crypt_slowpath(struct skcipher_request *req, xts_crypt_func crypt_func)
 	int tail = req->cryptlen % AES_BLOCK_SIZE;
 	struct scatterlist sg_src[2], sg_dst[2];
 	struct skcipher_request subreq;
-	struct skcipher_walk walk;
+	struct skcipher_walk walk = {};
 	struct scatterlist *src, *dst;
 	int err;
 
@@ -1339,7 +1339,7 @@ gcm_crypt(struct aead_request *req, int flags)
 	struct crypto_aead *tfm = crypto_aead_reqtfm(req);
 	const struct aes_gcm_key *key = aes_gcm_key_get(tfm, flags);
 	unsigned int assoclen = req->assoclen;
-	struct skcipher_walk walk;
+	struct skcipher_walk walk = {};
 	unsigned int nbytes;
 	u8 ghash_acc[16]; /* GHASH accumulator */
 	u32 le_ctr[4]; /* Counter in little-endian format */
-- 
2.46.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/aesni: fix uninit value for skcipher_walk
  2024-11-27 23:43 [PATCH] x86/aesni: fix uninit value for skcipher_walk Ragavendra
@ 2024-11-27 23:55 ` Eric Biggers
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2024-11-27 23:55 UTC (permalink / raw)
  To: Ragavendra
  Cc: herbert, davem, tglx, mingo, bp, dave.hansen, hpa, x86,
	linux-crypto, linux-kernel

On Wed, Nov 27, 2024 at 03:43:47PM -0800, Ragavendra wrote:
> In crypto/aesni-intel_glue.c most declarations of struct
> skcipher_walk are unitialized. This causes one of the values
> in the struct to be left uninitialized in the later usages.
> 
> This patch fixes it by adding initializations to the struct
> skcipher_walk walk variable.
> 
> Fixes bugs reported in the Coverity scan with CID 139545,
> 1518179, 1585019 and 1598915.
> 
> Signed-off-by: Ragavendra Nagraj <ragavendra.bn@gmail.com>

This should be fixed in skcipher_walk_virt(), not in every caller.

- Eric

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-27 23:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-27 23:43 [PATCH] x86/aesni: fix uninit value for skcipher_walk Ragavendra
2024-11-27 23:55 ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).