From: Hui Peng <benquike@gmail.com>
To: Anders Larsen <al@alarsen.net>,
Matthias Goergens <matthias.goergens@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Hui Peng <benquike@gmail.com>
Subject: [PATCH v5 1/6] qnx6: validate di_filelevels in qnx6_iget() before accessing level pointers
Date: Wed, 30 Sep 2026 08:19:42 +0000 [thread overview]
Message-ID: <20260930081947.511613-2-benquike@gmail.com> (raw)
In-Reply-To: <20260930081947.511613-1-benquike@gmail.com>
In qnx6_iget(), raw_inode->di_filelevels is loaded directly from disk
without checking if it exceeds QNX6_PTR_MAX_LEVELS (3). When di_filelevels
exceeds 3 (for example, 6 or 255), qnx6_block_map() triggers UBSAN
shift-out-of-bounds reports at both shifts during indirect block tree
traversal.
Validate raw_inode->di_filelevels <= QNX6_PTR_MAX_LEVELS in qnx6_iget()
and return -EIO on invalid values.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Tested-by: Matthias Goergens <matthias.goergens@gmail.com>
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
Changes in v5:
- Restored commit description to accurately specify UBSAN
shift-out-of-bounds reports at both shifts in qnx6_block_map() per
Matthias Goergens.
- Added Tested-by: Matthias Goergens.
fs/qnx6/inode.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
index a350280f2d47..eb6b5dfbc599 100644
--- a/fs/qnx6/inode.c
+++ b/fs/qnx6/inode.c
@@ -543,6 +543,11 @@ struct inode *qnx6_iget(struct super_block *sb, unsigned int ino)
raw_inode = qnx6_raw_inode(sb, ino, bh);
inode->i_mode = fs16_to_cpu(sbi, raw_inode->di_mode);
+ if (raw_inode->di_filelevels > QNX6_PTR_MAX_LEVELS) {
+ pr_err("invalid inode levels %d (max %d)\n",
+ raw_inode->di_filelevels, QNX6_PTR_MAX_LEVELS);
+ goto bad_inode;
+ }
i_uid_write(inode, fs32_to_cpu(sbi, raw_inode->di_uid));
i_gid_write(inode, fs32_to_cpu(sbi, raw_inode->di_gid));
set_nlink(inode, fs32_to_cpu(sbi, raw_inode->di_nlink));
--
2.47.3
next prev parent reply other threads:[~2026-09-30 8:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 8:19 [PATCH v5 0/6] fs/qnx6: fix buffer head leaks, double free, and inode validation Hui Peng
2026-09-30 8:19 ` Hui Peng [this message]
2026-09-30 8:19 ` [PATCH v5 2/6] qnx6: release bh on error path in qnx6_block_map() Hui Peng
2026-09-30 8:19 ` [PATCH v5 3/6] qnx6: release bh on error path in qnx6_fill_super() Hui Peng
2026-09-30 8:19 ` [PATCH v5 4/6] qnx6: clear sb_buf after brelse in qnx6_mmi_fill_super() Hui Peng
2026-09-30 8:19 ` [PATCH v5 5/6] qnx6: abort mount on superblock magic mismatch when silent is set " Hui Peng
2026-09-30 8:19 ` [PATCH v5 6/6] qnx6: validate sb_blocksize before dividing " Hui Peng
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=20260930081947.511613-2-benquike@gmail.com \
--to=benquike@gmail.com \
--cc=al@alarsen.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.goergens@gmail.com \
--cc=stable@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®