fix for minix crash

From: Andries.Brouwer
Date: Tue Aug 22 2006 - 05:59:10 EST


Mounting a (corrupt) minix filesystem with zero s_zmap_blocks
gives a spectacular crash on my 2.6.17.8 system, no doubt
because minix/inode.c does an unconditional
minix_set_bit(0,sbi->s_zmap[0]->b_data);
Here a fix (against 2.6.17.8).

Andries

diff -uprN -X /linux/dontdiff a/fs/minix/inode.c b/fs/minix/inode.c
--- a/fs/minix/inode.c 2006-08-07 16:01:12.000000000 +0200
+++ b/fs/minix/inode.c 2006-08-22 11:15:53.000000000 +0200
@@ -204,6 +204,8 @@ static int minix_fill_super(struct super
/*
* Allocate the buffer map to keep the superblock small.
*/
+ if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
+ goto out_illegal_sb;
i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh);
map = kmalloc(i, GFP_KERNEL);
if (!map)
@@ -276,6 +278,11 @@ out_no_map:
printk("MINIX-fs: can't allocate map\n");
goto out_release;

+out_illegal_sb:
+ if (!silent)
+ printk("MINIX-fs: bad superblock\n");
+ goto out_release;
+
out_no_fs:
if (!silent)
printk("VFS: Can't find a Minix or Minix V2 filesystem "
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/