From: ThangNN99 <ngocthang2710.1999@gmail.com>
To: Viacheslav Dubeyko <slava@dubeyko.com>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
Yangtao Li <frank.li@vivo.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
ThangNN99 <ngocthang2710.1999@gmail.com>,
syzbot+f8ce6c197125ab9d72ce@syzkaller.appspotmail.com
Subject: [PATCH] hfsplus: fix recursive tree_lock in hfsplus_file_extend()
Date: Sun, 6 Sep 2026 22:49:24 +0700 [thread overview]
Message-ID: <20260906154924.94160-1-ngocthang2710.1999@gmail.com> (raw)
hfs_bmap_reserve() calls hfsplus_file_extend() on tree->inode with
tree->tree_lock already held. When the tree is the extents overflow
B-tree and its own fork already claims more blocks than its eight
fork extents describe, hfsplus_file_extend() calls
hfsplus_ext_read_extent() -> hfs_find_init() on that same tree,
taking tree_lock a second time (lockdep: "possible recursive locking
... &tree->tree_lock/1").
Per the HFS+ format the extents overflow file is fully described by
its eight fork extents, so this state only arises from a corrupted
image. hfsplus_get_block() already refuses it for lookups; do the
same when growing the file.
Reported-by: syzbot+f8ce6c197125ab9d72ce@syzkaller.appspotmail.com
Signed-off-by: ThangNN99 <ngocthang2710.1999@gmail.com>
---
fs/hfsplus/extents.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index eb7c11524d18..39920b51e08b 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -458,6 +458,15 @@ int hfsplus_file_extend(struct inode *inode, bool zeroout)
if (hip->alloc_blocks == hip->first_blocks)
goal = hfsplus_ext_lastblock(hip->first_extents);
else {
+ /*
+ * The extents overflow file can't have overflow extents of
+ * its own; growing it here would re-enter hfs_find_init()
+ * on the extents tree, whose tree_lock is already held.
+ */
+ if (inode->i_ino == HFSPLUS_EXT_CNID) {
+ res = -EIO;
+ goto out;
+ }
res = hfsplus_ext_read_extent(inode, hip->alloc_blocks);
if (res)
goto out;
--
2.43.0
next reply other threads:[~2026-09-06 15:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 15:49 ThangNN99 [this message]
2026-09-07 17:05 ` [PATCH] hfsplus: fix recursive tree_lock in hfsplus_file_extend() Viacheslav Dubeyko
2026-09-07 17:15 ` ThangNN99
2026-09-07 17:26 ` Viacheslav Dubeyko
2026-09-08 11:54 ` ThangNN99
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-12 13:24 ` [PATCH v4 2/2] hfsplus: validate b-tree fork extents at mount time Nguyen Ngoc Thang
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=20260906154924.94160-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