Commit 8800a044 authored by Bob Copeland's avatar Bob Copeland

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: default avatarEric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: default avatarBob Copeland <me@bobcopeland.com>
parent 9442e54f
...@@ -517,6 +517,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -517,6 +517,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
(unsigned long long) sbi->s_num_blocks); (unsigned long long) sbi->s_num_blocks);
goto out_brelse_bh2; goto out_brelse_bh2;
} }
if (sbi->s_clustersize < 1 ||
sbi->s_clustersize > OMFS_MAX_CLUSTER_SIZE) {
printk(KERN_ERR "omfs: cluster size out of range (%d)",
sbi->s_clustersize);
goto out_brelse_bh2;
}
ret = omfs_get_imap(sb); ret = omfs_get_imap(sb);
if (ret) if (ret)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define OMFS_EXTENT_CONT 0x40 #define OMFS_EXTENT_CONT 0x40
#define OMFS_XOR_COUNT 19 #define OMFS_XOR_COUNT 19
#define OMFS_MAX_BLOCK_SIZE 8192 #define OMFS_MAX_BLOCK_SIZE 8192
#define OMFS_MAX_CLUSTER_SIZE 8
struct omfs_super_block { struct omfs_super_block {
char s_fill1[256]; char s_fill1[256];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment