]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.172/f2fs-fix-validation-of-the-block-count-in-sanity_check_raw_super.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.172 / f2fs-fix-validation-of-the-block-count-in-sanity_check_raw_super.patch
CommitLineData
c2a518a0
GKH
1From foo@baz Fri Jan 18 09:16:11 CET 2019
2From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
3Date: Sat, 22 Dec 2018 11:22:26 +0100
4Subject: f2fs: fix validation of the block count in sanity_check_raw_super
5
6From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
7
8commit 88960068f25fcc3759455d85460234dcc9d43fef upstream.
9
10Treat "block_count" from struct f2fs_super_block as 64-bit little endian
11value in sanity_check_raw_super() because struct f2fs_super_block
12declares "block_count" as "__le64".
13
14This fixes a bug where the superblock validation fails on big endian
15devices with the following error:
16 F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0)
17 F2FS-fs (sda1): Can't find valid F2FS filesystem in 1th superblock
18 F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0)
19 F2FS-fs (sda1): Can't find valid F2FS filesystem in 2th superblock
20As result of this the partition cannot be mounted.
21
22With this patch applied the superblock validation works fine and the
23partition can be mounted again:
24 F2FS-fs (sda1): Mounted with checkpoint version = 7c84
25
26My little endian x86-64 hardware was able to mount the partition without
27this fix.
28To confirm that mounting f2fs filesystems works on big endian machines
29again I tested this on a 32-bit MIPS big endian (lantiq) device.
30
31Fixes: 0cfe75c5b01199 ("f2fs: enhance sanity_check_raw_super() to avoid potential overflows")
32Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
33Reviewed-by: Chao Yu <yuchao0@huawei.com>
34Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
35Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
36Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37---
38 fs/f2fs/super.c | 6 +++---
39 1 file changed, 3 insertions(+), 3 deletions(-)
40
41--- a/fs/f2fs/super.c
42+++ b/fs/f2fs/super.c
43@@ -1081,10 +1081,10 @@ static int sanity_check_raw_super(struct
44 return 1;
45 }
46
47- if (segment_count > (le32_to_cpu(raw_super->block_count) >> 9)) {
48+ if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) {
49 f2fs_msg(sb, KERN_INFO,
50- "Wrong segment_count / block_count (%u > %u)",
51- segment_count, le32_to_cpu(raw_super->block_count));
52+ "Wrong segment_count / block_count (%u > %llu)",
53+ segment_count, le64_to_cpu(raw_super->block_count));
54 return 1;
55 }
56