Skip to content

Commit 09a4e0b

Browse files
Eric Sandeenjankara
authored andcommitted
isofs: reject hardware sector size > 2048 bytes
The largest block size supported by isofs is ISOFS_BLOCK_SIZE (2048), but isofs_fill_super calls sb_min_blocksize and sets the blocksize to the device's logical block size if it's larger than what we ended up with after option parsing. If for some reason we try to mount a hard 4k device as an isofs filesystem, we'll set opt.blocksize to 4096, and when we try to read the superblock we found via: block = iso_blknum << (ISOFS_BLOCK_BITS - s->s_blocksize_bits) with s_blocksize_bits greater than ISOFS_BLOCK_BITS, we'll have a negative shift and the bread will fail somewhat cryptically: isofs_fill_super: bread failed, dev=sda, iso_blknum=17, block=-2147483648 It seems best to just catch and clearly reject mounts of such a device. Reported-by: Bryan Gurney <bgurney@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent d3bc0fa commit 09a4e0b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎fs/isofs/inode.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/mpage.h>
2525
#include <linux/user_namespace.h>
2626
#include <linux/seq_file.h>
27+
#include <linux/blkdev.h>
2728

2829
#include "isofs.h"
2930
#include "zisofs.h"
@@ -653,6 +654,12 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
653654
/*
654655
* What if bugger tells us to go beyond page size?
655656
*/
657+
if (bdev_logical_block_size(s->s_bdev) > 2048) {
658+
printk(KERN_WARNING
659+
"ISOFS: unsupported/invalid hardware sector size %d\n",
660+
bdev_logical_block_size(s->s_bdev));
661+
goto out_freesbi;
662+
}
656663
opt.blocksize = sb_min_blocksize(s, opt.blocksize);
657664

658665
sbi->s_high_sierra = 0; /* default is iso9660 */

0 commit comments

Comments
 (0)