From: Phillip Lougher <phillip@squashfs.org.uk>
To: syzbot+65761fc25a137b9c8c6e@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, phillip@squashfs.org.uk,
squashfs-devel-owner@lists.sourceforge.net,
squashfs-devel@lists.sourceforge.net,
syzkaller-bugs@googlegroups.com, phillip.lougher@gmail.com
Subject: Re: [syzbot] [squashfs?] UBSAN: shift-out-of-bounds in squashfs_bio_read
Date: Mon, 7 Apr 2025 06:30:35 +0100 [thread overview]
Message-ID: <2a13ea1c-08df-4807-83d4-241831b7a2ec@squashfs.org.uk> (raw)
In-Reply-To: <67f1f6f6.050a0220.0a13.025a.GAE@google.com>
I have spent most of Sunday on this syzbot issue, because it is one of
those PITAs, which are difficult to reproduce, and are full of red
herrings.
Firstly, this issue has nothing to do with corrupted Squashfs
filesystems. This is the because the failure occurs before the Squashfs
filesystem superblock has been read, and thus filesystem corruption
doesn't come into it. Thus the source of the failure is elsewhere in
the obfusticated auto-generated C reproducer.
Digging deeper into the reproducer, it turns out the reproducer is
forking multiple processes which after mounting the Squashfs filesystem,
issues a LOOP_SET_BLOCK_SIZE(r0, 0x4c09, 0x8000) ioctl on loopback
device /dev/loop0. Now, if this ioctl occurs at the same time another
process is in the process of mounting a Squashfs filesystem on
/dev/loop0, the failure occurs. The ioctl has to be issued in the
early part of squashfs_fill_super() before the superblock has been read.
When this happens, the following code in squashfs_fill_super() fails.
----
msblk->devblksize = sb_min_blocksize(sb, SQUASHFS_DEVBLK_SIZE);
msblk->devblksize_log2 = ffz(~msblk->devblksize);
----
sb_min_blocksize() returns 0, which means msblk->devblksize is set to 0.
As a result, ffz(~msblk->devblksize) returns 64, and
msblk->devblksize_log2 is set to 64.
This subsequently causes the
UBSAN: shift-out-of-bounds in fs/squashfs/block.c:195:36
shift exponent 64 is too large for 64-bit type 'u64' (aka 'unsigned long long')
The fix is to check for a 0 return by sb_min_blocksize().
I'll send a patch tomorrow.
Phillip
next prev parent reply other threads:[~2025-04-07 5:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-05 7:36 syzbot
2025-04-06 3:37 ` syzbot
2025-04-07 5:30 ` Phillip Lougher [this message]
2025-04-08 4:18 ` 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=2a13ea1c-08df-4807-83d4-241831b7a2ec@squashfs.org.uk \
--to=phillip@squashfs.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=phillip.lougher@gmail.com \
--cc=squashfs-devel-owner@lists.sourceforge.net \
--cc=squashfs-devel@lists.sourceforge.net \
--cc=syzbot+65761fc25a137b9c8c6e@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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®