Skip to content

Commit 76e5121

Browse files
Fabian Fredericktorvalds
authored andcommitted
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>
1 parent 5ef9819 commit 76e5121

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎fs/omfs/inode.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,7 @@ static const struct super_operations omfs_sops = {
306306
*/
307307
static int omfs_get_imap(struct super_block *sb)
308308
{
309-
int bitmap_size;
310-
int array_size;
311-
int count;
309+
unsigned int bitmap_size, count, array_size;
312310
struct omfs_sb_info *sbi = OMFS_SB(sb);
313311
struct buffer_head *bh;
314312
unsigned long **ptr;
@@ -473,6 +471,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
473471
sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize);
474472
mutex_init(&sbi->s_bitmap_lock);
475473

474+
if (sbi->s_num_blocks > OMFS_MAX_BLOCKS) {
475+
printk(KERN_ERR "omfs: sysblock number (%llx) is out of range\n",
476+
(unsigned long long)sbi->s_num_blocks);
477+
goto out_brelse_bh;
478+
}
479+
476480
if (sbi->s_sys_blocksize > PAGE_SIZE) {
477481
printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n",
478482
sbi->s_sys_blocksize);

‎fs/omfs/omfs_fs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define OMFS_XOR_COUNT 19
1919
#define OMFS_MAX_BLOCK_SIZE 8192
2020
#define OMFS_MAX_CLUSTER_SIZE 8
21+
#define OMFS_MAX_BLOCKS (1ul << 31)
2122

2223
struct omfs_super_block {
2324
char s_fill1[256];

0 commit comments

Comments
 (0)