]>
Commit | Line | Data |
---|---|---|
7f041dd7 GKH |
1 | From a81c41ac6e920bdb87b51f20afde929cb08c00a1 Mon Sep 17 00:00:00 2001 |
2 | From: Eric Sandeen <sandeen@redhat.com> | |
3 | Date: Mon, 17 Aug 2009 23:48:51 -0400 | |
4 | Subject: [PATCH 10/85] ext4: reject too-large filesystems on 32-bit kernels | |
5 | ||
6 | (cherry picked from commit bf43d84b185e2ff54598f8c58a5a8e63148b6e90) | |
7 | ||
8 | ext4 will happily mount a > 16T filesystem on a 32-bit box, but | |
9 | this is not safe; writes to the block device will wrap past 16T | |
10 | and the page cache can't index past 16T (232 index * 4k pages). | |
11 | ||
12 | Adding another test to the existing "too many sectors" test | |
13 | should do the trick. | |
14 | ||
15 | Add a comment, a relevant return value, and fix the reference | |
16 | to the CONFIG_LBD(AF) option as well. | |
17 | ||
18 | Signed-off-by: Eric Sandeen <sandeen@redhat.com> | |
19 | Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> | |
20 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
21 | --- | |
22 | fs/ext4/super.c | 13 ++++++++++--- | |
23 | 1 file changed, 10 insertions(+), 3 deletions(-) | |
24 | ||
25 | --- a/fs/ext4/super.c | |
26 | +++ b/fs/ext4/super.c | |
27 | @@ -2550,12 +2550,19 @@ static int ext4_fill_super(struct super_ | |
28 | goto failed_mount; | |
29 | } | |
30 | ||
31 | - if (ext4_blocks_count(es) > | |
32 | - (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { | |
33 | + /* | |
34 | + * Test whether we have more sectors than will fit in sector_t, | |
35 | + * and whether the max offset is addressable by the page cache. | |
36 | + */ | |
37 | + if ((ext4_blocks_count(es) > | |
38 | + (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) || | |
39 | + (ext4_blocks_count(es) > | |
40 | + (pgoff_t)(~0ULL) >> (PAGE_CACHE_SHIFT - sb->s_blocksize_bits))) { | |
41 | ext4_msg(sb, KERN_ERR, "filesystem" | |
42 | - " too large to mount safely"); | |
43 | + " too large to mount safely on this system"); | |
44 | if (sizeof(sector_t) < 8) | |
45 | ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); | |
46 | + ret = -EFBIG; | |
47 | goto failed_mount; | |
48 | } | |
49 |