diff options
author | Bob Copeland <me@bobcopeland.com> | 2010-07-06 11:16:46 -0400 |
---|---|---|
committer | Bob Copeland <me@bobcopeland.com> | 2010-07-10 14:38:11 -0400 |
commit | 8800a044c71a128633cf3febaf4780531a991334 (patch) | |
tree | b736cdc086d86f27e1b52efa96f2a3f15fe1d443 /fs/omfs | |
parent | 9442e54f433eff9b6fbd0836611df4c1919df370 (diff) |
omfs: sanity check cluster size
A corrupt filesystem could have a bad cluster size; this could result in
the filesystem allocating too much space for files if too large, or
getting stuck in omfs_allocate_block if too small. The proper range is
1-8 blocks.
Reported-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Bob Copeland <me@bobcopeland.com>
Diffstat (limited to 'fs/omfs')
-rw-r--r-- | fs/omfs/inode.c | 6 | ||||
-rw-r--r-- | fs/omfs/omfs_fs.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c index 0af5d0af9f3..579d33feddd 100644 --- a/fs/omfs/inode.c +++ b/fs/omfs/inode.c | |||
@@ -517,6 +517,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent) | |||
517 | (unsigned long long) sbi->s_num_blocks); | 517 | (unsigned long long) sbi->s_num_blocks); |
518 | goto out_brelse_bh2; | 518 | goto out_brelse_bh2; |
519 | } | 519 | } |
520 | if (sbi->s_clustersize < 1 || | ||
521 | sbi->s_clustersize > OMFS_MAX_CLUSTER_SIZE) { | ||
522 | printk(KERN_ERR "omfs: cluster size out of range (%d)", | ||
523 | sbi->s_clustersize); | ||
524 | goto out_brelse_bh2; | ||
525 | } | ||
520 | 526 | ||
521 | ret = omfs_get_imap(sb); | 527 | ret = omfs_get_imap(sb); |
522 | if (ret) | 528 | if (ret) |
diff --git a/fs/omfs/omfs_fs.h b/fs/omfs/omfs_fs.h index 12cca245d6e..ee5e4327de9 100644 --- a/fs/omfs/omfs_fs.h +++ b/fs/omfs/omfs_fs.h | |||
@@ -17,6 +17,7 @@ | |||
17 | #define OMFS_EXTENT_CONT 0x40 | 17 | #define OMFS_EXTENT_CONT 0x40 |
18 | #define OMFS_XOR_COUNT 19 | 18 | #define OMFS_XOR_COUNT 19 |
19 | #define OMFS_MAX_BLOCK_SIZE 8192 | 19 | #define OMFS_MAX_BLOCK_SIZE 8192 |
20 | #define OMFS_MAX_CLUSTER_SIZE 8 | ||
20 | 21 | ||
21 | struct omfs_super_block { | 22 | struct omfs_super_block { |
22 | char s_fill1[256]; | 23 | char s_fill1[256]; |