From: Viacheslav Dubeyko <slava@dubeyko.com>
To: Sainath Manda <sainathmanda777@gmail.com>,
glaubitz@physik.fu-berlin.de, frank.li@vivo.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+f83fa2cf571bd7650422@syzkaller.appspotmail.com
Subject: Re: [PATCH] hfsplus: fix duplicate bnode creation in hfs_bnode_create
Date: Mon, 22 Jun 2026 22:56:48 -0700 [thread overview]
Message-ID: <5d8bf7aeebb3dbad5640d99784942201212eef4f.camel@dubeyko.com> (raw)
In-Reply-To: <20260621090448.13108-1-sainathmanda777@gmail.com>
On Sun, 2026-06-21 at 14:34 +0530, Sainath Manda wrote:
> 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);
If we have corrupted HFS+ image, then we should not mount it. If I
remember correctly, we already have patch that fixes this issue by
checking b-tree's map during mount operation. Are you sure that you are
running the latest state of the Linux kernel?
Thanks,
Slava.
prev parent reply other threads:[~2026-06-23 5:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-21 9:04 Sainath Manda
2026-06-23 5:56 ` Viacheslav Dubeyko [this message]
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=5d8bf7aeebb3dbad5640d99784942201212eef4f.camel@dubeyko.com \
--to=slava@dubeyko.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=sainathmanda777@gmail.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
all inboxes | Powered by JetHome®