Skip to contentSkip to conversation

authenc compile warnings in current net-2.6.24

DISCUSSION Oliver Hartkopp 4 participants 7 messages Oct 10, 2007 – Oct 11, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Herbert,

CC [M] crypto/authenc.o
crypto/authenc.c: In function ‘crypto_authenc_hash’:
crypto/authenc.c:88: warning: ‘cryptlen’ may be used uninitialized in this function crypto/authenc.c:87: warning: ‘dst’ may be used uninitialized in this function crypto/authenc.c: In function ‘crypto_authenc_decrypt’:
crypto/authenc.c:163: warning: ‘cryptlen’ may be used uninitialized in this function crypto/authenc.c:163: note: ‘cryptlen’ was declared here crypto/authenc.c:162: warning: ‘src’ may be used uninitialized in this function crypto/authenc.c:162: note: ‘src’ was declared here

do you already know these warnings?

Oliver

#1 lore raw
Quoted 14 lines · * Oliver Hartkopp | 2007-10-10 19:53:53 [+0200]:

CC [M] crypto/authenc.o
crypto/authenc.c: In function ?crypto_authenc_hash?:
crypto/authenc.c:88: warning: ?cryptlen? may be used uninitialized in this function
crypto/authenc.c:87: warning: ?dst? may be used uninitialized in this function
crypto/authenc.c: In function ?crypto_authenc_decrypt?:
crypto/authenc.c:163: warning: ?cryptlen? may be used uninitialized in this function
crypto/authenc.c:163: note: ?cryptlen? was declared here crypto/authenc.c:162: warning: ?src? may be used uninitialized in this function
crypto/authenc.c:162: note: ?src? was declared here

Quoted 1 line

do you already know these warnings?

Those warnings are looking like a compiler bug to me.

Quoted 1 line

Oliver

Sebastian

maintainer
#2 lore raw

From: Sebastian Siewior <[email protected]>
Date: Wed, 10 Oct 2007 21:53:37 +0200

Quoted 16 lines · * Oliver Hartkopp | 2007-10-10 19:53:53 [+0200]:
Quoted 15 lines

CC [M] crypto/authenc.o
crypto/authenc.c: In function ?crypto_authenc_hash?:
crypto/authenc.c:88: warning: ?cryptlen? may be used uninitialized in this function
crypto/authenc.c:87: warning: ?dst? may be used uninitialized in this function
crypto/authenc.c: In function ?crypto_authenc_decrypt?:
crypto/authenc.c:163: warning: ?cryptlen? may be used uninitialized in this function
crypto/authenc.c:163: note: ?cryptlen? was declared here crypto/authenc.c:162: warning: ?src? may be used uninitialized in this function
crypto/authenc.c:162: note: ?src? was declared here

Quoted 3 lines
Quoted 1 line

do you already know these warnings?

Those warnings are looking like a compiler bug to me.

It's just not smart enough to see that cryptlen's initialization and it's use in the auth_unlock label path are both protected by 'err' being non-zero.

To be honest I don't know of any compiler which commits enough flow variable analysis to support doing %100 accurate warnings in situations like this.

Since the compiler is unlikely to do so, I think we should fix it somehow because useless warnings just distract.

maintainer
#3 lore raw
Quoted 11 lines · David Miller

It's just not smart enough to see that cryptlen's initialization and it's use in the auth_unlock label path are both protected by 'err' being non-zero.

To be honest I don't know of any compiler which commits enough flow variable analysis to support doing %100 accurate warnings in situations like this.

Since the compiler is unlikely to do so, I think we should fix it somehow because useless warnings just distract.

Yeah I've added a fix in the cryptodev tree.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#4 lore raw
Quoted 2 lines · Herbert Xu

Yeah I've added a fix in the cryptodev tree.

Oh and here's the actual patch.

Cheers,

Signature · 6 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
1cd6038ce42447f9a32e6d138af0b69ad56ea627
crypto/authenc.c +4 -8
index 0b29a6a..126a529 100644
@@ -84,8 +84,8 @@ static int crypto_authenc_hash(struct aead_request *req)
 		.tfm = auth,
 	};
 	u8 *hash = aead_request_ctx(req);
