Module Name:    src
Committed By:   maxv
Date:           Sat Feb 14 07:11:34 UTC 2015

Modified Files:
        src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
ffs_reload(): call ffs_superblock_validate() with the new superblock.


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.309 src/sys/ufs/ffs/ffs_vfsops.c:1.310
--- src/sys/ufs/ffs/ffs_vfsops.c:1.309	Fri Feb 13 17:13:20 2015
+++ src/sys/ufs/ffs/ffs_vfsops.c	Sat Feb 14 07:11:34 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.309 2015/02/13 17:13:20 maxv Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.310 2015/02/14 07:11:34 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.309 2015/02/13 17:13:20 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.310 2015/02/14 07:11:34 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -111,7 +111,11 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c
 
 MODULE(MODULE_CLASS_VFS, ffs, NULL);
 
-static int	ffs_vfs_fsync(vnode_t *, int);
+static int
+ffs_vfs_fsync(vnode_t *, int);
+
+static int
+ffs_superblock_validate(struct fs *fs, u_int32_t fs_sbsize, int32_t fs_bsize);
 
 static struct sysctllog *ffs_sysctl_log;
 
@@ -738,14 +742,19 @@ ffs_reload(struct mount *mp, kauth_cred_
 	} else
 #endif
 		fs->fs_flags &= ~FS_SWAPPED;
+
 	if ((newfs->fs_magic != FS_UFS1_MAGIC &&
-	     newfs->fs_magic != FS_UFS2_MAGIC)||
-	     newfs->fs_bsize > MAXBSIZE ||
-	     newfs->fs_bsize < sizeof(struct fs)) {
+	     newfs->fs_magic != FS_UFS2_MAGIC)) {
 		brelse(bp, 0);
 		kmem_free(newfs, fs->fs_sbsize);
 		return (EIO);		/* XXX needs translation */
 	}
+	if (!ffs_superblock_validate(newfs, newfs->fs_sbsize, newfs->fs_bsize)) {
+		brelse(bp, 0);
+		kmem_free(newfs, fs->fs_sbsize);
+		return (EINVAL);
+	}
+
 	/* Store off old fs_sblockloc for fs_oldfscompat_read. */
 	sblockloc = fs->fs_sblockloc;
 	/*

Reply via email to