kernel: MIPS: Add CPU option reporting to /proc/cpuinfo
[openwrt/staging/dedeckeh.git] / target / linux / generic / pending-4.14 / 510-f2fs-fix-sanity_check_raw_super-on-big-endian-machines.patch
1 From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
2 To: linux-f2fs-devel@lists.sourceforge.net, yuchao0@huawei.com,
3 jaegeuk@kernel.org
4 Subject: [PATCH v2 1/1] f2fs: fix validation of the block count in
5 sanity_check_raw_super
6 Date: Sat, 22 Dec 2018 11:22:26 +0100
7 Message-Id: <20181222102226.10050-2-martin.blumenstingl@googlemail.com>
8
9 Treat "block_count" from struct f2fs_super_block as 64-bit little endian
10 value in sanity_check_raw_super() because struct f2fs_super_block
11 declares "block_count" as "__le64".
12
13 This fixes a bug where the superblock validation fails on big endian
14 devices with the following error:
15 F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0)
16 F2FS-fs (sda1): Can't find valid F2FS filesystem in 1th superblock
17 F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0)
18 F2FS-fs (sda1): Can't find valid F2FS filesystem in 2th superblock
19 As result of this the partition cannot be mounted.
20
21 With this patch applied the superblock validation works fine and the
22 partition can be mounted again:
23 F2FS-fs (sda1): Mounted with checkpoint version = 7c84
24
25 My little endian x86-64 hardware was able to mount the partition without
26 this fix.
27 To confirm that mounting f2fs filesystems works on big endian machines
28 again I tested this on a 32-bit MIPS big endian (lantiq) device.
29
30 Fixes: 0cfe75c5b01199 ("f2fs: enhance sanity_check_raw_super() to avoid potential overflows")
31 Cc: stable@vger.kernel.org
32 Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
33 Reviewed-by: Chao Yu <yuchao0@huawei.com>
34 ---
35
36 --- a/fs/f2fs/super.c
37 +++ b/fs/f2fs/super.c
38 @@ -1897,10 +1897,10 @@ static int sanity_check_raw_super(struct
39 return 1;
40 }
41
42 - if (segment_count > (le32_to_cpu(raw_super->block_count) >> 9)) {
43 + if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) {
44 f2fs_msg(sb, KERN_INFO,
45 - "Wrong segment_count / block_count (%u > %u)",
46 - segment_count, le32_to_cpu(raw_super->block_count));
47 + "Wrong segment_count / block_count (%u > %llu)",
48 + segment_count, le64_to_cpu(raw_super->block_count));
49 return 1;
50 }
51