Skip to content

Commit f1fcd9f

Browse files
Christoph Hellwigtorvalds
Christoph Hellwig
authored andcommitted
hfsplus: fix filesystem size checks
generic_check_addressable can't deal with hfsplus's larger than page size allocation blocks, so simply opencode the checks that we actually need in hfsplus_fill_super. Signed-off-by: Christoph Hellwig <[email protected]> Reported-by: Pavel Ivanov <[email protected]> Tested-by: Pavel Ivanov <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent f588c96 commit f1fcd9f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fs/hfsplus/super.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
344344
struct inode *root, *inode;
345345
struct qstr str;
346346
struct nls_table *nls = NULL;
347+
u64 last_fs_block, last_fs_page;
347348
int err;
348349

349350
err = -EINVAL;
@@ -399,9 +400,13 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
399400
if (!sbi->rsrc_clump_blocks)
400401
sbi->rsrc_clump_blocks = 1;
401402

402-
err = generic_check_addressable(sbi->alloc_blksz_shift,
403-
sbi->total_blocks);
404-
if (err) {
403+
err = -EFBIG;
404+
last_fs_block = sbi->total_blocks - 1;
405+
last_fs_page = (last_fs_block << sbi->alloc_blksz_shift) >>
406+
PAGE_CACHE_SHIFT;
407+
408+
if ((last_fs_block > (sector_t)(~0ULL) >> (sbi->alloc_blksz_shift - 9)) ||
409+
(last_fs_page > (pgoff_t)(~0ULL))) {
405410
printk(KERN_ERR "hfs: filesystem size too large.\n");
406411
goto out_free_vhdr;
407412
}

0 commit comments

Comments
 (0)