From: ThangNN99 <ngocthang2710.1999@gmail.com>
To: Viacheslav Dubeyko <slava@dubeyko.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
Yangtao Li <frank.li@vivo.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+f8ce6c197125ab9d72ce@syzkaller.appspotmail.com
Subject: Re: [PATCH] hfsplus: fix recursive tree_lock in hfsplus_file_extend()
Date: Tue, 8 Sep 2026 18:54:09 +0700 [thread overview]
Message-ID: <20260908115409.9818-1-ngocthang2710.1999@gmail.com> (raw)
In-Reply-To: <1b3ba7f7afc3509720cad69ba8c7c17a9276ecd1.camel@dubeyko.com>
Hi Slava,
> Could you share the dump/content of the Extents Overflow file's fork?
Decoded the volume header from the syzbot image. The Extents Overflow
fork (offset 192 in the header):
logicalSize=32768 clumpSize=32768 totalBlocks=32
extents[0]=(start=3, count=32)
extents[1]=(start=0, count=0)
extents[2]=(start=0, count=0)
extents[3]=(start=0, count=134217728) <- garbage
extents[4]=(start=0, count=0)
extents[5]=(start=0, count=0)
extents[6]=(start=0, count=11796736) <- garbage
extents[7]=(start=0, count=0)
Correction to my last mail: it's not totalBlocks exceeding the fork's
extents, it's the reverse and messier. hfsplus_inode_read_fork() sums
all 8 extents' block_count into hip->first_blocks with no validation
(inode.c:569). Slots 3 and 6 have start_block=0 (i.e. "unused") but
garbage non-zero block_count, so first_blocks comes out to 146014496
against a real totalBlocks (hip->alloc_blocks) of 32. Either direction
of that mismatch takes hfsplus_file_extend() down the same
hfsplus_ext_read_extent() path, since the code only tests
alloc_blocks == first_blocks.
> Could we detect the corruption of the fork during the mount phase?
> If we can then we need to mount in Read-Only mode the corrupted
> volume.
Yes. Proposed v2, forcing read-only instead of touching extents.c:
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -293,6 +293,14 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
goto free_inode;
}
+ /* Per TN1150, the extents file can't have overflow extents of its own. */
+ if (id == HFSPLUS_EXT_CNID &&
+ HFSPLUS_I(tree->inode)->first_blocks !=
+ HFSPLUS_I(tree->inode)->alloc_blocks) {
+ pr_warn("extents overflow file has overflow extents of its own, forcing read-only.\n");
+ sb->s_flags |= SB_RDONLY;
+ }
+
mapping = tree->inode->i_mapping;
page = read_mapping_page(mapping, 0, NULL);
if (IS_ERR(page))
One catch: the reproducer mounts MS_RDONLY, then remounts rw via a
bare MS_REMOUNT|MS_MOVE. hfsplus_reconfigure() only re-checks
VOL_UNMNT/SOFTLOCK/JOURNALED before allowing that, and this image sets
VOL_UNMNT, so a read-only-only fix in hfs_btree_open() gets undone by
that remount. Same check needs to go in hfsplus_reconfigure() too:
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -400,6 +400,12 @@ static int hfsplus_reconfigure(struct fs_context *fc)
pr_warn("filesystem is marked journaled, leaving read-only.\n");
sb->s_flags |= SB_RDONLY;
fc->sb_flags |= SB_RDONLY;
+ } else if (HFSPLUS_I(sbi->ext_tree->inode)->first_blocks !=
+ HFSPLUS_I(sbi->ext_tree->inode)->alloc_blocks) {
+ /* Per TN1150, the extents file can't have overflow extents of its own. */
+ pr_warn("extents overflow file has overflow extents of its own, leaving read-only.\n");
+ sb->s_flags |= SB_RDONLY;
+ fc->sb_flags |= SB_RDONLY;
}
}
return 0;
Both hunks build cleanly here. Want me to send this as v2 replacing
the extents.c hunk, or keep the extents.c guard too as a second line
of defense (it's independent of mount-time state and free)?
Thanks,
Thang
next prev parent reply other threads:[~2026-09-08 11:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 15:49 ThangNN99
2026-09-07 17:05 ` Viacheslav Dubeyko
2026-09-07 17:15 ` ThangNN99
2026-09-07 17:26 ` Viacheslav Dubeyko
2026-09-08 11:54 ` ThangNN99 [this message]
2026-09-08 17:39 ` Viacheslav Dubeyko
2026-09-09 16:20 ` Nguyen Ngoc Thang
2026-09-09 18:36 ` Viacheslav Dubeyko
2026-09-10 16:01 ` Nguyen Ngoc Thang
2026-09-10 19:20 ` Viacheslav Dubeyko
2026-09-11 11:46 ` Nguyen Ngoc Thang
2026-09-11 18:26 ` Viacheslav Dubeyko
2026-09-12 13:24 ` [PATCH v4 0/2] hfsplus: fix the extents overflow file recursive tree_lock and its root cause Nguyen Ngoc Thang
2026-09-12 13:24 ` [PATCH v4 1/2] hfsplus: fix recursive tree_lock in hfsplus_file_extend() Nguyen Ngoc Thang
2026-09-14 19:26 ` Viacheslav Dubeyko
2026-09-15 14:07 ` Nguyen Ngoc Thang
2026-09-15 23:43 ` Viacheslav Dubeyko
2026-09-12 13:24 ` [PATCH v4 2/2] hfsplus: validate b-tree fork extents at mount time Nguyen Ngoc Thang
2026-09-14 20:12 ` Viacheslav Dubeyko
2026-09-15 14:15 ` Nguyen Ngoc Thang
2026-09-15 23:48 ` Viacheslav Dubeyko
2026-09-16 17:15 ` Viacheslav Dubeyko
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=20260908115409.9818-1-ngocthang2710.1999@gmail.com \
--to=ngocthang2710.1999@gmail.com \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=slava@dubeyko.com \
--cc=syzbot+f8ce6c197125ab9d72ce@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®