Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/ffs ffs_superblock_validate(): when checking the num...



details:   https://anonhg.NetBSD.org/src/rev/7b220a98da35
branches:  trunk
changeset: 806288:7b220a98da35
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Feb 14 13:43:28 2015 +0000

description:
ffs_superblock_validate(): when checking the number of frag blocks, also
make sure it matches fs->fs_frag. This also prevents an infinite loop if
fs->fs_frag=0.

diffstat:

 sys/ufs/ffs/ffs_vfsops.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r b98b3c39d9e0 -r 7b220a98da35 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Sat Feb 14 13:07:39 2015 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Sat Feb 14 13:43:28 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vfsops.c,v 1.315 2015/02/14 10:21:29 maxv Exp $    */
+/*     $NetBSD: ffs_vfsops.c,v 1.316 2015/02/14 13:43:28 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.315 2015/02/14 10:21:29 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.316 2015/02/14 13:43:28 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -925,7 +925,7 @@
 static int
 ffs_superblock_validate(struct fs *fs)
 {
-       int32_t i, fs_bshift = 0, fs_fshift = 0;
+       int32_t i, fs_bshift = 0, fs_fshift = 0, fs_frag;
 
        /* Check the superblock size */
        if (fs->fs_sbsize > SBLOCKSIZE || fs->fs_sbsize < sizeof(struct fs))
@@ -965,7 +965,9 @@
        /* Now that the shifts are sanitized, we can use the ffs_ API */
 
        /* Check the number of frag blocks */
-       if (ffs_numfrags(fs, fs->fs_bsize) > MAXFRAG)
+       if ((fs_frag = ffs_numfrags(fs, fs->fs_bsize)) > MAXFRAG)
+               return 0;
+       if (fs->fs_frag != fs_frag)
                return 0;
 
        return 1;



Home | Main Index | Thread Index | Old Index