Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

FS/OMFS: block number sanity check during fill_super operation

This patch defines maximum block number to 2^31. It also converts
bitmap_size and array_size to unsigned int in omfs_get_imap

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Suggested-by: Bob Copeland <me@bobcopeland.com>
Acked-by: Bob Copeland <me@bobcopeland.com>
Tested-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Fabian Frederick and committed by
Linus Torvalds
76e51210 5ef98192

+8 -3
+7 -3
fs/omfs/inode.c
··· 306 306 */ 307 307 static int omfs_get_imap(struct super_block *sb) 308 308 { 309 - int bitmap_size; 310 - int array_size; 311 - int count; 309 + unsigned int bitmap_size, count, array_size; 312 310 struct omfs_sb_info *sbi = OMFS_SB(sb); 313 311 struct buffer_head *bh; 314 312 unsigned long **ptr; ··· 470 472 sbi->s_root_ino = be64_to_cpu(omfs_sb->s_root_block); 471 473 sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize); 472 474 mutex_init(&sbi->s_bitmap_lock); 475 + 476 + if (sbi->s_num_blocks > OMFS_MAX_BLOCKS) { 477 + printk(KERN_ERR "omfs: sysblock number (%llx) is out of range\n", 478 + (unsigned long long)sbi->s_num_blocks); 479 + goto out_brelse_bh; 480 + } 473 481 474 482 if (sbi->s_sys_blocksize > PAGE_SIZE) { 475 483 printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n",
+1
fs/omfs/omfs_fs.h
··· 18 18 #define OMFS_XOR_COUNT 19 19 19 #define OMFS_MAX_BLOCK_SIZE 8192 20 20 #define OMFS_MAX_CLUSTER_SIZE 8 21 + #define OMFS_MAX_BLOCKS (1ul << 31) 21 22 22 23 struct omfs_super_block { 23 24 char s_fill1[256];