diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-06-17 16:30:59 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-06-17 16:30:59 +0000 |
commit | 3bf8483d625f82dbcfb29f0a44b051ee1e86afdc (patch) | |
tree | 66d2877515d30578caecbfff4232f3a495664d4e | |
parent | f1553a4136f90ff275ea219f01956c86bd7afeff (diff) |
Refuse to mount a ffs fielsystems whose number of frags is not 1, 2, 4 or 8,
and remove the corresponding panics in low level code.
ok pedro@ weingart@
-rw-r--r-- | sys/ufs/ffs/ffs_subr.c | 15 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 5 |
2 files changed, 9 insertions, 11 deletions
diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index d542d97094b..e41c52218c7 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_subr.c,v 1.17 2005/11/08 02:29:51 pedro Exp $ */ +/* $OpenBSD: ffs_subr.c,v 1.18 2006/06/17 16:30:58 miod Exp $ */ /* $NetBSD: ffs_subr.c,v 1.6 1996/03/17 02:16:23 christos Exp $ */ /* @@ -161,6 +161,7 @@ ffs_isblock(struct fs *fs, unsigned char *cp, daddr_t h) unsigned char mask; switch ((int)fs->fs_frag) { + default: case 8: return (cp[h] == 0xff); case 4: @@ -172,8 +173,6 @@ ffs_isblock(struct fs *fs, unsigned char *cp, daddr_t h) case 1: mask = 0x01 << (h & 0x7); return ((cp[h >> 3] & mask) == mask); - default: - panic("ffs_isblock"); } } @@ -185,6 +184,7 @@ ffs_clrblock(struct fs *fs, u_char *cp, daddr_t h) { switch ((int)fs->fs_frag) { + default: case 8: cp[h] = 0; return; @@ -197,8 +197,6 @@ ffs_clrblock(struct fs *fs, u_char *cp, daddr_t h) case 1: cp[h >> 3] &= ~(0x01 << (h & 0x7)); return; - default: - panic("ffs_clrblock"); } } @@ -210,7 +208,7 @@ ffs_setblock(struct fs *fs, unsigned char *cp, daddr_t h) { switch ((int)fs->fs_frag) { - + default: case 8: cp[h] = 0xff; return; @@ -223,8 +221,6 @@ ffs_setblock(struct fs *fs, unsigned char *cp, daddr_t h) case 1: cp[h >> 3] |= (0x01 << (h & 0x7)); return; - default: - panic("ffs_setblock"); } } @@ -236,6 +232,7 @@ ffs_isfreeblock(struct fs *fs, unsigned char *cp, daddr_t h) { switch ((int)fs->fs_frag) { + default: case 8: return (cp[h] == 0); case 4: @@ -244,7 +241,5 @@ ffs_isfreeblock(struct fs *fs, unsigned char *cp, daddr_t h) return ((cp[h >> 2] & (0x03 << ((h & 0x3) << 1))) == 0); case 1: return ((cp[h >> 3] & (0x01 << (h & 0x7))) == 0); - default: - panic("ffs_isfreeblock"); } } diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index e2bfd0f7f75..7729df1320f 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.93 2006/05/20 16:03:46 pedro Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.94 2006/06/17 16:30:58 miod Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -633,6 +633,9 @@ ffs_validate(struct fs *fsp) if ((u_int)fsp->fs_sbsize > SBSIZE) return (0); /* Invalid super block size */ + if ((u_int)fsp->fs_frag > MAXFRAG || fragtbl[fsp->fs_frag] == NULL) + return (0); /* Invalid number of fragments */ + return (1); /* Super block is okay */ } |