All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Phillip Lougher <phillip@lougher.demon.co.uk>
Cc: Linux Kernel Development <linux-kernel@vger.kernel.org>,
	Jesper Juhl <jj@chaosbits.net>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Squashfs: Fix use of uninitialised variable in zlib & xz decompressors
Date: Tue, 25 Jan 2011 21:45:02 +0100	[thread overview]
Message-ID: <AANLkTim_BRoaK1a0wQT=NZZH5yQ87YPf+KiwO08yOFar@mail.gmail.com> (raw)
In-Reply-To: <4D3F1D2A.9040309@lougher.demon.co.uk>

On Tue, Jan 25, 2011 at 19:57, Phillip Lougher
<phillip@lougher.demon.co.uk> wrote:
> Geert Uytterhoeven wrote:
>>
>> On Tue, Jan 25, 2011 at 02:33, Phillip Lougher
>> <phillip@lougher.demon.co.uk> wrote:
>>>
>>> Incidentally, on most architectures (bar Mips and Parisc), no
>>> uninitialised variable warning is generated by gcc, this is because
>>> the while condition test on continue is optimised out and not performed
>>> (when executing continue zlib_err has not been changed since entering the
>>> loop, and logically if the while condition was true previously, then it's
>>> still true).
>>
>> As this is a "do { ... } while (...);" construct and not a "while
>> (...) { ... }" construct,
>> the condition is not checked before doing the first iteration. Furthermore
>> the
>> "continue" may happen during the first iteration (this depends on
>> parameters
>> passed to the function), so the compiler cannot make any assumptions about
>> the
>> value of zlib_err, except that may be uninitialized.
>>
>
> No, I've checked the assembly language produced - the while condition test
> has
> been optimised out in the case of continue.
>
> This is the assembly language output for x86_64, the relevant
> bits manually annotated by me,

While the continue skips the test at the end of the loop, that doesn't
change the
fact that zlib_err was never initialized in the first place.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

      reply	other threads:[~2011-01-25 20:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25  1:33 [PATCH] Squashfs: Fix use of uninitialised variable in zlib & xz decompressors Phillip Lougher
2011-01-25 17:09 ` Geert Uytterhoeven
2011-01-25 18:57   ` Phillip Lougher
2011-01-25 20:45     ` Geert Uytterhoeven [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='AANLkTim_BRoaK1a0wQT=NZZH5yQ87YPf+KiwO08yOFar@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=akpm@linux-foundation.org \
    --cc=jj@chaosbits.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@lougher.demon.co.uk \
    /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.