From: Shardul Bankar <shardul.b@mpiricsoftware.com>
To: Viacheslav Dubeyko <slava@dubeyko.com>,
zippel@linux-m68k.org, linux-fsdevel@vger.kernel.org,
glaubitz@physik.fu-berlin.de, frank.li@vivo.com
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org,
janak@mpiricsoftware.com, stable@vger.kernel.org,
syzbot+1c8ff72d0cd8a50dfeaa@syzkaller.appspotmail.com,
shardulsb08@gmail.com
Subject: Re: [PATCH v2 1/2] hfsplus: skip node 0 in hfs_bmap_alloc
Date: Thu, 25 Dec 2025 12:02:46 +0530 [thread overview]
Message-ID: <de697a2fbf2464297d5e303a109b0edddddef207.camel@mpiricsoftware.com> (raw)
In-Reply-To: <63e3ff1595ebd27e9835ae7057204b7eef0c1254.camel@dubeyko.com>
On Wed, 2025-12-24 at 20:02 -0800, Viacheslav Dubeyko wrote:
>
> I think that it's not completely correct fix. First of all, we have
> bitmap corruption. It means that we need to complain about it and
> return error code. Logic cannot continue to work normally because we
> cannot rely on bitmap anymore. It could contain multiple corrupted
> bits.
>
> Technically speaking, we need to check that bitmap is corrupted when
> we
> create b-trees during mount operation (we can define it for node 0
> but
> it could be tricky for other nodes). If we have detected the
> corruption, then we can recommend to run FSCK tool and we can mount
> in
> READ-ONLY mode.
>
> I think we can check the bitmap when we are trying to open/create not
> a
> new node but already existing in the tree. I mean if we mounted the
> volume this b-tree containing several nodes on the volume, we can
> check
> that bitmap contains the set bit for these nodes. And if the bit is
> not
> there, then it's clear sign of bitmap corruption. Currently, I
> haven't
> idea how to check corrupted bits that showing presence of not
> existing
> nodes in the b-tree. But I suppose that we can do some check in
> driver's logic. Finally, if we detected corruption, then we should
> complain about the corruption. Ideally, it will be good to remount in
> READ-ONLY mode.
>
> Does it make sense to you?
>
Hi Slava,
Yes, that makes sense.
Skipping node 0 indeed looks like only a local workaround: if the
bitmap is already inconsistent, we shouldn’t proceed as if it is
trustworthy for further allocations, because other bits could be wrong
as well.
For the next revision I plan to replace the “skip node 0” guard with a
bitmap sanity check during btree open/mount. At minimum, I will verify
that the header node (node 0) is marked allocated, and I will also
investigate whether other existing nodes can be validated as well. If
corruption is detected, the driver will report it and force a read-only
mount, along with a recommendation to run fsck.hfsplus. This avoids
continuing RW operation with a known-bad allocator state.
In parallel, I plan to keep the -EEXIST change in hfs_bnode_create() as
a robustness fix for any remaining or future inconsistency paths.
I’ll post a respin shortly.
If you’re OK with it, I can also post the hfs_bnode_create() -EEXIST
change as a standalone fix, since it independently prevents a refcount
underflow and panic even outside the bitmap-corruption scenario. I’ll
continue working on the bitmap validation in parallel.
Thanks,
Shardul
next prev parent reply other threads:[~2025-12-25 6:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-24 15:13 [PATCH v2 0/2] hfsplus: avoid re-allocating header node 0 and stop on already-hashed nodes Shardul Bankar
2025-12-24 15:13 ` [PATCH v2 1/2] hfsplus: skip node 0 in hfs_bmap_alloc Shardul Bankar
2025-12-25 4:02 ` Viacheslav Dubeyko
2025-12-25 6:32 ` Shardul Bankar [this message]
2025-12-29 20:12 ` Viacheslav Dubeyko
2025-12-24 15:13 ` [PATCH v2 2/2] hfsplus: return error when node already exists in hfs_bnode_create 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=de697a2fbf2464297d5e303a109b0edddddef207.camel@mpiricsoftware.com \
--to=shardul.b@mpiricsoftware.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=stable@vger.kernel.org \
--cc=syzbot+1c8ff72d0cd8a50dfeaa@syzkaller.appspotmail.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