Skip to content

Commit f5fb09f

Browse files
Andries BrouwerLinus Torvalds
authored andcommitted
[PATCH] Fix for minix crash
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); [akpm@osdl.org: make labels conistent while we're there] Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent fb8d81e commit f5fb09f

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎fs/minix/inode.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
204204
/*
205205
* Allocate the buffer map to keep the superblock small.
206206
*/
207+
if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
208+
goto out_illegal_sb;
207209
i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh);
208210
map = kmalloc(i, GFP_KERNEL);
209211
if (!map)
@@ -263,7 +265,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
263265

264266
out_no_bitmap:
265267
printk("MINIX-fs: bad superblock or unable to read bitmaps\n");
266-
out_freemap:
268+
out_freemap:
267269
for (i = 0; i < sbi->s_imap_blocks; i++)
268270
brelse(sbi->s_imap[i]);
269271
for (i = 0; i < sbi->s_zmap_blocks; i++)
@@ -276,11 +278,16 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
276278
printk("MINIX-fs: can't allocate map\n");
277279
goto out_release;
278280

281+
out_illegal_sb:
282+
if (!silent)
283+
printk("MINIX-fs: bad superblock\n");
284+
goto out_release;
285+
279286
out_no_fs:
280287
if (!silent)
281288
printk("VFS: Can't find a Minix or Minix V2 filesystem "
282289
"on device %s\n", s->s_id);
283-
out_release:
290+
out_release:
284291
brelse(bh);
285292
goto out;
286293

@@ -290,7 +297,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
290297

291298
out_bad_sb:
292299
printk("MINIX-fs: unable to read superblock\n");
293-
out:
300+
out:
294301
s->s_fs_info = NULL;
295302
kfree(sbi);
296303
return -EINVAL;

0 commit comments

Comments
 (0)