aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Lamparter <chunkeey@gmail.com>2018-12-29 13:41:35 +0100
committerChristian Lamparter <chunkeey@gmail.com>2019-01-01 02:51:43 +0100
commitafcdf099b7cc505acf9497a3dbccf4e6bdc29c27 (patch)
treea6115e89e2aabe6f885a2694640ec633609ca00e
parent016a71a18a238842e36d6742af7fb852fe5742dc (diff)
downloadupstream-afcdf099b7cc505acf9497a3dbccf4e6bdc29c27.tar.gz
upstream-afcdf099b7cc505acf9497a3dbccf4e6bdc29c27.tar.bz2
upstream-afcdf099b7cc505acf9497a3dbccf4e6bdc29c27.zip
kernel: fix f2fs on big endian machines
The WD MyBook Live SquashFS images didn't work anymore due to a upstream regression in f2fs commit: 0cfe75c5b01199 ("f2fs: enhance sanity_check_raw_super() to avoid potential overflows") that got backported to 4.14.86 and 4.9.144. by Martin Blumenstingl: |Treat "block_count" from struct f2fs_super_block as 64-bit little endian |value in sanity_check_raw_super() because struct f2fs_super_block |declares "block_count" as "__le64". | |This fixes a bug where the superblock validation fails on big endian |devices with the following error: | F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0) | F2FS-fs (sda1): Can't find valid F2FS filesystem in 1th superblock | F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0) | F2FS-fs (sda1): Can't find valid F2FS filesystem in 2th superblock |As result of this the partition cannot be mounted. | |With this patch applied the superblock validation works fine and the |partition can be mounted again: | F2FS-fs (sda1): Mounted with checkpoint version = 7c84 | |My little endian x86-64 hardware was able to mount the partition without |this fix. |To confirm that mounting f2fs filesystems works on big endian machines |again I tested this on a 32-bit MIPS big endian (lantiq) device. Hopefully, this will do until Martin's patch moved through upstream to -stable. Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
-rw-r--r--target/linux/generic/pending-4.14/510-f2fs-fix-sanity_check_raw_super-on-big-endian-machines.patch51
-rw-r--r--target/linux/generic/pending-4.9/510-f2fs-fix-sanity_check_raw_super-on-big-endian-machines.patch51
2 files changed, 102 insertions, 0 deletions
diff --git a/target/linux/generic/pending-4.14/510-f2fs-fix-sanity_check_raw_super-on-big-endian-machines.patch b/target/linux/generic/pending-4.14/510-f2fs-fix-sanity_check_raw_super-on-big-endian-machines.patch
new file mode 100644
index 0000000000..6cbaf28e81
--- /dev/null
+++ b/target/linux/generic/pending-4.14/510-f2fs-fix-sanity_check_raw_super-on-big-endian-machines.patch
@@ -0,0 +1,51 @@
+From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+To: linux-f2fs-devel@lists.sourceforge.net, yuchao0@huawei.com,
+ jaegeuk@kernel.org
+Subject: [PATCH v2 1/1] f2fs: fix validation of the block count in
+ sanity_check_raw_super
+Date: Sat, 22 Dec 2018 11:22:26 +0100
+Message-Id: <20181222102226.10050-2-martin.blumenstingl@googlemail.com>
+
+Treat "block_count" from struct f2fs_super_block as 64-bit little endian
+value in sanity_check_raw_super() because struct f2fs_super_block
+declares "block_count" as "__le64".
+
+This fixes a bug where the superblock validation fails on big endian
+devices with the following error:
+ F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0)
+ F2FS-fs (sda1): Can't find valid F2FS filesystem in 1th superblock
+ F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0)
+ F2FS-fs (sda1): Can't find valid F2FS filesystem in 2th superblock
+As result of this the partition cannot be mounted.
+
+With this patch applied the superblock validation works fine and the
+partition can be mounted again:
+ F2FS-fs (sda1): Mounted with checkpoint version = 7c84
+
+My little endian x86-64 hardware was able to mount the partition without
+this fix.
+To confirm that mounting f2fs filesystems works on big endian machines
+again I tested this on a 32-bit MIPS big endian (lantiq) device.
+
+Fixes: 0cfe75c5b01199 ("f2fs: enhance sanity_check_raw_super() to avoid potential overflows")
+Cc: stable@vger.kernel.org
+Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+Reviewed-by: Chao Yu <yuchao0@huawei.com>
+---
+
+--- a/fs/f2fs/super.c
++++ b/fs/f2fs/super.c
+@@ -1897,10 +1897,10 @@ static int sanity_check_raw_super(struct
+ return 1;
+ }
+
+- if (segment_count > (le32_to_cpu(raw_super->block_count) >> 9)) {
++ if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) {
+ f2fs_msg(sb, KERN_INFO,
+- "Wrong segment_count / block_count (%u > %u)",
+- segment_count, le32_to_cpu(raw_super->block_count));
++ "Wrong segment_count / block_count (%u > %llu)",
++ segment_count, le64_to_cpu(raw_super->block_count));
+ return 1;
+ }
+
diff --git a/target/linux/generic/pending-4.9/510-f2fs-fix-sanity_check_raw_super-on-big-endian-machines.patch b/target/linux/generic/pending-4.9/510-f2fs-fix-sanity_check_raw_super-on-big-endian-machines.patch
new file mode 100644
index 0000000000..5844af5233
--- /dev/null
+++ b/target/linux/generic/pending-4.9/510-f2fs-fix-sanity_check_raw_super-on-big-endian-machines.patch
@@ -0,0 +1,51 @@
+From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+To: linux-f2fs-devel@lists.sourceforge.net, yuchao0@huawei.com,
+ jaegeuk@kernel.org
+Subject: [PATCH v2 1/1] f2fs: fix validation of the block count in
+ sanity_check_raw_super
+Date: Sat, 22 Dec 2018 11:22:26 +0100
+Message-Id: <20181222102226.10050-2-martin.blumenstingl@googlemail.com>
+
+Treat "block_count" from struct f2fs_super_block as 64-bit little endian
+value in sanity_check_raw_super() because struct f2fs_super_block
+declares "block_count" as "__le64".
+
+This fixes a bug where the superblock validation fails on big endian
+devices with the following error:
+ F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0)
+ F2FS-fs (sda1): Can't find valid F2FS filesystem in 1th superblock
+ F2FS-fs (sda1): Wrong segment_count / block_count (61439 > 0)
+ F2FS-fs (sda1): Can't find valid F2FS filesystem in 2th superblock
+As result of this the partition cannot be mounted.
+
+With this patch applied the superblock validation works fine and the
+partition can be mounted again:
+ F2FS-fs (sda1): Mounted with checkpoint version = 7c84
+
+My little endian x86-64 hardware was able to mount the partition without
+this fix.
+To confirm that mounting f2fs filesystems works on big endian machines
+again I tested this on a 32-bit MIPS big endian (lantiq) device.
+
+Fixes: 0cfe75c5b01199 ("f2fs: enhance sanity_check_raw_super() to avoid potential overflows")
+Cc: stable@vger.kernel.org
+Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+Reviewed-by: Chao Yu <yuchao0@huawei.com>
+---
+
+--- a/fs/f2fs/super.c
++++ b/fs/f2fs/super.c
+@@ -1427,10 +1427,10 @@ static int sanity_check_raw_super(struct
+ return 1;
+ }
+
+- if (segment_count > (le32_to_cpu(raw_super->block_count) >> 9)) {
++ if (segment_count > (le64_to_cpu(raw_super->block_count) >> 9)) {
+ f2fs_msg(sb, KERN_INFO,
+- "Wrong segment_count / block_count (%u > %u)",
+- segment_count, le32_to_cpu(raw_super->block_count));
++ "Wrong segment_count / block_count (%u > %llu)",
++ segment_count, le64_to_cpu(raw_super->block_count));
+ return 1;
+ }
+