-	struct scatterlist *dst;
-	unsigned int cryptlen;
+	struct scatterlist *dst = req->dst;
+	unsigned int cryptlen = req->cryptlen;
 	int err;
 
 	hash = (u8 *)ALIGN((unsigned long)hash + crypto_hash_alignmask(auth), 
@@ -100,8 +100,6 @@ static int crypto_authenc_hash(struct aead_request *req)
 	if (err)
 		goto auth_unlock;
 
-	cryptlen = req->cryptlen;
-	dst = req->dst;
 	err = crypto_hash_update(&desc, dst, cryptlen);
 	if (err)
 		goto auth_unlock;
@@ -159,8 +157,8 @@ static int crypto_authenc_verify(struct aead_request *req)
 	};
 	u8 *ohash = aead_request_ctx(req);
 	u8 *ihash;
-	struct scatterlist *src;
-	unsigned int cryptlen;
+	struct scatterlist *src = req->src;
+	unsigned int cryptlen = req->cryptlen;
 	unsigned int authsize;
 	int err;
 
@@ -177,8 +175,6 @@ static int crypto_authenc_verify(struct aead_request *req)
 	if (err)
 		goto auth_unlock;
 
-	cryptlen = req->cryptlen;
-	src = req->src;
 	err = crypto_hash_update(&desc, src, cryptlen);
 	if (err)
 		goto auth_unlock;
#5 lore raw
In reply to David Miller
Quoted 19 lines · * David Miller | 2007-10-10 16:25:28 [-0700]:

From: Sebastian Siewior <[email protected]>
Date: Wed, 10 Oct 2007 21:53:37 +0200

Quoted 16 lines · * Oliver Hartkopp | 2007-10-10 19:53:53 [+0200]:
Quoted 15 lines

CC [M] crypto/authenc.o
crypto/authenc.c: In function ?crypto_authenc_hash?:
crypto/authenc.c:88: warning: ?cryptlen? may be used uninitialized in this function
crypto/authenc.c:87: warning: ?dst? may be used uninitialized in this function
crypto/authenc.c: In function ?crypto_authenc_decrypt?:
crypto/authenc.c:163: warning: ?cryptlen? may be used uninitialized in this function
crypto/authenc.c:163: note: ?cryptlen? was declared here crypto/authenc.c:162: warning: ?src? may be used uninitialized in this function
crypto/authenc.c:162: note: ?src? was declared here

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

do you already know these warnings?

Those warnings are looking like a compiler bug to me.

To be honest I don't know of any compiler which commits enough flow variable analysis to support doing %100 accurate warnings in situations like this.

gcc (GCC) 4.1.2 (Gentoo 4.1.2) did not produce any warnings in this case.

Quoted 2 lines

Since the compiler is unlikely to do so, I think we should fix it somehow because useless warnings just distract.

sure.

Sebastian

#6 lore raw
Quoted 24 lines · Sebastian Siewior
Quoted 21 lines · * David Miller | 2007-10-10 16:25:28 [-0700]:

From: Sebastian Siewior <[email protected]>
Date: Wed, 10 Oct 2007 21:53:37 +0200

Quoted 17 lines · * Oliver Hartkopp | 2007-10-10 19:53:53 [+0200]:
Quoted 12 lines

CC [M] crypto/authenc.o
crypto/authenc.c: In function ?crypto_authenc_hash?:
crypto/authenc.c:88: warning: ?cryptlen? may be used uninitialized in this function crypto/authenc.c:87: warning: ?dst? may be used uninitialized in this function crypto/authenc.c: In function ?crypto_authenc_decrypt?:
crypto/authenc.c:163: warning: ?cryptlen? may be used uninitialized in this function crypto/authenc.c:163: note: ?cryptlen? was declared here crypto/authenc.c:162: warning: ?src? may be used uninitialized in this function crypto/authenc.c:162: note: ?src? was declared here

Quoted 2 lines

do you already know these warnings?

Those warnings are looking like a compiler bug to me.

Quoted 9 lines
Quoted 4 lines

To be honest I don't know of any compiler which commits enough flow variable analysis to support doing %100 accurate warnings in situations like this.

gcc (GCC) 4.1.2 (Gentoo 4.1.2) did not produce any warnings in this case.

Hi Sebasian,

my gcc was the lastest Debian unstable one:

gcc -v

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-targets=all --disable-werror --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix
gcc version 4.2.1 (Debian 4.2.1-5)

Regards,
Oliver