]>
Commit | Line | Data |
---|---|---|
517ec11f GKH |
1 | From b9dd46188edc2f0d1f37328637860bb65a771124 Mon Sep 17 00:00:00 2001 |
2 | From: Jin Qian <jinqian@google.com> | |
3 | Date: Tue, 25 Apr 2017 16:28:48 -0700 | |
4 | Subject: f2fs: sanity check segment count | |
5 | ||
6 | From: Jin Qian <jinqian@google.com> | |
7 | ||
8 | commit b9dd46188edc2f0d1f37328637860bb65a771124 upstream. | |
9 | ||
10 | F2FS uses 4 bytes to represent block address. As a result, supported | |
11 | size of disk is 16 TB and it equals to 16 * 1024 * 1024 / 2 segments. | |
12 | ||
13 | Signed-off-by: Jin Qian <jinqian@google.com> | |
14 | Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> | |
15 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
16 | ||
17 | --- | |
18 | fs/f2fs/super.c | 7 +++++++ | |
19 | include/linux/f2fs_fs.h | 6 ++++++ | |
20 | 2 files changed, 13 insertions(+) | |
21 | ||
22 | --- a/fs/f2fs/super.c | |
23 | +++ b/fs/f2fs/super.c | |
24 | @@ -1405,6 +1405,13 @@ static int sanity_check_raw_super(struct | |
25 | return 1; | |
26 | } | |
27 | ||
28 | + if (le32_to_cpu(raw_super->segment_count) > F2FS_MAX_SEGMENT) { | |
29 | + f2fs_msg(sb, KERN_INFO, | |
30 | + "Invalid segment count (%u)", | |
31 | + le32_to_cpu(raw_super->segment_count)); | |
32 | + return 1; | |
33 | + } | |
34 | + | |
35 | /* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */ | |
36 | if (sanity_check_area_boundary(sbi, bh)) | |
37 | return 1; | |
38 | --- a/include/linux/f2fs_fs.h | |
39 | +++ b/include/linux/f2fs_fs.h | |
40 | @@ -286,6 +286,12 @@ struct f2fs_nat_block { | |
41 | #define SIT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_sit_entry)) | |
42 | ||
43 | /* | |
44 | + * F2FS uses 4 bytes to represent block address. As a result, supported size of | |
45 | + * disk is 16 TB and it equals to 16 * 1024 * 1024 / 2 segments. | |
46 | + */ | |
47 | +#define F2FS_MAX_SEGMENT ((16 * 1024 * 1024) / 2) | |
48 | + | |
49 | +/* | |
50 | * Note that f2fs_sit_entry->vblocks has the following bit-field information. | |
51 | * [15:10] : allocation type such as CURSEG_XXXX_TYPE | |
52 | * [9:0] : valid block count |