From 82b2bbe7a82806cf90c09481320a02003dd2d7e9 Mon Sep 17 00:00:00 2001 From: zhangjian Date: Wed, 20 Aug 2025 03:22:30 +0000 Subject: [PATCH] sync patches from 2403-sp2 --- ...hash_version-from-superblock-if-a-fi.patch | 52 +++++++++++++ ...-block-leak-when-process-orphan-list.patch | 78 +++++++++++++++++++ ...ing-of-a-invalid-symlink-in-an-inlin.patch | 46 +++++++++++ ...-dumpe2fs-to-report-free-block-range.patch | 71 +++++++++++++++++ ...rect-I-O-when-reading-the-superblock.patch | 37 +++++++++ e2fsprogs.spec | 10 ++- 6 files changed, 293 insertions(+), 1 deletion(-) create mode 100644 0018-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch create mode 100644 0019-e2fsck-fix-acl-block-leak-when-process-orphan-list.patch create mode 100644 0020-e2fsck-fix-handling-of-a-invalid-symlink-in-an-inlin.patch create mode 100644 0021-e2fsprogs-modify-dumpe2fs-to-report-free-block-range.patch create mode 100644 0022-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch diff --git a/0018-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch b/0018-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch new file mode 100644 index 0000000..0b01809 --- /dev/null +++ b/0018-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch @@ -0,0 +1,52 @@ +From 29d83fef9e6eab139516afe433c03d975e85c25b Mon Sep 17 00:00:00 2001 +From: Srivathsa Dara +Date: Thu, 24 Aug 2023 06:56:34 +0000 +Subject: [PATCH] debugfs: Use the hash_version from superblock if a file + system is opened + +The debugfs program's dx_hash command computes the hash for the given +filename, taking the hash_seed and hash_version (i.e hash algorithm) +as arguments. So the user has to refer to the superblock to get these +values used by the filesystem. So if debugfs has an opened file +system, use those values from the current file system. + +[ Fixed patch to avoid crashing when a file system is not opened. --TYT ] + +Conflict:NA +Reference: https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit?id=29d83fef9e6eab139516afe433c03d975e85c25b + +Signed-off-by: Srivathsa Dara +Link: https://lore.kernel.org/r/20230824065634.2662858-1-srivathsa.d.dara@oracle.com +Signed-off-by: Theodore Ts'o +--- + debugfs/htree.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/debugfs/htree.c b/debugfs/htree.c +index a9f9211b..a3e95ddb 100644 +--- a/debugfs/htree.c ++++ b/debugfs/htree.c +@@ -336,11 +336,18 @@ void do_dx_hash(int argc, char *argv[], int sci_idx EXT2FS_ATTR((unused)), + errcode_t err; + int c; + int hash_version = 0; +- __u32 hash_seed[4]; ++ __u32 hash_seed[4] = { 0, }; + int hash_flags = 0; + const struct ext2fs_nls_table *encoding = NULL; + +- hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0; ++ if (current_fs) { ++ hash_seed[0] = current_fs->super->s_hash_seed[0]; ++ hash_seed[1] = current_fs->super->s_hash_seed[1]; ++ hash_seed[2] = current_fs->super->s_hash_seed[2]; ++ hash_seed[3] = current_fs->super->s_hash_seed[3]; ++ ++ hash_version = current_fs->super->s_def_hash_version; ++ } + + reset_getopt(); + while ((c = getopt(argc, argv, "h:s:ce:")) != EOF) { +-- +2.32.0 + \ No newline at end of file diff --git a/0019-e2fsck-fix-acl-block-leak-when-process-orphan-list.patch b/0019-e2fsck-fix-acl-block-leak-when-process-orphan-list.patch new file mode 100644 index 0000000..f6090e2 --- /dev/null +++ b/0019-e2fsck-fix-acl-block-leak-when-process-orphan-list.patch @@ -0,0 +1,78 @@ +From 4c2fb1cc1848790735cb6bc78b5dfb8a30d326c2 Mon Sep 17 00:00:00 2001 +From: Ye Bin +Date: Thu, 18 Apr 2024 14:39:46 +0800 +Subject: [PATCH] e2fsck: fix acl block leak when process orphan list + +Conflict: NA +Reference: https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit/?id=4c2fb1cc1848790735cb6bc78b5dfb8a30d326c2 + + There's a issue: + []$~/e2fsprogs/e2fsck/e2fsck -f scsi-disk2.img + e2fsck 1.47.0 (5-Feb-2023) + scsi-disk2.img: recovering journal + Clearing orphaned inode 12 (uid=0, gid=0, mode=0140777, size=0) + Pass 1: Checking inodes, blocks, and sizes + Extended attribute block 4247 has reference count 3, should be 2. Fix? no + Pass 2: Checking directory structure + Pass 3: Checking directory connectivity + Pass 4: Checking reference counts + Pass 5: Checking group summary information + Free blocks count wrong (249189, counted=249188). + Fix? no + Free inodes count wrong (65526, counted=65523). + Fix? no + + scsi-disk2.img: ***** FILE SYSTEM WAS MODIFIED ***** + + scsi-disk2.img: ********** WARNING: Filesystem still has errors ********** + + scsi-disk2.img: 10/65536 files (0.0% non-contiguous), 12955/262144 blocks + + Above issue can reproduce as follows: + step1: socat UNIX-LISTEN:/home/test/mysocket.sock,mode=777,reuseaddr,fork EXEC:/home/test & + step2: setfacl some xattr for mysocket.sock + step3: cp -a /home/test/mysocket.sock /home/test/sock1 + cp -a /home/test/mysocket.sock /home/test/sock2 + step4: sync + step5: Power-off + step6: run e2fsck + + As after commit 42475e281d22 add ext2fs_inode_has_valid_blocks() judgement in + release_inode_blocks() which means socket type file skip realse block include + ACL block. The kernel does not restrict the setting of extended attributes for + socket files. So this will lead to ACL block leak. + To solve above issue there's need to release ACL block for other kind of + special file. + + Fixes: 42475e281d22 ("super.c (release_inode_blocks): Don't try to release the blocks if the orphaned inode is a device file, symlink, or some other kind of special file that doesn't have a block list.") + Signed-off-by: Ye Bin + Reviewed-by: Jan Kara + Link: https://lore.kernel.org/r/20240418063946.2802835-1-yebin10@huawei.com + Signed-off-by: Theodore Ts'o +--- + e2fsck/super.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/e2fsck/super.c b/e2fsck/super.c +index d654c5d..8512d3c 100644 +--- a/e2fsck/super.c ++++ b/e2fsck/super.c +@@ -196,7 +196,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, + __u32 count; + + if (!ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(inode))) +- return 0; ++ goto release_acl; + + pb.buf = block_buf + 3 * ctx->fs->blocksize; + pb.ctx = ctx; +@@ -240,6 +240,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, + if (inode->i_links_count) + return 0; + ++release_acl: + blk = ext2fs_file_acl_block(fs, EXT2_INODE(inode)); + if (blk) { + retval = ext2fs_adjust_ea_refcount3(fs, blk, block_buf, -1, +-- +2.33.0 \ No newline at end of file diff --git a/0020-e2fsck-fix-handling-of-a-invalid-symlink-in-an-inlin.patch b/0020-e2fsck-fix-handling-of-a-invalid-symlink-in-an-inlin.patch new file mode 100644 index 0000000..3caa58c --- /dev/null +++ b/0020-e2fsck-fix-handling-of-a-invalid-symlink-in-an-inlin.patch @@ -0,0 +1,46 @@ +From 8798bbb81687103b0c0f56a42b096884c6032101 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Wed, 14 Jun 2023 14:44:19 -0400 +Subject: [PATCH] e2fsck: fix handling of a invalid symlink in an inline_data + directory + +If there is an inline directory that contains a directory entry to an +invalid symlink, and that invalid symlink is the portion of the inline +directory stored in an xattr portion of the inode, this can result in +a buffer overrun. + +When check_dir_block() is handling the in-xattr portion of the inline +directory, it sets the buf pointer to the beginning of that part of +the inline directory. This results in the scratch buffer passed to +e2fsck_process_bad_inode() to incorrect, resulting in a buffer overrun +if e2fsck_pass1_check_symlink() needs to read the symlink target (when +the symlink is too long to fit in the i_blocks[] space). + +This commit fixes this by using the original cd->buf instead of buf, +since it can get modified when handling inline directories. + +Conflict: NA +Reference: https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit?id=8798bbb81687103b0c0f56a42b096884c6032101 + +Fixes: 0ac4b3973f31 ("e2fsck: inspect inline dir data as two directory blocks") +Signed-off-by: Theodore Ts'o +--- + e2fsck/pass2.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c +index 47f9206f..42f3e5ef 100644 +--- a/e2fsck/pass2.c ++++ b/e2fsck/pass2.c +@@ -1523,7 +1523,7 @@ skip_checksum: + dirent->inode)) { + if (e2fsck_process_bad_inode(ctx, ino, + dirent->inode, +- buf + fs->blocksize)) { ++ cd->buf + fs->blocksize)) { + dirent->inode = 0; + dir_modified++; + goto next; +-- +2.32.0 + \ No newline at end of file diff --git a/0021-e2fsprogs-modify-dumpe2fs-to-report-free-block-range.patch b/0021-e2fsprogs-modify-dumpe2fs-to-report-free-block-range.patch new file mode 100644 index 0000000..0106002 --- /dev/null +++ b/0021-e2fsprogs-modify-dumpe2fs-to-report-free-block-range.patch @@ -0,0 +1,71 @@ +From b31d5b582b4189a0ed27bced22276dd3f68c50a7 Mon Sep 17 00:00:00 2001 +From: Eric Whitney +Date: Fri, 21 Jul 2023 14:55:06 -0400 +Subject: [PATCH] e2fsprogs: modify dumpe2fs to report free block ranges for + bigalloc + +dumpe2fs has never been modified to correctly report block ranges +corresponding to free clusters in block allocation bitmaps from bigalloc +file systems. Rather than reporting block ranges covering all the +blocks in free clusters found in a block bitmap, it either reports just +the first block number in a cluster for a single free cluster, or a +range beginning with the first block number in the first cluster in a +series of free clusters, and ending with the first block number in the +last cluster in that series. + +This behavior causes xfstest shared/298 to fail when run on a bigalloc +file system with a 1k block size. The test uses dumpe2fs to collect +a list of the blocks freed when files are deleted from a file system. +When the test deletes a file containing blocks located after the first +block in the last cluster in a series of clusters, dumpe2fs does not +report those blocks as free per the test's expectations. + +Modify dumpe2fs to report full block ranges for free clusters. At the +same time, fix a small bug causing unnecessary !in_use() retests while +iterating over a block bitmap. + +Conflict: NA +Reference: https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit?id=b31d5b582b4189a0ed27bced22276dd3f68c50a7 + +Signed-off-by: Eric Whitney +Link: https://lore.kernel.org/r/20230721185506.1020225-1-enwlinux@gmail.com +Signed-off-by: Theodore Ts'o +--- + misc/dumpe2fs.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c +index 7c080ed9..d2d57fb0 100644 +--- a/misc/dumpe2fs.c ++++ b/misc/dumpe2fs.c +@@ -84,8 +84,7 @@ static void print_free(unsigned long group, char * bitmap, + unsigned long num, unsigned long offset, int ratio) + { + int p = 0; +- unsigned long i; +- unsigned long j; ++ unsigned long i, j; + + offset /= ratio; + offset += group * num; +@@ -95,13 +94,14 @@ static void print_free(unsigned long group, char * bitmap, + if (p) + printf (", "); + print_number((i + offset) * ratio); +- for (j = i; j < num && !in_use (bitmap, j); j++) ++ for (j = i + 1; j < num && !in_use(bitmap, j); j++) + ; +- if (--j != i) { ++ if (j != i + 1 || ratio > 1) { + fputc('-', stdout); +- print_number((j + offset) * ratio); +- i = j; ++ print_number(((j - 1 + offset) * ratio) + ++ ratio - 1); + } ++ i = j; + p = 1; + } + } +-- +2.32.0 \ No newline at end of file diff --git a/0022-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch b/0022-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch new file mode 100644 index 0000000..fb4018f --- /dev/null +++ b/0022-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch @@ -0,0 +1,37 @@ +From 43a498e938887956f393b5e45ea6ac79cc5f4b84 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Thu, 15 Jun 2023 00:17:01 -0400 +Subject: [PATCH] resize2fs: use Direct I/O when reading the superblock for + online resizes + +If the file system is mounted, the superblock can be changing while +resize2fs is trying to read the superblock, resulting in checksum +failures. One way of avoiding this problem is read the superblock +using Direct I/O, since the kernel makes sure that what gets written +to disk is self-consistent. + +Conflict:context conflict because upstream change ca340221b is not +applied +Reference: https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit?id=43a498e938887956f393b5e45ea6ac79cc5f4b84 + +Suggested-by: Krister Johansen +Signed-off-by: Theodore Ts'o +--- + resize/main.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/resize/main.c b/resize/main.c +index 94f5ec6d6..f914c0507 100644 +--- a/resize/main.c ++++ b/resize/main.c +@@ -409,6 +409,8 @@ int main (int argc, char ** argv) + + if (!(mount_flags & EXT2_MF_MOUNTED) && !print_min_size) + io_flags = EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE; ++ if (mount_flags & EXT2_MF_MOUNTED) ++ io_flags |= EXT2_FLAG_DIRECT_IO; + + io_flags |= EXT2_FLAG_64BITS | EXT2_FLAG_THREADS; + if (undo_file) { +-- +2.32.0 \ No newline at end of file diff --git a/e2fsprogs.spec b/e2fsprogs.spec index 48ab6c7..9c1b434 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -1,6 +1,6 @@ Name: e2fsprogs Version: 1.47.0 -Release: 9 +Release: 10 Summary: Second extended file system management tools License: GPLv2+ and LGPLv2 and MIT URL: http://e2fsprogs.sourceforge.net/ @@ -24,6 +24,11 @@ Patch14: 0014-e2fsck-update-quota-accounting-after-directory-optim.patch Patch15: 0015-e2fsck-update-quota-when-deallocating-a-bad-inode.patch Patch16: 0016-fsck-fix-memory-leak-on-an-error-exit.patch Patch17: 0017-mke2fs-batch-zeroing-inode-table.patch +Patch18: 0018-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch +Patch19: 0019-e2fsck-fix-acl-block-leak-when-process-orphan-list.patch +Patch20: 0020-e2fsck-fix-handling-of-a-invalid-symlink-in-an-inlin.patch +Patch21: 0021-e2fsprogs-modify-dumpe2fs-to-report-free-block-range.patch +Patch22: 0022-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch BuildRequires: gcc pkgconfig texinfo BuildRequires: fuse-devel libblkid-devel libuuid-devel @@ -164,6 +169,9 @@ exit 0 %{_mandir}/man8/* %changelog +* Wed Aug 20 2025 zhangjian - 1.47.0-10 +- sync patches from 2403-sp2 + * Tue Jul 01 2025 wangxiao - 1.47.0-9 - delete macros in changelog -- Gitee