From: Arbab Haider <arbabhaider649@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
syzbot+6a0633f11d3fb88860bf@syzkaller.appspotmail.com,
stable@vger.kernel.org, Arbab Haider <arbabhaider649@gmail.com>
Subject: [PATCH] qnx6: fix divide-by-zero and silent magic check in qnx6_mmi_fill_super()
Date: Sat, 21 Nov 2026 03:03:54 +0500 [thread overview]
Message-ID: <20261120220355.137600-1-arbabhaider649@gmail.com> (raw)
syzbot reported a divide error in qnx6_mmi_fill_super() when mounting an
all-zero block device with MS_SILENT and the "mmi_fs" mount option:
Oops: divide error: 0000 [#1] SMP KASAN PTI
RIP: 0010:qnx6_mmi_fill_super+0x228/0x870 fs/qnx6/super_mmi.c:68
Two issues combine to trigger this crash:
1. When sb1->sb_magic does not match QNX6_SUPER_MAGIC, "goto out;" is
nested inside "if (!silent)", so mounting with MS_SILENT falls
through instead of aborting. An all-zero superblock then passes the
crc32_be() check because crc32_be(0, zeros, 504) == 0.
2. The second superblock offset divides QNX6_SUPERBLOCK_AREA by
fs32_to_cpu(sbi, sb1->sb_blocksize) before sb_set_blocksize()
validates the blocksize, causing a divide-by-zero when
sb_blocksize is 0.
Fix both by moving "goto out;" outside "if (!silent)" (matching the sb2
magic check) and validating sb1->sb_blocksize against
QNX6_SUPERBLOCK_AREA and sb_set_blocksize() before computing the second
superblock offset using a 64-bit addition and s->s_blocksize_bits,
matching qnx6_fill_super().
Reported-by: syzbot+6a0633f11d3fb88860bf@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6a0633f11d3fb88860bf
Fixes: 5d026c724220 ("fs: initial qnx6fs addition")
Cc: stable@vger.kernel.org
Signed-off-by: Arbab Haider <arbabhaider649@gmail.com>
---
fs/qnx6/super_mmi.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/qnx6/super_mmi.c b/fs/qnx6/super_mmi.c
index b8afb6f38..bb4243872 100644
--- a/fs/qnx6/super_mmi.c
+++ b/fs/qnx6/super_mmi.c
@@ -51,10 +51,9 @@ struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
sb1 = (struct qnx6_mmi_super_block *)bh1->b_data;
sbi = QNX6_SB(s);
if (fs32_to_cpu(sbi, sb1->sb_magic) != QNX6_SUPER_MAGIC) {
- if (!silent) {
+ if (!silent)
pr_err("wrong signature (magic) in superblock #1.\n");
- goto out;
- }
+ goto out;
}
/* checksum check - start at byte 8 and end at byte 512 */
@@ -64,12 +63,9 @@ struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
goto out;
}
- /* calculate second superblock blocknumber */
- offset = fs32_to_cpu(sbi, sb1->sb_num_blocks) + QNX6_SUPERBLOCK_AREA /
- fs32_to_cpu(sbi, sb1->sb_blocksize);
-
/* set new blocksize */
- if (!sb_set_blocksize(s, fs32_to_cpu(sbi, sb1->sb_blocksize))) {
+ if (fs32_to_cpu(sbi, sb1->sb_blocksize) > QNX6_SUPERBLOCK_AREA ||
+ !sb_set_blocksize(s, fs32_to_cpu(sbi, sb1->sb_blocksize))) {
pr_err("unable to set blocksize\n");
goto out;
}
@@ -80,6 +76,10 @@ struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s, int silent)
goto out;
sb1 = (struct qnx6_mmi_super_block *)bh1->b_data;
+ /* calculate second superblock blocknumber */
+ offset = (u64)fs32_to_cpu(sbi, sb1->sb_num_blocks) +
+ (QNX6_SUPERBLOCK_AREA >> s->s_blocksize_bits);
+
/* read second superblock */
bh2 = sb_bread(s, offset);
if (!bh2) {
--
2.53.0
reply other threads:[~2026-11-20 22:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261120220355.137600-1-arbabhaider649@gmail.com \
--to=arbabhaider649@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+6a0633f11d3fb88860bf@syzkaller.appspotmail.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®