From: Viacheslav Dubeyko <vdubeyko@redhat.com>
To: Edward Adam Davis <eadavis@qq.com>
Cc: frank.li@vivo.com, glaubitz@physik.fu-berlin.de,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
slava@dubeyko.com,
syzbot+98547b0428b6a6a3467c@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] hfsplus: Supports freeing newly created tree head
Date: Wed, 22 Apr 2026 11:19:10 -0700 [thread overview]
Message-ID: <39b283f4e3fe75a8b9ee324e5906c6635aafed40.camel@redhat.com> (raw)
In-Reply-To: <tencent_B50525C2BA56BB53331B9E5A1B444B281B08@qq.com>
On Sat, 2026-04-18 at 17:37 +0800, Edward Adam Davis wrote:
> On Fri, 17 Apr 2026 15:03:17 -0700, Viacheslav Dubeyko wrote:
> > > hfs_bnode_put() does not support deallocating a newly created btree
> > > head node; therefore, regardless of whether hfsplus_bnode_find() succeeds
> > > or fails, it cannot effectively reclaim the memory allocated for a newly
> > > created head node.
> > >
> > > When finding a head node, if the node is a newly created one, we can use
> > > hfs_bnode_free() to reclaim its memory.
> > >
> > > [1]
> > > BUG: memory leak
> > > unreferenced object 0xffff88811cabc840 (size 96):
> > > backtrace (crc 3e2dadb7):
> > > __hfs_bnode_create+0x59/0x310 fs/hfsplus/bnode.c:469
> > > hfsplus_bnode_find+0x13e/0x580 fs/hfsplus/bnode.c:547
> > > hfsplus_btree_open+0x2fa/0x6d0 fs/hfsplus/btree.c:382
> > > hfsplus_fill_super+0x272/0x880 fs/hfsplus/super.c:548
> >
> > I need slightly more detailed and clear explanation how the issue has been
> > happened and why we need to fix it in a such way. Currently, I don't have the
> > complete picture how this happened. I am sure that you have the complete
> > picture. :) Could you please share what you have in your mind? :) Don't hide the
> > wisdom. ;)
> fc_mount()
> vfs_get_tree()
> get_tree_bdev_flags()
> hfsplus_fill_super()
We have multiple calls of hfsplus_btree_open(). Which particular b-tree do you
mean here?
> hfsplus_btree_open()
I assume that you mean hfs_btree_open().
> hfsplus_bnode_find(tree, HFSPLUS_TREE_HEAD)
>
We call hfs_bnode_find() here.
>
> __hfs_bnode_create()
> ...
> node->this = cnid; // cnid is HFSPLUS_TREE_HEAD, it is 0
> ...
> ...
> desc = (struct hfs_bnode_desc *)(kmap_local_page(node->page[0])
> node->type = desc->type;
> switch (node->type) {
> ...
> default: // because node->type is 127, so run here
> goto node_error;
I think, maybe, we need to add some error message(s) when some error is
happened. What do you think?
> ...
> hfs_bnode_put()
> ...
> if (test_bit(HFS_BNODE_DELETED, &node->flags)) { /* head node not set HFS_BNODE_DELETED flag
> * so, the node will never be freed.
> * Furthermore, even if the node were marked
> * with the HFS_BNODE_DELETED flag, hfs_bmap_free()
> * would still trigger BUG_ON(!node->this).
> */
node_error:
set_bit(HFS_BNODE_ERROR, &node->flags);
- clear_bit(HFS_BNODE_NEW, &node->flags);
- wake_up(&node->lock_wq);
+ if (num != HFSPLUS_TREE_HEAD) {
Why do we need to distinguish is it HFSPLUS_TREE_HEAD or not? I don't see any
difference in node processing.
+ clear_bit(HFS_BNODE_NEW, &node->flags);
I think that we don't need to clear the HFS_BNODE_NEW. Because, we need to
analyze HFS_BNODE_ERROR in hfs_bnode_put().
+ wake_up(&node->lock_wq);
I assume that wake_up() should be called anyway. Why have you removed this call
for HFSPLUS_TREE_HEAD case?
+ }
hfs_bnode_put(node);
return ERR_PTR(-EIO);
@@ -694,6 +698,10 @@ void hfs_bnode_put(struct hfs_bnode *node)
hfs_bnode_free(node);
return;
}
+ if (test_bit(HFS_BNODE_NEW, &node->flags)) {
I suggest to analyze HFS_BNODE_ERROR here.
+ hfs_bnode_unhash(node);
+ hfs_bnode_free(node);
+ }
@@ -598,14 +598,18 @@ struct hfs_bnode *hfs_bnode_find(struct hfs_btree *tree,
u32 num)
if (key_size >= entry_size || key_size & 1)
goto node_error;
}
- clear_bit(HFS_BNODE_NEW, &node->flags);
- wake_up(&node->lock_wq);
+ if (num != HFSPLUS_TREE_HEAD) {
+ clear_bit(HFS_BNODE_NEW, &node->flags);
+ wake_up(&node->lock_wq);
What the point in this code? Why have you change the logic here?
+ }
return node;
And, could you please add these new details into the commit message?
Thanks,
Slava.
prev parent reply other threads:[~2026-04-22 18:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 1:56 [syzbot] [hfs?] memory leak in __hfs_bnode_create syzbot
2026-04-17 6:58 ` [PATCH] hfsplus: Supports freeing newly created tree head Edward Adam Davis
2026-04-17 22:03 ` Viacheslav Dubeyko
2026-04-18 9:37 ` Edward Adam Davis
2026-04-22 18:19 ` 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=39b283f4e3fe75a8b9ee324e5906c6635aafed40.camel@redhat.com \
--to=vdubeyko@redhat.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+98547b0428b6a6a3467c@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