From: Shardul Bankar <shardul.b@mpiricsoftware.com>
To: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>,
"zippel@linux-m68k.org" <zippel@linux-m68k.org>,
"glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"slava@dubeyko.com" <slava@dubeyko.com>,
"frank.li@vivo.com" <frank.li@vivo.com>
Cc: "akpm@osdl.org" <akpm@osdl.org>,
"janak@mpiricsoftware.com" <janak@mpiricsoftware.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
shardulsb08@gmail.com
Subject: Re: [PATCH] hfsplus: fix missing hfs_bnode_get() in hfs_bnode_create()
Date: Wed, 24 Dec 2025 17:30:30 +0530 [thread overview]
Message-ID: <966687093123e00c166afabc0a9de87e0ba844d5.camel@mpiricsoftware.com> (raw)
In-Reply-To: <1e0095625a71cca2ff25c2946fd6532c28cfd1b0.camel@ibm.com>
On Tue, 2025-12-16 at 20:28 +0000, Viacheslav Dubeyko wrote:
>
> The fix in hfs_bmap_alloc() sounds reasonable to me. But I don't see
> the point
> of adding hfs_bnode_get() in hfs_bnode_create() for the case of
> erroneous
> situation [1]:
>
> if (node) {
> pr_crit("new node %u already hashed?\n", num);
> WARN_ON(1);
> return node;
> }
>
> It will be much better to return ERR_PTR(-EEXIST) here. Because, it
> is not
> situation of "doing business as usual". We should not continue to
> believe that
> "sun is shining for us", but we should stop the logic somehow.
>
> Thanks,
> Slava.
>
> [1] https://elixir.bootlin.com/linux/v6.18/source/fs/hfs/bnode.c#L518
Hi Slava,
Thanks, agreed.
I’ll keep the hfs_bmap_alloc() change to ensure node 0 is never
allocated.
And I agree that the “already hashed?” case in hfs_bnode_create()
should not try to continue by returning a pointer (even with an extra
hfs_bnode_get()). Callers like hfs_btree_inc_height() and
hfs_bnode_split() treat the returned node as a freshly allocated node
and immediately rewrite its header/records. If hfs_bnode_create()
returns an existing hashed node, that effectively overwrites live node
contents and amplifies corruption, which can then cascade into later
failures.
So I’ll rework v2 as a small series:
1/2: guard against allocating node 0 in hfs_bmap_alloc()
2/2: make the “already hashed?” path return ERR_PTR(-EEXIST) and
propagate the error
I’ll send the updated series shortly.
Thanks,
Shardul
next prev parent reply other threads:[~2025-12-24 12:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-13 23:32 Shardul Bankar
2025-12-15 19:29 ` Viacheslav Dubeyko
2025-12-16 6:01 ` Shardul Bankar
2025-12-16 20:28 ` Viacheslav Dubeyko
2025-12-24 12:00 ` Shardul Bankar [this message]
2025-12-25 2:31 ` Shardul Bankar
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=966687093123e00c166afabc0a9de87e0ba844d5.camel@mpiricsoftware.com \
--to=shardul.b@mpiricsoftware.com \
--cc=Slava.Dubeyko@ibm.com \
--cc=akpm@osdl.org \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=janak@mpiricsoftware.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shardulsb08@gmail.com \
--cc=slava@dubeyko.com \
--cc=zippel@linux-m68k.org \
/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®