Skip to contentSkip to conversation

crypto: sunxi - don't print uninitialized data

PATCH Superseded Arnd Bergmann 2 participants 3 messages Jan 25, 2016 – Jan 26, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 crypto: sunxi - don't print uninitialized data

gcc correctly warns that the printk output contains a variable that is not initialized in some cases:

drivers/crypto/sunxi-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_cipher_poll':
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:254:76: warning: 'todo' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:144:15: note: 'todo' was declared here

This adds an explicit initialization to zero in the exact case where it was missing, to avoid leaking stack data to the console and to shut up that warning.

---
 drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +2 -0
index a19ee127edca..db52ae16c147 100644
@@ -246,6 +246,8 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
 				sg_miter_next(&mi);
 				oi = 0;
 			}
+		} else {
+			todo = 0;
 		}
 
 		spaces = readl(ss->base + SS_FCSR);
Signature · 1 line
2.7.0
#1 lore raw
Quoted 7 lines · On Monday 25 January 2016 17:53:48 Arnd Bergmann wrote:

gcc correctly warns that the printk output contains a variable that is not initialized in some cases:

drivers/crypto/sunxi-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_cipher_poll':
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:254:76: warning: 'todo' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:144:15: note: 'todo' was declared here

Quoted 6 lines

This adds an explicit initialization to zero in the exact case where it was missing, to avoid leaking stack data to the console and to shut up that warning.

Sorry for the broken ordering and missing cover letter. I just submitted three crypto patches:

[PATCH 1/4] crypto: sunxi - don't print uninitialized data [PATCH] crypto: hash - select CRYPTO_HASH where needed [PATCH 1/2] crypto: jitterentropy - always select CRYPTO_RNG

These address independent build issues, and there is no ordering between them. None of them are important, so please queue them up for 4.6.

Arnd

maintainer
#2 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

gcc correctly warns that the printk output contains a variable that is not initialized in some cases:

drivers/crypto/sunxi-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_cipher_poll':
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:254:76: warning: 'todo' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:144:15: note: 'todo' was declared here

Quoted 5 lines

This adds an explicit initialization to zero in the exact case where it was missing, to avoid leaking stack data to the console and to shut up that warning.

This is actually a bogus warning because todo is always initialised but gcc can't see that because it's behind multiple conditionals.

It would be great if we can restructure the code so that gcc can see this while at the same time also improving the readability of the loop.

Otherwise just initialise it at the top or use uninitialised_var.

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt