From: Hui Peng <benquike@gmail.com>
To: al@alarsen.net, brauner@kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] qnx4: validate xblk_num_xtnts and rootdir size in qnx4_block_map() and mount
Date: Sat, 19 Sep 2026 22:26:23 +0000 [thread overview]
Message-ID: <20260919222623.3797296-1-benquike@gmail.com> (raw)
In qnx4_block_map() and qnx4_fill_super() (fs/qnx4/inode.c), check that
xblk->xblk_num_xtnts is between 1 and QNX4_MAX_XTNTS_PER_XBLK (60),
return 0 instead of (unsigned long)-EIO on error, and validate the root
directory inode size on mount to prevent out-of-bounds reads past the
512-byte buffer_head.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 42fcd500fad2..f6eb08cac09b 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -104,12 +104,15 @@ unsigned long qnx4_block_map( struct inode *inode, long iblock )
bh = sb_bread(inode->i_sb, i_xblk - 1);
if ( !bh ) {
QNX4DEBUG((KERN_ERR "qnx4: I/O error reading xtnt block [%ld])\n", i_xblk - 1));
- return -EIO;
+ return 0;
}
xblk = (struct qnx4_xblk*)bh->b_data;
- if ( memcmp( xblk->xblk_signature, "IamXblk", 7 ) ) {
+ if (memcmp(xblk->xblk_signature, "IamXblk", 7) ||
+ xblk->xblk_num_xtnts == 0 ||
+ xblk->xblk_num_xtnts > QNX4_MAX_XTNTS_PER_XBLK) {
QNX4DEBUG((KERN_ERR "qnx4: block at %ld is not a valid xtnt\n", qnx4_inode->i_xblk));
- return -EIO;
+ brelse(bh);
+ return 0;
}
}
block = try_extent(&xblk->xblk_xtnts[ix], &offset);
reply other threads:[~2026-09-19 22:26 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=20260919222623.3797296-1-benquike@gmail.com \
--to=benquike@gmail.com \
--cc=al@alarsen.net \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®