From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "syzbot+41ba9c82bce8d7101765@syzkaller.appspotmail.com"
<syzbot+41ba9c82bce8d7101765@syzkaller.appspotmail.com>,
"eadavis@qq.com" <eadavis@qq.com>
Cc: "syzkaller-bugs@googlegroups.com"
<syzkaller-bugs@googlegroups.com>,
"frank.li@vivo.com" <frank.li@vivo.com>,
"glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"slava@dubeyko.com" <slava@dubeyko.com>
Subject: Re: [PATCH] hfs: Prevent the use of bnodes without entries
Date: Thu, 24 Jul 2025 20:06:20 +0000 [thread overview]
Message-ID: <0ead1ebdbbecc1802e3ffed0867ba6a2c567e415.camel@ibm.com> (raw)
In-Reply-To: <tencent_DFFF86C192DEC64EC99B6EF96EDE4C986706@qq.com>
On Thu, 2025-07-24 at 23:08 +0800, Edward Adam Davis wrote:
> If the number of entries in the bnode is 0, the bnode is considered
> invalid.
>
> Reported-by: syzbot+41ba9c82bce8d7101765@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=41ba9c82bce8d7101765
> Tested-by: syzbot+41ba9c82bce8d7101765@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> fs/hfs/bfind.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
> index ef9498a6e88a..1d6f2bbafa7a 100644
> --- a/fs/hfs/bfind.c
> +++ b/fs/hfs/bfind.c
> @@ -133,6 +133,8 @@ int hfs_brec_find(struct hfs_find_data *fd)
> goto invalid;
> if (bnode->type != (--height ? HFS_NODE_INDEX : HFS_NODE_LEAF))
> goto invalid;
> + if (!bnode->num_recs)
> + goto invalid;
If b-tree node hasn't records, then it doesn't mean that it's invalid. Because,
if we go into invalid way, then we show the message that node is corrupted [1]:
invalid:
pr_err("inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
height, bnode->height, bnode->type, nidx, parent);
res = -EIO;
But it is not true because the node simply has no records. It could be invalid
if bnode->num_recs < 0.
Also, I've sent the patch [2] already. I believe it should fix the issue. Am I
wrong here?
Thanks,
Slava.
[1] https://elixir.bootlin.com/linux/v6.16-rc6/source/fs/hfs/bfind.c#L152
[2]
https://lore.kernel.org/linux-fsdevel/20250703214912.244138-1-slava@dubeyko.com/
> bnode->parent = parent;
>
> res = __hfs_brec_find(bnode, fd);
next prev parent reply other threads:[~2025-07-24 20:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 17:18 [syzbot] [hfs?] KASAN: out-of-bounds Read in hfs_bnode_move syzbot
2025-07-23 17:26 ` Viacheslav Dubeyko
2025-07-24 1:52 ` Forwarded: " syzbot
2025-07-24 9:40 ` Edward Adam Davis
2025-07-24 10:17 ` syzbot
2025-07-24 11:46 ` Edward Adam Davis
2025-07-24 15:06 ` syzbot
2025-07-24 15:08 ` [PATCH] hfs: Prevent the use of bnodes without entries Edward Adam Davis
2025-07-24 20:06 ` Viacheslav Dubeyko [this message]
2025-08-27 9:54 ` [syzbot] [hfs?] KASAN: out-of-bounds Read in hfs_bnode_move syzbot
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=0ead1ebdbbecc1802e3ffed0867ba6a2c567e415.camel@ibm.com \
--to=slava.dubeyko@ibm.com \
--cc=eadavis@qq.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+41ba9c82bce8d7101765@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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