From: Lasse Collin <lasse.collin@tukaani.org>
To: Phillip Lougher <phillip@lougher.demon.co.uk>,
Kyle McMartin <kyle@infradead.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] xz: make XZ_DEC_BCJ filters non-optional
Date: Wed, 5 Mar 2014 18:24:22 +0200 [thread overview]
Message-ID: <20140305182422.767a6cbe@tukaani.org> (raw)
In-Reply-To: <53169123.4020909@lougher.demon.co.uk>
On 2014-03-05 Phillip Lougher wrote:
> (BTW Kyle you should have CC'd me on the patch as a courtesy).
I could have done that too but somehow I didn't, sorry.
> But speaking as the Squashfs author, the lack of BCJ support for
> an architecture creates a subtle failure mode in Squashfs, this is
> because not all blocks in a Squashfs filesystem get compressed
> with a BCJ filter. At compression time each block is compressed
> without any BCJ filter, and then with the BCJ filter(s) selected on
> the command line, and the best compression for *that* block is
> chosen. What this means is kernels without a particular
> BCJ filter can still read the Squashfs metadata (mount, ls etc.) and
> read many of the files, it is only some files that mysteriously
> fail with decompression error. As such this will be (and has been)
> invariably treated as a bug in Squashfs.
There is an easy way to make Squashfs give an error message in the
kernel log. xz_dec_run() gives XZ_OPTIONS_ERROR when valid-looking but
unsupported input is detected. Currently Squashfs treats all error
codes from xz_dec_run() the same way so the reason for the
decompression error is silently lost.
Below is an *untested* fix. I'm not sure about the exact wording of the
error message, so feel free to improve it.
diff -Narup linux-3.14-rc5.orig/fs/squashfs/xz_wrapper.c linux-3.14-rc5/fs/squashfs/xz_wrapper.c
--- linux-3.14-rc5.orig/fs/squashfs/xz_wrapper.c 2014-03-03 04:56:16.000000000 +0200
+++ linux-3.14-rc5/fs/squashfs/xz_wrapper.c 2014-03-05 18:08:58.729643127 +0200
@@ -170,8 +170,13 @@ static int squashfs_xz_uncompress(struct
squashfs_finish_page(output);
- if (xz_err != XZ_STREAM_END || k < b)
+ if (xz_err != XZ_STREAM_END || k < b) {
+ if (xz_err == XZ_OPTIONS_ERROR)
+ ERROR("Unsupported XZ-compressed data; check the XZ "
+ "options in the kernel config\n");
+
goto out;
+ }
return total + stream->buf.out_pos;
> Moreover, without expert knowledge of Squashfs, and the config
> options, most people will not have a clue how to fix the issue.
>
> This is why I prefer the first option, which is to reinstate
> the enabling of all filters by default, and then to allow people
> to remove the filters they don't want.
I will submit the first option. In the other email Florian Fainelli
seemed to be OK with that too.
> BTW there is a potential additional fix for Squashfs that will
> make its handling of (lack of) BCJ filters more intelligent
> at mount time, but this of course only addresses Squashfs,
> and it relies on an additional call into XZ being added. The
> BCJ filters specified at filesystem creation are stored in the
> compression options part of the superblock, and are known at
> mount time. Squashfs should check that these filters are
> supported by the kernel and refuse to mount it otherwise. This
> has not been done because AFAIK there is no way to query XZ to
> determine which BCJ filters are supported (beyond passing it a
> test stream which is too messy).
You can use #ifdef CONFIG_XZ_DEC_X86 and such, although maybe that's
not convenient enough.
Adding a function to xz_dec module could be sort of OK. It's important
to keep in mind that the ability to disable filters is there to reduce
code size *slightly*. If you or we add something extra to figure out
what is supported at runtime, the size benefit may get lost.
If all filters are enabled by default, a clear error message on
XZ_OPTIONS_ERROR should be enough, I think.
--
Lasse Collin | IRC: Larhzu @ IRCnet & Freenode
next prev parent reply other threads:[~2014-03-05 16:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 23:00 [PATCH] xz: make XZ_DEC_BCJ filters non-optional Kyle McMartin
2014-03-03 12:51 ` Lasse Collin
2014-03-03 17:34 ` Florian Fainelli
2014-03-04 18:20 ` Lasse Collin
[not found] ` <53169123.4020909@lougher.demon.co.uk>
2014-03-05 3:50 ` Florian Fainelli
2014-03-06 20:37 ` Geert Uytterhoeven
2014-03-08 10:11 ` Lasse Collin
2014-03-08 10:24 ` Geert Uytterhoeven
2014-03-05 16:24 ` Lasse Collin [this message]
2014-03-12 0:07 ` 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=20140305182422.767a6cbe@tukaani.org \
--to=lasse.collin@tukaani.org \
--cc=akpm@linux-foundation.org \
--cc=f.fainelli@gmail.com \
--cc=kyle@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=phillip@lougher.demon.co.uk \
--cc=torvalds@linux-foundation.org \
/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