From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <shao.mingyin@zte.com.cn>, <richard@nod.at>,
<linux-mtd@lists.infradead.org>
Cc: <linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH 3/5] ubifs: reject master nodes claiming a too small inode number
Date: Tue, 3 Nov 2026 10:06:12 +0800 [thread overview]
Message-ID: <6ff71dd8-84e0-dcef-01c7-1bb7e341ccff@huawei.com> (raw)
In-Reply-To: <20261102214935612btR10gHRJy3yrzqeLcnE9@zte.com.cn>
在 2026/11/2 21:49, shao.mingyin@zte.com.cn 写道:
> validate_master() only rejects highest_inum values above
> INUM_WATERMARK. A master node whose value is below UBIFS_FIRST_INO is
> accepted, and ubifs_new_inode() then allocates inode numbers starting
> from that value, i.e. from the range reserved for special inodes. With
> highest_inum = 0 the very first new inode gets number 1, which is
> UBIFS_ROOT_INO and is already used by the root inode, so two inodes end
> up with the same number and the index is corrupted.
>
> Check the lower bound as well.
>
> Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
> Cc: stable@vger.kernel.org
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> ---
> diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c
> index a148760fa49e..8a1ba81c10bb 100644
> --- a/fs/ubifs/master.c
> +++ b/fs/ubifs/master.c
> @@ -191,6 +191,16 @@ static int validate_master(const struct ubifs_info *c)
> goto out;
> }
>
> + /*
> + * Inode numbers below UBIFS_FIRST_INO are reserved. If the master
> + * node claims a smaller value, newly created inodes would reuse the
> + * root inode number or another reserved one.
> + */
> + if (c->highest_inum < UBIFS_FIRST_INO) {
> + err = 24;
> + goto out;
> + }
> +
This check could be merged into previous check:
f (c->highest_inum >= INUM_WATERMARK)
> if (c->lhead_lnum < UBIFS_LOG_LNUM ||
> c->lhead_lnum >= UBIFS_LOG_LNUM + c->log_lebs ||
> c->lhead_offs < 0 || c->lhead_offs >= c->leb_size ||
> .
>
next prev parent reply other threads:[~2026-11-03 2:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 13:45 [PATCH 0/5] ubifs: harden validation of on-disk inode and node metadata shao.mingyin
2026-11-02 13:45 ` [PATCH 1/5] ubifs: reject inodes with an out-of-range size shao.mingyin
2026-11-02 13:49 ` [PATCH 2/5] ubifs: reject xattr inodes whose size does not match the value shao.mingyin
2026-11-03 2:06 ` Zhihao Cheng
2026-11-03 4:31 ` shao.mingyin
2026-11-02 13:49 ` [PATCH 3/5] ubifs: reject master nodes claiming a too small inode number shao.mingyin
2026-11-03 2:06 ` Zhihao Cheng [this message]
2026-11-03 4:31 ` shao.mingyin
2026-11-03 4:50 ` Zhihao Cheng
2026-11-02 13:49 ` [PATCH 4/5] ubifs: validate inode and data node sizes during replay shao.mingyin
2026-11-02 13:49 ` [PATCH 5/5] ubifs: xattr: guard against xattr accounting underflow shao.mingyin
2026-11-03 2:06 ` [PATCH 0/5] ubifs: harden validation of on-disk inode and node metadata Zhihao Cheng
2026-11-03 4:30 ` shao.mingyin
2026-11-03 4:50 ` Zhihao Cheng
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=6ff71dd8-84e0-dcef-01c7-1bb7e341ccff@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=shao.mingyin@zte.com.cn \
--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®