v2: merge the lower bound into the existing highest_inum check, as suggested by Zhihao Cheng. diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c index a148760fa49e..e180091fab8c 100644 --- a/fs/ubifs/master.c +++ b/fs/ubifs/master.c @@ -186,7 +186,13 @@ static int validate_master(const struct ubifs_info *c) goto out; } - if (c->highest_inum >= INUM_WATERMARK) { + /* + * 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 >= INUM_WATERMARK || + c->highest_inum < UBIFS_FIRST_INO) { err = 3; goto out; }