From: Sainath Manda <sainathmanda777@gmail.com>
To: slava@dubeyko.com, glaubitz@physik.fu-berlin.de, frank.li@vivo.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Sainath Manda <sainathmanda777@gmail.com>,
syzbot+f83fa2cf571bd7650422@syzkaller.appspotmail.com
Subject: [PATCH] hfsplus: fix duplicate bnode creation in hfs_bnode_create
Date: Sun, 21 Jun 2026 14:34:48 +0530 [thread overview]
Message-ID: <20260621090448.13108-1-sainathmanda777@gmail.com> (raw)
Syzbot reported a WARNING in hfsplus_bnode_create. A maliciously crafted
HFS+ image can request the creation of a duplicate bnode (e.g., bnode 0)
that is mathematically within the tree->node_count bounds, but has
already been hashed in memory. This bypasses initial boundary checks and
triggers a WARN_ON(1) upon a duplicate hash collision.
This patch adds a clean state check in hfs_bnode_create. If a requested
node is already hashed, the driver now safely rejects the operation
with -EEXIST instead of tripping the kernel warning.
Reported-by: syzbot+f83fa2cf571bd7650422@syzkaller.appspotmail.com
Signed-off-by: Sainath Manda sainathmanda777@gmail.com
---
fs/hfsplus/bnode.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index f8b5a8ae5..5946baad2 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -626,12 +626,18 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num)
struct page **pagep;
int i;
+ if (num >= tree->node_count) {
+ pr_err("hfsplus: attempted to create invalid bnode %u (max %u)\n",
+ num, tree->node_count);
+ return ERR_PTR(-EINVAL);
+ }
+
spin_lock(&tree->hash_lock);
node = hfs_bnode_findhash(tree, num);
spin_unlock(&tree->hash_lock);
if (node) {
- pr_crit("new node %u already hashed?\n", num);
- WARN_ON(1);
+ pr_err("hfsplus: attempted to create already hashed bnode %u\n",
+ num);
return ERR_PTR(-EEXIST);
}
node = __hfs_bnode_create(tree, num);
--
2.34.1
next reply other threads:[~2026-06-21 9:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-21 9:04 Sainath Manda [this message]
2026-06-23 5:56 ` [PATCH] hfsplus: fix duplicate bnode creation in hfs_bnode_create 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=20260621090448.13108-1-sainathmanda777@gmail.com \
--to=sainathmanda777@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+f83fa2cf571bd7650422@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