Skip to content

Commit 8800a04

Browse files
committed
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>
1 parent 9442e54 commit 8800a04

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎fs/omfs/inode.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
517517
(unsigned long long) sbi->s_num_blocks);
518518
goto out_brelse_bh2;
519519
}
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+
}
520526

521527
ret = omfs_get_imap(sb);
522528
if (ret)

‎fs/omfs/omfs_fs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define OMFS_EXTENT_CONT 0x40
1818
#define OMFS_XOR_COUNT 19
1919
#define OMFS_MAX_BLOCK_SIZE 8192
20+
#define OMFS_MAX_CLUSTER_SIZE 8
2021

2122
struct omfs_super_block {
2223
char s_fill1[256];

0 commit comments

Comments
 (0)