Bug 953723

Summary: mksquashfs corrupts files
Product: [openSUSE] openSUSE Distribution Reporter: Stefan Seyfried <seife>
Component: BasesystemAssignee: Torsten Duwe <duwe>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: astieger, bwiedemann, dsterba, duwe, maint-coord, ms
Version: 13.2   
Target Milestone: ---   
Hardware: x86-64   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Stefan Seyfried 2015-11-05 08:10:43 UTC
IMPORTANT: I have seen this both on 13.2 and on a patched SLES12 installation (no wonder, they have the same version of squashfs :-)

While working with KIWI (OEM image, deployed either via PXE or as an ISO), I got spurious checksum errors when unpacking the image. A rebuild of the image often fixed the issue.
Until yesterday, when there was no possibility to create a working image anymore.
I was assuming something changed with my KIWI setup or a bug in kiwi.
I investigated the issue and it comes down to the following:

vbox-seife:~/oem # cat SLES_12_image1.x86_64-0.3.4.md5 
b6a50a9e4a509b40ee192ee977cc5b48   312192 8192
vbox-seife:~/oem # md5sum SLES_12_image1.x86_64-0.3.4.raw 
b6a50a9e4a509b40ee192ee977cc5b48  SLES_12_image1.x86_64-0.3.4.raw
vbox-seife:~/oem # mksquashfs SLES_12_image1.x86_64-0.3.4.raw SLES_12_image1.x86_64-0.3.4.md5 /tmp/SLES_12_image1.x86_64-0.3.4.raw.squashfs -no-progress
Parallel mksquashfs: Using 2 processors
Creating 4.0 filesystem on /tmp/SLES_12_image1.x86_64-0.3.4.raw.squashfs, block size 131072.

Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
        compressed data, compressed metadata, compressed fragments, compressed xattrs
        duplicates are removed
Filesystem size 642142.91 Kbytes (627.09 Mbytes)
        25.71% of uncompressed filesystem size (2497612.67 Kbytes)
Inode table size 42177 bytes (41.19 Kbytes)
        53.94% of uncompressed inode table size (78188 bytes)
Directory table size 59 bytes (0.06 Kbytes)
        64.13% of uncompressed directory table size (92 bytes)
Number of duplicate files found 0
Number of inodes 3
Number of files 2
Number of fragments 2
Number of symbolic links  0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 1
Number of ids (unique uids + gids) 1
Number of uids 1
        root (0)
Number of gids 1
        root (0)
vbox-seife:~/oem # mount -t squashfs /tmp/SLES_12_image1.x86_64-0.3.4.raw.squashfs /mnt/
vbox-seife:~/oem # md5sum /mnt/SLES_12_image1.x86_64-0.3.4.raw 
4f2653aea2424557a4341d1416d21389  /mnt/SLES_12_image1.x86_64-0.3.4.raw

So the file got altered when packing up with mksquashfs.

vbox-seife:~/oem # cmp -l /mnt/SLES_12_image1.x86_64-0.3.4.raw SLES_12_image1.x86_64-0.3.4.raw |head -1
2557459969   0 110
vbox-seife:~/oem # dd if=SLES_12_image1.x86_64-0.3.4.raw skip=$((2557459969/512))|hexdump -C
33+0 records in
33+0 records out
16896 bytes (17 kB) copied, 0.000102726 s, 164 MB/s
00000000  48 61 68 21 49 64 6f 6e  74 4e 65 65 64 45 46 49  |Hah!IdontNeedEFI|
00000010  f1 d9 c8 c6 e2 3f bd 48  89 b6 17 29 bc 94 dd 67  |.....?.H...)...g|
00000020  00 08 00 00 00 00 00 00  03 18 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  6c 00 65 00 67 00 61 00  |........l.e.g.a.|
00000040  63 00 79 00 00 00 00 00  00 00 00 00 00 00 00 00  |c.y.............|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000080  28 73 2a c1 1f f8 d2 11  ba 4b 00 a0 c9 3e c9 3b  |(s*......K...>.;|
00000090  f6 f0 20 26 9a 16 1e 40  a7 03 f1 5a ea c8 80 90  |.. &...@...Z....|
000000a0  00 20 00 00 00 00 00 00  03 60 06 00 00 00 00 00  |. .......`......|
000000b0  00 00 00 00 00 00 00 00  55 00 45 00 46 00 49 00  |........U.E.F.I.|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000100  a2 a0 d0 eb e5 b9 33 44  87 c0 68 b6 b7 26 99 c7  |......3D..h..&..|
00000110  8b 4b b5 64 5c 86 ab 49  87 f5 13 a2 ba 7b 8f 98  |.K.d\..I.....{..|
00000120  00 68 06 00 00 00 00 00  03 c8 0f 00 00 00 00 00  |.h..............|
00000130  00 00 00 00 00 00 00 00  6c 00 78 00 62 00 6f 00  |........l.x.b.o.|
00000140  6f 00 74 00 00 00 00 00  00 00 00 00 00 00 00 00  |o.t.............|
00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000180  a2 a0 d0 eb e5 b9 33 44  87 c0 68 b6 b7 26 99 c7  |......3D..h..&..|
00000190  b2 0b ef 75 36 86 a4 4f  8a 7c 42 20 08 af 33 28  |...u6..O.|B ..3(|
000001a0  00 d0 0f 00 00 00 00 00  80 37 4c 00 00 00 00 00  |.........7L.....|
000001b0  00 00 00 00 00 00 00 00  6c 00 78 00 6c 00 76 00  |........l.x.l.v.|
000001c0  6d 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |m...............|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00004000  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00004010  82 ba 8f 32 00 00 00 00  ff 37 4c 00 00 00 00 00  |...2.....7L.....|
00004020  01 00 00 00 00 00 00 00  22 00 00 00 00 00 00 00  |........".......|
00004030  de 37 4c 00 00 00 00 00  8e 28 e4 1a a7 84 ae 48  |.7L......(.....H|
00004040  b2 d1 ff 8a 8b 14 2c 11  df 37 4c 00 00 00 00 00  |......,..7L.....|
00004050  80 00 00 00 80 00 00 00  3f cd f4 5d 00 00 00 00  |........?..]....|
00004060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00004200
vbox-seife:~/oem # dd if=/mnt/SLES_12_image1.x86_64-0.3.4.raw skip=$((2557459969/512))|hexdump -C
33+0 records in
33+0 records out
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00004200
16896 bytes (17 kB) copied, 0.000606308 s, 27.9 MB/s

The last ~16.5kB are just zeroes.

I then looked at the upstream git and found this:
http://sourceforge.net/p/squashfs/code/ci/de03266983ceb62e5365aac84fcd3b2fd4d16e6f/

Note that this bug is present in at least 13.2 and SLES12, and looking at the package I have no reason to believe it is not in Factory/Tumbleweed.
Comment 1 Stefan Seyfried 2015-11-05 08:35:01 UTC
Unfortunately, this one patch is not enough, it seems like http://sourceforge.net/p/squashfs/code/ci/9c1db6 is also needed.
Comment 2 Stefan Seyfried 2015-11-05 08:51:19 UTC
a mkquashfs with both patches applies fixes the issue for me:

vbox-seife:~/oem # mksquashfs SLES_12_image1.x86_64-0.3.4.raw SLES_12_image1.x86_64-0.3.4.md5 /tmp/SLES_12_image1.x86_64-0.3.4.raw.squashfs -no-progress
Parallel mksquashfs: Using 2 processors
Creating 4.0 filesystem on /tmp/SLES_12_image1.x86_64-0.3.4.raw.squashfs, block size 131072.
[...]
vbox-seife:~/oem # mount -t squashfs /tmp/SLES_12_image1.x86_64-0.3.4.raw.squashfs /mnt/
vbox-seife:~/oem # md5sum /mnt/SLES_12_image1.x86_64-0.3.4.raw 
b6a50a9e4a509b40ee192ee977cc5b48  /mnt/SLES_12_image1.x86_64-0.3.4.raw

i submitted a fixed version to filesystems repo, SR#342512

Would be nice to get this as an update for released products, including SLES12 :-)
Comment 3 Stefan Seyfried 2015-11-05 10:51:31 UTC
Adding David to CC, as he accepted my submitrequest :-)
Comment 4 Dirk Mueller 2016-01-21 16:42:35 UTC
*** Bug 962397 has been marked as a duplicate of this bug. ***
Comment 5 Dirk Mueller 2016-01-21 16:44:22 UTC
What do you think? After some painful debugging we found out that this is breaking SLES installation every once in a while, as the instsys is calling mksquashfs and every 20th case or so it just creates a corrupted filesystem which causes interesting misbehavior later on.
Comment 6 Bernhard Wiedemann 2016-01-21 17:00:10 UTC
This is an autogenerated message for OBS integration:
This bug (953723) was mentioned in
https://build.opensuse.org/request/show/355285 42.1 / squashfs
Comment 8 Stefan Seyfried 2016-01-22 09:33:17 UTC
Do I need to go through the whole support chain to also get a fix for this into SLES12 and SLES12SP1?
Comment 9 Bernhard Wiedemann 2016-01-22 10:00:49 UTC
(In reply to Stefan Seyfried from comment #8)
> Do I need to go through the whole support chain to also get a fix for this
> into SLES12 and SLES12SP1?

No, you dont need to. It is already proposed internally as an update
using the same version as 42.1

though it wont fix the random SLE installer breakage before SP2
which is why we will keep using squash=0 for SUSE Cloud
Comment 10 Stefan Seyfried 2016-01-22 10:09:11 UTC
That's ok for me, I'm just interested in reducing the numbers of custom-built packages (I need squashfs in the OBS/KIWI context and have for now built a patched version for this purpose :-)
Comment 12 Swamp Workflow Management 2016-02-12 18:12:08 UTC
SUSE-RU-2016:0446-1: An update that has one recommended fix can now be installed.

Category: recommended (moderate)
Bug References: 953723
CVE References: 
Sources used:
SUSE Linux Enterprise Server 12-SP1 (src):    squashfs-4.3-3.1
SUSE Linux Enterprise Server 12 (src):    squashfs-4.3-3.1
SUSE Linux Enterprise Desktop 12-SP1 (src):    squashfs-4.3-3.1
SUSE Linux Enterprise Desktop 12 (src):    squashfs-4.3-3.1
Comment 13 Andreas Stieger 2016-02-18 08:32:20 UTC
Releasing for openSUSE Leap 42.1.

Thorsten, this bug was reported against openSUSE 13.2. If that release is also affected and you think this is a good fix to have there as well now or later, please submit for openSUSE:13.2:Update. Otherwise close the bug at your leisure.
Comment 14 Swamp Workflow Management 2016-02-18 12:13:34 UTC
openSUSE-RU-2016:0502-1: An update that has one recommended fix can now be installed.

Category: recommended (moderate)
Bug References: 953723
CVE References: 
Sources used:
openSUSE Leap 42.1 (src):    squashfs-4.3-6.1
Comment 15 Tomáš Chvátal 2018-04-12 14:07:28 UTC
This version of openSUSE changed to end-of-life (EOL [1]) status. As such
it is no longer maintained, which means that it will not receive any
further security or bug fix updates.
As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
openSUSE, or consider the bug still valid, please feel free to reopen this
bug against that version, or open a new ticket.

Thank you for reporting this bug and we are sorry it could not be fixed
during the lifetime of the release.

[1] https://en.opensuse.org/Lifetime
Comment 16 Stefan Seyfried 2018-08-08 09:12:40 UTC
The bug actually was fixed for all relevant distributions, so set this straight ;-)