From 29609c519c983ae414fa904cacfa963e910e8d0b Mon Sep 17 00:00:00 2001 From: jinzhimin369 Date: Wed, 16 Dec 2020 17:58:11 +0800 Subject: [PATCH] backport upstream patches-epoch2 to fix some problems --- ...gefile-from-4T-to-1T-in-hugefile-tes.patch | 31 +++++-- ...y-one-check-when-validating-depth-of.patch | 29 +++++++ ...eck-for-hardlinks-always-false-if-in.patch | 82 +++++++++++++++++++ ...-add-device-check-in-ismount-process.patch | 0 e2fsprogs.spec | 13 ++- 5 files changed, 145 insertions(+), 10 deletions(-) rename 9000-mke2fs-check.patch => 0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch (65%) create mode 100644 0002-e2fsck-fix-off-by-one-check-when-validating-depth-of.patch create mode 100644 0003-mke2fs-fix-up-check-for-hardlinks-always-false-if-in.patch rename 9001-add-device-check-in-ismount-process.patch => 0004-add-device-check-in-ismount-process.patch (100%) diff --git a/9000-mke2fs-check.patch b/0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch similarity index 65% rename from 9000-mke2fs-check.patch rename to 0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch index eb3ce4c..402f2bc 100644 --- a/9000-mke2fs-check.patch +++ b/0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch @@ -1,6 +1,21 @@ -diff -Npur e2fsprogs-1.44.4/tests/m_hugefile/expect e2fsprogs-1.44.4-hzq/tests/m_hugefile/expect ---- e2fsprogs-1.44.4/tests/m_hugefile/expect 2018-08-19 10:26:58.000000000 +0800 -+++ e2fsprogs-1.44.4-hzq/tests/m_hugefile/expect 2018-11-30 06:04:12.000000000 +0800 +From 851e3f835614371ab4e21c36f2ddcb6f0312a8bb Mon Sep 17 00:00:00 2001 +From: ZhiqiangLiu +Date: Wed, 15 Jul 2020 21:20:25 +0800 +Subject: [PATCH] e2fsprogs: set hugefile from 4T to 1T in hugefile test + +When execing make check, 4T is too large for CI, +so set hugefile from 4T to 1T in hugefile test. + +Signed-off-by: Zhiqiang Liu +--- + tests/m_hugefile/expect | 14 +++++++------- + tests/m_hugefile/script | 4 ++-- + 2 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/tests/m_hugefile/expect b/tests/m_hugefile/expect +index ee33fe5..170387a 100644 +--- a/tests/m_hugefile/expect ++++ b/tests/m_hugefile/expect @@ -1,19 +1,19 @@ -mke2fs -F -T hugefile test.img 4T -Creating filesystem with 1073741824 4k blocks and 1048576 inodes @@ -28,9 +43,10 @@ diff -Npur e2fsprogs-1.44.4/tests/m_hugefile/expect e2fsprogs-1.44.4-hzq/tests/m -Last physical block: 1073741823 +Last logical block: 268369919 +Last physical block: 268435455 -diff -Npur e2fsprogs-1.44.4/tests/m_hugefile/script e2fsprogs-1.44.4-hzq/tests/m_hugefile/script ---- e2fsprogs-1.44.4/tests/m_hugefile/script 2018-08-19 10:26:58.000000000 +0800 -+++ e2fsprogs-1.44.4-hzq/tests/m_hugefile/script 2018-11-30 05:52:17.000000000 +0800 +diff --git a/tests/m_hugefile/script b/tests/m_hugefile/script +index 1abdb7d..e576a21 100644 +--- a/tests/m_hugefile/script ++++ b/tests/m_hugefile/script @@ -35,8 +35,8 @@ cat > $CONF << ENDL } ENDL @@ -42,3 +58,6 @@ diff -Npur e2fsprogs-1.44.4/tests/m_hugefile/script e2fsprogs-1.44.4-hzq/tests/m rm -f $CONF # check the file system if we get this far, we succeeded... +-- +2.21.1 (Apple Git-122.3) + diff --git a/0002-e2fsck-fix-off-by-one-check-when-validating-depth-of.patch b/0002-e2fsck-fix-off-by-one-check-when-validating-depth-of.patch new file mode 100644 index 0000000..f5eb619 --- /dev/null +++ b/0002-e2fsck-fix-off-by-one-check-when-validating-depth-of.patch @@ -0,0 +1,29 @@ +From 2f6fd5da81a78aa45d750d8248b25171b8ad9dcd Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Fri, 10 Apr 2020 00:30:52 -0400 +Subject: [PATCH 13/26] e2fsck: fix off-by-one check when validating depth of + an htree + +Fixes: 3f0cf6475399 ("e2fsprogs: add support for 3-level htree") + +Signed-off-by: Theodore Ts'o +--- + e2fsck/pass1.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c +index c9e8bf8..38afda4 100644 +--- a/e2fsck/pass1.c ++++ b/e2fsck/pass1.c +@@ -2685,7 +2685,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx, + return 1; + + pctx->num = root->indirect_levels; +- if ((root->indirect_levels > ext2_dir_htree_level(fs)) && ++ if ((root->indirect_levels >= ext2_dir_htree_level(fs)) && + fix_problem(ctx, PR_1_HTREE_DEPTH, pctx)) + return 1; + +-- +1.8.3.1 + diff --git a/0003-mke2fs-fix-up-check-for-hardlinks-always-false-if-in.patch b/0003-mke2fs-fix-up-check-for-hardlinks-always-false-if-in.patch new file mode 100644 index 0000000..9e86c65 --- /dev/null +++ b/0003-mke2fs-fix-up-check-for-hardlinks-always-false-if-in.patch @@ -0,0 +1,82 @@ +From 4baaa1fcada10669af9c267d8c436383e0bffb07 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia +Date: Tue, 21 Jul 2020 18:25:03 -0700 +Subject: [PATCH 25/26] mke2fs: fix up check for hardlinks always false if + inode > 0xFFFFFFFF + +While file has a large inode number (> 0xFFFFFFFF), mkfs.ext4 could +not parse hardlink correctly. + +Prepare three hardlink files for mkfs.ext4 + +$ ls -il rootfs_ota/a rootfs_ota/boot/b rootfs_ota/boot/c +11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/a +11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/b +11026675846 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 rootfs_ota/boot/c + +$ truncate -s 1M rootfs_ota.ext4 + +$ mkfs.ext4 -F -i 8192 rootfs_ota.ext4 -L otaroot -U fd5f8768-c779-4dc9-adde-165a3d863349 -d rootfs_ota + +$ mkdir mnt && sudo mount rootfs_ota.ext4 mnt + +$ ls -il mnt/a mnt/boot/b mnt/boot/c +12 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/a +14 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/b +15 -rw-r--r-- 1 hjia users 0 Jul 20 17:44 mnt/boot/c + +After applying this fix +$ ls -il mnt/a mnt/boot/b mnt/boot/c +12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/a +12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/b +12 -rw-r--r-- 3 hjia users 0 Jul 20 17:44 mnt/boot/c + +Since commit [382ed4a1 e2fsck: use proper types for variables][1] +applied, it used ext2_ino_t instead of ino_t for referencing inode +numbers, but the type of is_hardlink's `ino' should not be instead, +The ext2_ino_t is 32bit, if inode > 0xFFFFFFFF, its value will be +truncated. + +Add a debug printf to show the value of inode, when it check for hardlink +files, it will always return false if inode > 0xFFFFFFFF +|--- a/misc/create_inode.c +|+++ b/misc/create_inode.c +|@@ -605,6 +605,7 @@ static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ext2_ino_t ino) +| { +| int i; +| +|+ printf("%s %d, %lX, %lX\n", __FUNCTION__, __LINE__, hdlinks->hdl[i].src_ino, ino); +| for (i = 0; i < hdlinks->count; i++) { +| if (hdlinks->hdl[i].src_dev == dev && +| hdlinks->hdl[i].src_ino == ino) + +Here is debug message: +is_hardlink 608, 2913DB886, 913DB886 + +The length of ext2_ino_t is 32bit (typedef __u32 __bitwise ext2_ino_t;), +and ino_t is 64bit on 64bit system (such as x86-64), recover `ino' to ino_t. + +[1] https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit/?id=382ed4a1c2b60acb9db7631e86dda207bde6076e + +Signed-off-by: Hongxu Jia +Signed-off-by: Theodore Ts'o +--- + misc/create_inode.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/misc/create_inode.c b/misc/create_inode.c +index e8d1df6..837f387 100644 +--- a/misc/create_inode.c ++++ b/misc/create_inode.c +@@ -601,7 +601,7 @@ out: + return err; + } + +-static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ext2_ino_t ino) ++static int is_hardlink(struct hdlinks_s *hdlinks, dev_t dev, ino_t ino) + { + int i; + +-- +1.8.3.1 + diff --git a/9001-add-device-check-in-ismount-process.patch b/0004-add-device-check-in-ismount-process.patch similarity index 100% rename from 9001-add-device-check-in-ismount-process.patch rename to 0004-add-device-check-in-ismount-process.patch diff --git a/e2fsprogs.spec b/e2fsprogs.spec index f40cbd3..efffa47 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -1,17 +1,19 @@ Name: e2fsprogs Version: 1.45.6 -Release: 1 +Release: 2 Summary: Second extended file system management tools License: GPLv2 and LGPLv2 and MIT URL: http://e2fsprogs.sourceforge.net/ Source0: https://www.kernel.org/pub/linux/kernel/people/tytso/%{name}/v%{version}/%{name}-%{version}.tar.xz -Patch9000: 9000-mke2fs-check.patch -Patch9001: 9001-add-device-check-in-ismount-process.patch +Patch1: 0001-e2fsprogs-set-hugefile-from-4T-to-1T-in-hugefile-tes.patch +Patch2: 0002-e2fsck-fix-off-by-one-check-when-validating-depth-of.patch +Patch3: 0003-mke2fs-fix-up-check-for-hardlinks-always-false-if-in.patch +Patch4: 0004-add-device-check-in-ismount-process.patch BuildRequires: gcc git pkgconfig texinfo BuildRequires: fuse-devel libblkid-devel libuuid-devel -Requires: %{name}-help = %{version}-%{release} +Recommends: %{name}-help = %{version}-%{release} Provides: e2fsprogs-libs%{?_isa} e2fsprogs-libs Obsoletes: e2fsprogs-libs @@ -128,6 +130,9 @@ exit 0 %{_mandir}/man8/* %changelog +* Wed Dec 16 2020 yanglongkang - 1.45.6-2 +- backport upstream patches-epoch2 to fix some problems + * Tue Nov 10 2020 lixiaokeng - 1.45.6-1 - Set help package as install require -- Gitee