Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/ffs Add some checks in ffs_superblock_validate():
details: https://anonhg.NetBSD.org/src/rev/40147d0ad0fa
branches: trunk
changeset: 336113:40147d0ad0fa
user: maxv <maxv%NetBSD.org@localhost>
date: Fri Feb 13 16:59:52 2015 +0000
description:
Add some checks in ffs_superblock_validate():
- fs_bsize < MINBSIZE
- !powerof2(fs_bsize)
- !powerof2(fs->fs_fsize)
- fs_bsize < fs->fs_fsize
Based on makefs/ffs.
diffstat:
sys/ufs/ffs/ffs_vfsops.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diffs (42 lines):
diff -r f5b8883ba1d1 -r 40147d0ad0fa sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c Fri Feb 13 16:56:57 2015 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c Fri Feb 13 16:59:52 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_vfsops.c,v 1.307 2015/02/13 15:52:29 maxv Exp $ */
+/* $NetBSD: ffs_vfsops.c,v 1.308 2015/02/13 16:59:52 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.307 2015/02/13 15:52:29 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.308 2015/02/13 16:59:52 maxv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -912,12 +912,22 @@
return 0;
/* Check the file system blocksize */
- if (fs_bsize > MAXBSIZE)
+ if (fs_bsize > MAXBSIZE || fs_bsize < MINBSIZE)
+ return 0;
+ if (!powerof2(fs_bsize))
+ return 0;
+
+ /* Check the size of frag blocks */
+ if (!powerof2(fs->fs_fsize))
return 0;
if (fs->fs_size == 0)
return 0;
+ /* Block size cannot be smaller than fragment size */
+ if (fs_bsize < fs->fs_fsize)
+ return 0;
+
return 1;
}
Home |
Main Index |
Thread Index |
Old Index