2005-12-25 18:08:00

by Kees Cook

[permalink] [raw]
Subject: [PATCH] lib: zlib_inflate "r.base" uninitialized compile warnings

Eliminates compile-time warnings from "r" being uninitialized.

Signed-of-by: Kees Cook <[email protected]>

---

--- linux-2.6.15-rc7/lib/zlib_inflate/inftrees.c.orig 2005-12-25 09:51:01.000000000 -0800
+++ linux-2.6.15-rc7/lib/zlib_inflate/inftrees.c 2005-12-25 09:46:06.000000000 -0800
@@ -196,6 +196,7 @@ static int huft_build(
u[0] = NULL; /* just to keep compilers happy */
q = NULL; /* ditto */
z = 0; /* ditto */
+ r.word.pad = r.base = 0; /* ditto */

/* go through the bit lengths (k already is bits in shortest code) */
for (; k <= g; k++)


--
Kees Cook @outflux.net


2005-12-25 18:34:17

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH] lib: zlib_inflate "r.base" uninitialized compile warnings

On Sun, Dec 25, 2005 at 10:07:58AM -0800, Kees Cook wrote:
> Eliminates compile-time warnings from "r" being uninitialized.

NAK. That sort of patches is only going to hide real problems in the
code where such warnings are _not_ false positives.

Let me put it that way: what bug are you fixing in that patch? Is
there a codepath that would lead to use of r without initialization?
If there is - show it; if there is not - why are you patching kernel
and not gcc?

2005-12-25 20:08:03

by James Lamanna

[permalink] [raw]
Subject: Re: [PATCH] lib: zlib_inflate "r.base" uninitialized compile warnings

Kees Cook wrote:

> Eliminates compile-time warnings from "r" being uninitialized.
>

What version of gcc are you using?

I get no warnings on 3.4.4:
CC [M] lib/zlib_inflate/infblock.o
CC [M] lib/zlib_inflate/infcodes.o
CC [M] lib/zlib_inflate/inffast.o
CC [M] lib/zlib_inflate/inflate.o
CC [M] lib/zlib_inflate/inflate_sync.o
CC [M] lib/zlib_inflate/inftrees.o
CC [M] lib/zlib_inflate/infutil.o
CC [M] lib/zlib_inflate/inflate_syms.o
LD [M] lib/zlib_inflate/zlib_inflate.o
Building modules, stage 2.
MODPOST
CC lib/zlib_inflate/zlib_inflate.mod.o
LD [M] lib/zlib_inflate/zlib_inflate.ko

agard linux-2.6.15-rc7 # gcc --version
gcc (GCC) 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)

Looks like a gcc bug that was fixed?

2005-12-25 20:35:37

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] lib: zlib_inflate "r.base" uninitialized compile warnings

On Sun, Dec 25, 2005 at 12:08:00PM -0800, James Lamanna wrote:
> What version of gcc are you using?

gcc (GCC) 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)

> Looks like a gcc bug that was fixed?

I guess it's been introduced. ;)

--
Kees Cook @outflux.net

2005-12-25 20:39:36

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] lib: zlib_inflate "r.base" uninitialized compile warnings

On Sun, Dec 25, 2005 at 06:34:06PM +0000, Al Viro wrote:
> NAK. That sort of patches is only going to hide real problems in the
> code where such warnings are _not_ false positives.
>
> Let me put it that way: what bug are you fixing in that patch? Is
> there a codepath that would lead to use of r without initialization?
> If there is - show it; if there is not - why are you patching kernel
> and not gcc?

Well, good point. My only question would be: why are other
"uninitialized" variables masked in the same way in that code?

Also, perhaps the phrasing in SubmittingPatches should be changed.
Currently (for "trivial" patches) it says:

Warning fixes (cluttering with useless warnings is bad)

Is that warning considered "useful"? Should this hint, instead, read:

Warning fixes (make sure the warning is "real", if not, patch gcc)

:)

--
Kees Cook @outflux.net

2005-12-25 20:43:16

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH] lib: zlib_inflate "r.base" uninitialized compile warnings

On Sun, Dec 25, 2005 at 12:35:32PM -0800, Kees Cook wrote:
> On Sun, Dec 25, 2005 at 12:08:00PM -0800, James Lamanna wrote:
> > What version of gcc are you using?
>
> gcc (GCC) 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)
>
> > Looks like a gcc bug that was fixed?
>
> I guess it's been introduced. ;)

4.0.x is very bad in that area - it's crying "wolf" a _lot_ and genuine
cases of uninitialized variables being used are drowning in the noise;
compared to 3.x it's a serious regression.