Module Name: src Committed By: maxv Date: Sat Feb 14 13:43:28 UTC 2015
Modified Files: src/sys/ufs/ffs: ffs_vfsops.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.315 -r1.316 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.315 src/sys/ufs/ffs/ffs_vfsops.c:1.316 --- src/sys/ufs/ffs/ffs_vfsops.c:1.315 Sat Feb 14 10:21:29 2015 +++ src/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 13:43:28 2015 @@ -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 const int sblock_try[] = SBLOCKSE 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 @@ ffs_superblock_validate(struct fs *fs) /* 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;