mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Phillip Lougher <phillip@lougher.demon.co.uk>
Cc: akpm@linux-foundation.org, Geert.Uytterhoeven@sonycom.com,
	linux-kernel@vger.kernel.org, s.L-H@gmx.de
Subject: Re: [GIT-PULL] More Squashfs fixes for 2.6.29?
Date: Wed, 11 Mar 2009 12:50:58 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.00.0903111237410.32478@localhost.localdomain> (raw)
In-Reply-To: <E1LhU3m-0001f1-Cw@dylan.lougher.demon.co.uk>



On Wed, 11 Mar 2009, Phillip Lougher wrote:
> 
> Squashfs: Valid filesystems are flagged as bad by the corrupted fs patch
> 
> The problem arises due to an unexpected corner-case with zlib which the
> corrupted filesystems patch didn't address.  Very occasionally zlib
> exits needing a couple of extra bytes of input (up to 6 seen bytes in the
> test filesystems), but with avail_out == 0 and no more output buffer
> space available.  This situation was incorrectly flagged as an output buffer
> overrun by the corrupted filesystems patch.

I'm almost certain that this situation is caused by a bug in how you call 
zlib().

You've explicitly asked for Z_NO_FLUSH, and I suspect you should be using 
Z_SYNC_FLUSH (of Z_FINISH if you know you have all the input data). You 
want as much to be inflated as possible, and you do seem to be expecting 
it to flush as much as possible. 

However, I think the more direct cause is your inflate loop. The rules for 
running inflate() is to call it until it is done, or returns an error:

    inflate() should normally be called until it returns Z_STREAM_END or an
  error. However if all decompression is to be performed in a single step
  (a single call of inflate), the parameter flush should be set to
  Z_FINISH.

so you seem to be doing this all wrong. I think you _should_ be doing an 
inner loop over zlib_inflate() that just does inflates until you get a 
buffer error, and if you get a buffer error you then go on to the next 
page if avail_out is zero (all done if it's the last page), or fill the 
input buffer if it's empty.

So I really think you should fix the zlib_inflate() loop instead.

I dunno. At least that's what the docs suggest, and it's what we do in 
git (another heavy user of zlib, althoughb the usage patterns are rather 
different, and we _tend_ to 

			Linus

  reply	other threads:[~2009-03-11 19:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11 19:25 Phillip Lougher
2009-03-11 19:50 ` Linus Torvalds [this message]
2009-03-12  0:11   ` Phillip Lougher
2009-03-12  0:39     ` Linus Torvalds
2009-03-12  0:59       ` Phillip Lougher

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=alpine.LFD.2.00.0903111237410.32478@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=Geert.Uytterhoeven@sonycom.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@lougher.demon.co.uk \
    --cc=s.L-H@gmx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®