summaryrefslogtreecommitdiffstats
path: root/fs/omfs/inode.c
diff options
context:
space:
mode:
authorFabian Frederick <fabf@skynet.be>2014-10-13 15:54:01 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-14 02:18:22 +0200
commit76e512108935ecdb46792208dae5f59c7ea78e25 (patch)
tree96ea1468ce3e23c2add86f986948a17d0eaad4ee /fs/omfs/inode.c
parent5ef9819234e285abe6b616864e7b1b4607d39b58 (diff)
downloadop-kernel-dev-76e512108935ecdb46792208dae5f59c7ea78e25.zip
op-kernel-dev-76e512108935ecdb46792208dae5f59c7ea78e25.tar.gz
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>
Diffstat (limited to 'fs/omfs/inode.c')
-rw-r--r--fs/omfs/inode.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index ba88197..138321b 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -306,9 +306,7 @@ static const struct super_operations omfs_sops = {
*/
static int omfs_get_imap(struct super_block *sb)
{
- int bitmap_size;
- int array_size;
- int count;
+ unsigned int bitmap_size, count, array_size;
struct omfs_sb_info *sbi = OMFS_SB(sb);
struct buffer_head *bh;
unsigned long **ptr;
@@ -473,6 +471,12 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent)
sbi->s_sys_blocksize = be32_to_cpu(omfs_sb->s_sys_blocksize);
mutex_init(&sbi->s_bitmap_lock);
+ if (sbi->s_num_blocks > OMFS_MAX_BLOCKS) {
+ printk(KERN_ERR "omfs: sysblock number (%llx) is out of range\n",
+ (unsigned long long)sbi->s_num_blocks);
+ goto out_brelse_bh;
+ }
+
if (sbi->s_sys_blocksize > PAGE_SIZE) {
printk(KERN_ERR "omfs: sysblock size (%d) is out of range\n",
sbi->s_sys_blocksize);
OpenPOWER on IntegriCloud