tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: FFS: wrong superblock check ~> crash
Le 20/10/2014 18:23, David Holland a écrit :
>
> On Mon, Oct 20, 2014 at 03:38:11PM +0200, Maxime Villard wrote:
> > I think the sanity check should be:
> >
> > Index: ffs_vfsops.c
> > ===================================================================
> > RCS file: /cvsroot/src/sys/ufs/ffs/ffs_vfsops.c,v
> > retrieving revision 1.299
> > diff -u -r1.299 ffs_vfsops.c
> > --- ffs_vfsops.c 24 May 2014 16:34:04 -0000 1.299
> > +++ ffs_vfsops.c 20 Oct 2014 13:01:46 -0000
> > @@ -974,7 +974,7 @@
> > continue;
> >
> > /* Validate size of superblock */
> > - if (sbsize > MAXBSIZE || sbsize < sizeof(struct fs))
> > + if (sbsize > SBLOCKSIZE || sbsize < sizeof(struct fs))
> > continue;
> >
> > /* Check that we can handle the file system blocksize */
> >
> > Tested on NetBSD-current: no longer crashes.
> >
> > Ok/Comments?
>
> I think the check should be left alone, but afterwards the value
> should be clamped to the amount of data that can actually be
> transferred. Otherwise I think it may break, e.g. on volumes with odd
> block sizes.
Yes that's what I thought first, but I saw a comment in ffs/fs.h on this:
"In all cases the size of the superblock will be SBLOCKSIZE."
Home |
Main Index |
Thread Index |
Old Index