Re: [PATCH 2/3] minix: Add required sanity checking to minix_check_superblock()

From: Jan Kara
Date: Mon Dec 08 2025 - 04:51:52 EST


On Sun 07-12-25 19:36:44, Jori Koolstra wrote:
> > >
> > > diff --git a/fs/minix/inode.c b/fs/minix/inode.c
> > > index 7897f5123b3d..8eb26ff91adf 100644
> > > --- a/fs/minix/inode.c
> > > +++ b/fs/minix/inode.c
> > > @@ -171,7 +171,14 @@ static bool minix_check_superblock(struct super_block *sb)
> > > {
> > > struct minix_sb_info *sbi = minix_sb(sb);
> > >
> > > - if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
> > > + if (sbi->s_log_zone_size != 0) {
> > > + printk("minix-fs error: zone size must equal block size. "
> > > + "s_log_zone_size > 0 is not supported.\n");
> > > + return false;
> > > + }
> > > +
> > > + if (sbi->s_ninodes < 1 || sbi->s_firstdatazone <= 4 ||
> > > + sbi->s_firstdatazone >= sbi->s_nzones)
> > > return false;
> >
> > OK, but why did you remove the s_imap_blocks and s_zmap_blocks checks?
> >
>
> I replied to this a while ago that this already happens later in
> minix_fill_superblock:
> https://elixir.bootlin.com/linux/v6.18-rc7/source/fs/minix/inode.c#L280
>
> Maybe you missed it. Let me know if this answers your question when you
> have time.

True, a stricter check happens later in minix_fill_super() but AFAICS
minix_set_bit() calls before this stricter check will crash if
s_imap_blocks or s_zmap_blocks are zero. So I think the original check is
still needed.

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR