On Sun, 21 Feb 2016 16:33:27 +0100, Stefan Kempf wrote:

> Should we really mount the FS in that case? If the FS was of the
> "new" format, then short symlinks would store the destination path in the
> inode directly. I think we'd not be able to correctly follow these symlinks
> if we set fs_maxsymlinklen to 0 when encountering a negative value.

I was concerned about old 4.2/4.3 filesystems having garbage in
that location.  It's not really an issue since we'll never really
encounter such a file system that was not created by our own newfs
(which will zero it on the disk).

Since fs_maxsymlinklen should be ignored for the old inode format
we could do something like this just to be safe.

 - todd

Index: ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /cvs/src/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.150
diff -u -p -u -r1.150 ffs_vfsops.c
--- ufs/ffs/ffs_vfsops.c        12 Jan 2016 11:41:00 -0000      1.150
+++ ufs/ffs/ffs_vfsops.c        22 Feb 2016 13:27:09 -0000
@@ -642,6 +642,11 @@ ffs_validate(struct fs *fsp)
        if ((u_int)fsp->fs_frag > MAXFRAG || fragtbl[fsp->fs_frag] == NULL)
                return (0); /* Invalid number of fragments */
 
+       if (fsp->fs_inodefmt == FS_42INODEFMT)
+               fsp->fs_maxsymlinklen = 0;
+       else if (fsp->fs_maxsymlinklen < 0)
+               return (0); /* Invalid max size of short symlink */
+
        return (1); /* Super block is okay */
 }
 

Index: ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /cvs/src/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.150
diff -u -p -u -r1.150 ffs_vfsops.c
--- ufs/ffs/ffs_vfsops.c        12 Jan 2016 11:41:00 -0000      1.150
+++ ufs/ffs/ffs_vfsops.c        22 Feb 2016 13:27:09 -0000
@@ -642,6 +642,11 @@ ffs_validate(struct fs *fsp)
        if ((u_int)fsp->fs_frag > MAXFRAG || fragtbl[fsp->fs_frag] == NULL)
                return (0); /* Invalid number of fragments */
 
+       if (fsp->fs_inodefmt == FS_42INODEFMT)
+               fsp->fs_maxsymlinklen = 0;
+       else if (fsp->fs_maxsymlinklen < 0)
+               return (0); /* Invalid max size of short symlink */
+
        return (1); /* Super block is okay */
 }
 

Reply via email to