mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "shardul.b@mpiricsoftware.com" <shardul.b@mpiricsoftware.com>,
	"glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
	"frank.li@vivo.com" <frank.li@vivo.com>,
	"slava@dubeyko.com" <slava@dubeyko.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "syzbot+1c8ff72d0cd8a50dfeaa@syzkaller.appspotmail.com"
	<syzbot+1c8ff72d0cd8a50dfeaa@syzkaller.appspotmail.com>,
	"janak@mpiricsoftware.com" <janak@mpiricsoftware.com>,
	"shardulsb08@gmail.com" <shardulsb08@gmail.com>
Subject: RE:  [PATCH v2] hfsplus: validate btree bitmap during mount and handle corruption gracefully
Date: Fri, 30 Jan 2026 18:10:09 +0000	[thread overview]
Message-ID: <b78c1e380a17186b73bc8641b139eca56a8de964.camel@ibm.com> (raw)
In-Reply-To: <2283988f9edee66e648e257c303d5e4d77925402.camel@mpiricsoftware.com>

On Fri, 2026-01-30 at 15:13 +0530, Shardul Bankar wrote:
> On Mon, 2026-01-26 at 22:42 +0000, Viacheslav Dubeyko wrote:
> > On Sun, 2026-01-25 at 08:37 +0530, Shardul Bankar wrote:
> > > 
> > > @@ -176,6 +238,13 @@ struct hfs_btree *hfs_btree_open(struct
> > > super_block *sb, u32 id)
> > >         tree->max_key_len = be16_to_cpu(head->max_key_len);
> > >         tree->depth = be16_to_cpu(head->depth);
> > >  
> > > +       /* Validate bitmap: node 0 must be marked allocated */
> > > +       if (hfsplus_validate_btree_bitmap(tree, head)) {
> > > +               struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
> > > +
> > > +               sbi->btree_bitmap_corrupted = true;
> > 
> > Please, see my comment about this field.
> > 
> > > +       }
> > > +
> > >         /* Verify the tree and set the correct compare function */
> > >         switch (id) {
> > >         case HFSPLUS_EXT_CNID:
> > > diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
> > > index 45fe3a12ecba..b925878333d4 100644
> > > --- a/fs/hfsplus/hfsplus_fs.h
> > > +++ b/fs/hfsplus/hfsplus_fs.h
> > > @@ -154,6 +154,7 @@ struct hfsplus_sb_info {
> > >  
> > >         int part, session;
> > >         unsigned long flags;
> > > +       bool btree_bitmap_corrupted;    /* Bitmap corruption
> > > detected during btree open */
> > 
> > This field is completely unnecessary. The hfs_btree_open() can return
> > -EROFS
> > error code and hfsplus_fill_super() can process it.
> >   
> Hi Slava,
> 
> Thanks for the review.
> 
> Regarding the suggestion to convert hfs_btree_open() to return
> ERR_PTR(-EROFS):
> 
> I reviewed this, but I cannot use ERR_PTR for the corruption case
> because it would defeat a purpose of the patch (data recovery).
> 
> If hfs_btree_open() returns -EROFS, the caller hfsplus_fill_super()
> would receive the error code but would have no tree object to work
> with. Without the B-tree structure, we cannot mount the filesystem-even
> read-only-making data recovery impossible.
> 
> To support recovery, hfs_btree_open() must return a valid tree pointer
> even when corruption is detected.

Yeah, I missed this point. You are correct here.

> 
> Therefore, for v3, I plan to:
> 
>     -Keep the return type as-is to avoid scope creep and ensure easy
> backporting.
> 
>     -Use sb->s_flags |= SB_RDONLY inside hfs_btree_open() to flag the
> safety issue.

Sounds like a better option.

> 
>     -Drop the bool flag I added in v2 (as you requested) and simply
> check sb_rdonly(sb) in fill_super to print the warning.

Sounds good.

> 
> I will, of course, address your other comments regarding named
> constants and pointer arithmetic in v3.
> 
> Does this sound acceptable?

Yes, it sounds reasonably well. I like your suggestions.

Thanks,
Slava.

      reply	other threads:[~2026-01-30 18:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-25  3:07 Shardul Bankar
2026-01-26 22:42 ` Viacheslav Dubeyko
2026-01-30  9:43   ` Shardul Bankar
2026-01-30 18:10     ` 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=b78c1e380a17186b73bc8641b139eca56a8de964.camel@ibm.com \
    --to=slava.dubeyko@ibm.com \
    --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=shardul.b@mpiricsoftware.com \
    --cc=shardulsb08@gmail.com \
    --cc=slava@dubeyko.com \
    --cc=syzbot+1c8ff72d0cd8a50dfeaa@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®