[packages/e2fsprogs] Rel 3. Backport orphan file, tune2fs and debugfs rdump fixes

arekm arekm at pld-linux.org
Thu Oct 29 08:31:43 CET 2026


commit 93d83f14ca8efcf7e4ec4e489599d785019c8000
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Oct 29 00:19:20 2026 +0100

    Rel 3. Backport orphan file, tune2fs and debugfs rdump fixes

 e2fsprogs-debugfs-rdump-traversal.patch      |  69 +++++++++++++
 e2fsprogs-orphan-file-size.patch             | 144 +++++++++++++++++++++++++++
 e2fsprogs-tune2fs-ea-inode-overrun.patch     |  98 ++++++++++++++++++
 e2fsprogs-tune2fs-inline-xattr-overrun.patch |  45 +++++++++
 e2fsprogs.spec                               |  16 ++-
 5 files changed, 369 insertions(+), 3 deletions(-)
---
diff --git a/e2fsprogs.spec b/e2fsprogs.spec
index 4579585..e6111af 100644
--- a/e2fsprogs.spec
+++ b/e2fsprogs.spec
@@ -47,7 +47,7 @@ Summary(zh_CN.UTF-8):	管理第二扩展(ext2)文件系统的工具。
 Summary(zh_TW.UTF-8):	用於管理 ext2 檔案系統的工具程式。
 Name:		e2fsprogs
 Version:	1.47.4
-Release:	2
+Release:	3
 License:	GPL v2 (with LGPL v2 and BSD parts)
 Group:		Applications/System
 Source0:	https://downloads.sourceforge.net/e2fsprogs/%{name}-%{version}.tar.gz
@@ -57,13 +57,19 @@ Source2:	http://www.mif.pg.gda.pl/homepages/ankry/man-PLD/%{name}-non-english-ma
 Patch0:		%{name}-info.patch
 Patch1:		%{name}-498381.patch
 Patch2:		%{name}-diet.patch
+Patch3:		%{name}-orphan-file-size.patch
+Patch4:		%{name}-tune2fs-ea-inode-overrun.patch
+Patch5:		%{name}-tune2fs-inline-xattr-overrun.patch
+Patch6:		%{name}-debugfs-rdump-traversal.patch
 URL:		https://e2fsprogs.sourceforge.net/
 BuildRequires:	autoconf >= 2.72
 BuildRequires:	autoconf-archive
 BuildRequires:	automake
 BuildRequires:	gettext-tools >= 0.11
+BuildRequires:	libarchive-devel
 BuildRequires:	libblkid-devel
-%{?with_fuse:BuildRequires:	libfuse-devel}
+%{?with_fuse:BuildRequires:	libfuse3-devel}
+BuildRequires:	libmagic-devel
 BuildRequires:	libuuid-devel
 BuildRequires:	pkgconfig
 BuildRequires:	rpm >= 4.4.9-56
@@ -331,7 +337,7 @@ Summary:	FUSE file system client for ext2/ext3/ext4 file systems
 Summary(pl.UTF-8):	Klient systemu plików FUSE dla systemów plików ext2/ext3/ext4
 Group:		Applications/System
 Requires:	%{name}-libs%{?_isa} = %{version}-%{release}
-Requires:	libfuse-tools
+Requires:	libfuse3-tools
 Requires:	libcom_err%{?_isa} = %{version}-%{release}
 
 %description fuse
@@ -635,6 +641,10 @@ na potrzeby initrd.
 %patch -P0 -p1
 %patch -P1 -p1
 %patch -P2 -p1
+%patch -P3 -p1
+%patch -P4 -p1
+%patch -P5 -p1
+%patch -P6 -p1
 
 grep -q AM_GNU_GETTEXT configure.ac && ! grep -q AM_GNU_GETTEXT acinclude.m4 || exit 1
 %if %{_ver_ge %{gettext_ver} 0.24.1}
diff --git a/e2fsprogs-debugfs-rdump-traversal.patch b/e2fsprogs-debugfs-rdump-traversal.patch
new file mode 100644
index 0000000..ac5226c
--- /dev/null
+++ b/e2fsprogs-debugfs-rdump-traversal.patch
@@ -0,0 +1,69 @@
+From f426552233e8831a358ca1f9ed90411a2bcbc9c9 Mon Sep 17 00:00:00 2001
+From: Nexory <St4yl3r30 at hotmail.de>
+Date: Fri, 7 Aug 2026 12:03:03 +0200
+Subject: [PATCH] debugfs: reject path-traversal names in rdump
+
+rdump_dirent() copies the raw on-disk directory entry name and passes it to
+rdump_inode(), which sprintf()s it into the destination path and open()s /
+symlink()s the result. An entry named "../foo" (or one containing '/') in a
+crafted or corrupted image therefore escapes the destination directory when
+"rdump" extracts a tree from an untrusted filesystem image.
+
+Reject such names in rdump_dirent() before use. Valid ext2/3/4 filesystems
+never contain them, so there is no change for legitimate images; e2fsck
+already treats '/' in a name as corruption (PR_2_BAD_NAME).
+
+Fixes: https://github.com/tytso/e2fsprogs/issues/272
+Signed-off-by: Nexory <St4yl3r30 at hotmail.de>
+Message-ID: <OS6P279MB11807BB1AB25D78C31814B39CBD12 at OS6P279MB1180.NORP279.PROD.OUTLOOK.COM>
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+---
+ debugfs/dump.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/debugfs/dump.c b/debugfs/dump.c
+index cc81a5086..e959cd012 100644
+--- a/debugfs/dump.c
++++ b/debugfs/dump.c
+@@ -317,6 +317,16 @@ static int rdump_dirent(struct ext2_dir_entry *dirent,
+ 	strncpy(name, dirent->name, thislen);
+ 	name[thislen] = 0;
+ 
++	/* Path-traversal guard: reject entry names that would escape the
++	 * destination directory. A valid ext2/3/4 filesystem never contains
++	 * a name with '/' or an empty name; e2fsck treats such names as
++	 * corruption (PR_2_BAD_NAME). */
++	if (name[0] == 0 || strchr(name, '/')) {
++		com_err("rdump", 0, "skipping entry with unsafe name (inode %u)",
++			dirent->inode);
++		return 0;
++	}
++
+ 	if (debugfs_read_inode(dirent->inode, &inode, name))
+ 		return 0;
+ 
+From f972b0ff42955e667475ab4e80233de96aac3672 Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso at mit.edu>
+Date: Sat, 5 Sep 2026 17:23:39 -0400
+Subject: [PATCH] debugfs: make rdump fail if the destination pathname points
+ at a symlink
+
+Fixes: https://github.com/tytso/e2fsprogs/issues/273
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+---
+ debugfs/dump.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/debugfs/dump.c b/debugfs/dump.c
+index e959cd012..f3e865afe 100644
+--- a/debugfs/dump.c
++++ b/debugfs/dump.c
+@@ -351,7 +351,7 @@ void do_rdump(int argc, ss_argv_t argv, int sci_idx EXT2FS_ATTR((unused)),
+ 	argc--;
+ 
+ 	/* Ensure last arg is a directory. */
+-	if (stat(dest_dir, &st) == -1) {
++	if (lstat(dest_dir, &st) == -1) {
+ 		com_err("rdump", errno, "while statting %s", dest_dir);
+ 		return;
+ 	}
diff --git a/e2fsprogs-orphan-file-size.patch b/e2fsprogs-orphan-file-size.patch
new file mode 100644
index 0000000..d212e6c
--- /dev/null
+++ b/e2fsprogs-orphan-file-size.patch
@@ -0,0 +1,144 @@
+From 782f43e32b58b37277f0ec6af405d5c45245b8c1 Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso at mit.edu>
+Date: Thu, 12 Mar 2026 15:35:05 -0400
+Subject: [PATCH] Revert "libext2fs: fix orphan file size > kernel limit with
+ large blocksize"
+
+This reverts commit 6f03c698ef53bb9d0cd42c9bd0b68e8ce72f8345.
+
+    Due to missing parenthesis around the #defines for
+    EXT4_{MAX,DEFAULT}_ORPHAN_FILE_SIZE, the default number of blocks
+    assigned to the orphan file was calculated as 2 when the file system
+    has more than 2**21 blocks:
+
+       % mke2fs  -t ext4 -Fq /tmp/foo.img 8191M
+       /tmp/foo.img contains a ext4 file system
+               created on Wed Mar 11 09:54:04 2026
+       % debugfs -R "extents <12>" /tmp/foo.img
+       debugfs 1.47.4 (6-Mar-2025)
+       Level Entries       Logical          Physical Length Flags
+        0/ 0   1/  1     0 -   510    9255 -    9765    511
+
+       % mke2fs  -t ext4 -Fq /tmp/foo.img 8192M
+       /tmp/foo.img contains a ext4 file system
+               created on Wed Mar 11 09:54:11 2026
+       % debugfs -R "extents <12>" /tmp/foo.img
+       debugfs 1.47.4 (6-Mar-2025)
+       Level Entries       Logical          Physical Length Flags
+        0/ 0   1/  1     0 -     1    9255 -    9256      2  <======
+
+The problem addressed by the reverted commit will fixed via the next
+commit.
+
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+---
+ lib/ext2fs/ext2fs.h |  2 --
+ lib/ext2fs/orphan.c | 12 +++++-------
+ 2 files changed, 5 insertions(+), 9 deletions(-)
+
+diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
+index d9df007c4..bb2170b78 100644
+--- a/lib/ext2fs/ext2fs.h
++++ b/lib/ext2fs/ext2fs.h
+@@ -1819,8 +1819,6 @@ errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io);
+ errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io);
+ 
+ /* orphan.c */
+-#define EXT4_MAX_ORPHAN_FILE_SIZE	8 << 20
+-#define EXT4_DEFAULT_ORPHAN_FILE_SIZE	2 << 20
+ extern errcode_t ext2fs_create_orphan_file(ext2_filsys fs, blk_t num_blocks);
+ extern errcode_t ext2fs_truncate_orphan_file(ext2_filsys fs);
+ extern e2_blkcnt_t ext2fs_default_orphan_file_blocks(ext2_filsys fs);
+diff --git a/lib/ext2fs/orphan.c b/lib/ext2fs/orphan.c
+index 40b1c5c72..14ac35694 100644
+--- a/lib/ext2fs/orphan.c
++++ b/lib/ext2fs/orphan.c
+@@ -164,8 +164,6 @@ errcode_t ext2fs_create_orphan_file(ext2_filsys fs, blk_t num_blocks)
+ 	memset(zerobuf, 0, fs->blocksize);
+ 	ob_tail = ext2fs_orphan_block_tail(fs, buf);
+ 	ob_tail->ob_magic = ext2fs_cpu_to_le32(EXT4_ORPHAN_BLOCK_MAGIC);
+-	if (num_blocks * fs->blocksize > EXT4_MAX_ORPHAN_FILE_SIZE)
+-		num_blocks = EXT4_MAX_ORPHAN_FILE_SIZE / fs->blocksize;
+ 	oi.num_blocks = num_blocks;
+ 	oi.alloc_blocks = 0;
+ 	oi.last_blk = 0;
+@@ -218,18 +216,18 @@ errcode_t ext2fs_create_orphan_file(ext2_filsys fs, blk_t num_blocks)
+ 
+ /*
+  * Find reasonable size for orphan file. We choose orphan file size to be
+- * between 32 filesystem blocks and EXT4_DEFAULT_ORPHAN_FILE_SIZE, and not
+- * more than 1/fs->blocksize of the filesystem unless it is really small.
++ * between 32 and 512 filesystem blocks and not more than 1/4096 of the
++ * filesystem unless it is really small.
+  */
+ e2_blkcnt_t ext2fs_default_orphan_file_blocks(ext2_filsys fs)
+ {
+ 	__u64 num_blocks = ext2fs_blocks_count(fs->super);
+-	e2_blkcnt_t blks = EXT4_DEFAULT_ORPHAN_FILE_SIZE / fs->blocksize;
++	e2_blkcnt_t blks = 512;
+ 
+ 	if (num_blocks < 128 * 1024)
+ 		blks = 32;
+-	else if (num_blocks < EXT4_DEFAULT_ORPHAN_FILE_SIZE)
+-		blks = num_blocks / fs->blocksize;
++	else if (num_blocks < 2 * 1024 * 1024)
++		blks = num_blocks / 4096;
+ 	return (blks + EXT2FS_CLUSTER_MASK(fs)) & ~EXT2FS_CLUSTER_MASK(fs);
+ }
+ 
+From a9f482e55f3ca384226e76fceb15f274698cce93 Mon Sep 17 00:00:00 2001
+From: Baokun Li <libaokun1 at huawei.com>
+Date: Thu, 20 Nov 2025 21:55:14 +0800
+Subject: [PATCH] libext2fs: fix orphan file size > kernel limit with large
+ blocksize
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Kernel commit 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
+limits the maximum supported orphan file size to 8 << 20.
+
+However, in e2fsprogs, the orphan file size is set to 32–512 filesystem
+blocks when creating a filesystem.
+
+With 64k block size, formatting an ext4 fs >32G gives an orphan file bigger
+than the kernel allows, so mount prints an error and fails:
+
+    EXT4-fs (vdb): orphan file too big: 8650752
+    EXT4-fs (vdb): mount failed
+
+Thus, orphan file size is capped at 512 filesystem blocks in both e2fsprogs
+and the kernel.
+
+Signed-off-by: Baokun Li <libaokun1 at huawei.com>
+Reviewed-by: Jan Kara <jack at suse.cz>
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+Message-ID: <20251120135514.3013973-1-libaokun at huaweicloud.com>
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+---
+ lib/ext2fs/orphan.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/ext2fs/orphan.c b/lib/ext2fs/orphan.c
+index 14ac35694..0f1889cbc 100644
+--- a/lib/ext2fs/orphan.c
++++ b/lib/ext2fs/orphan.c
+@@ -15,6 +15,8 @@
+ #include "ext2_fs.h"
+ #include "ext2fsP.h"
+ 
++#define EXT4_MAX_ORPHAN_FILE_BLOCKS 512
++
+ errcode_t ext2fs_truncate_orphan_file(ext2_filsys fs)
+ {
+ 	struct ext2_inode inode;
+@@ -129,6 +131,9 @@ errcode_t ext2fs_create_orphan_file(ext2_filsys fs, blk_t num_blocks)
+ 	struct ext4_orphan_block_tail *ob_tail;
+ 	time_t now;
+ 
++	if (num_blocks > EXT4_MAX_ORPHAN_FILE_BLOCKS)
++		num_blocks = EXT4_MAX_ORPHAN_FILE_BLOCKS;
++
+ 	if (ino) {
+ 		err = ext2fs_read_inode(fs, ino, &inode);
+ 		if (err)
diff --git a/e2fsprogs-tune2fs-ea-inode-overrun.patch b/e2fsprogs-tune2fs-ea-inode-overrun.patch
new file mode 100644
index 0000000..0310e7e
--- /dev/null
+++ b/e2fsprogs-tune2fs-ea-inode-overrun.patch
@@ -0,0 +1,98 @@
+From 70f15ba5df0fd033e2c01b822282c52b494ff732 Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso at mit.edu>
+Date: Thu, 3 Sep 2026 11:19:43 -0400
+Subject: [PATCH] tune2fs: avoid a buffer overrun when rewriting an overly
+ large EA inode
+
+If a maliciously crafted file system contains an EA inode which is
+larger than the maximum allowed extended attribute size, the contents
+of the inode will be overflow an allocated buffer.  Fix this by
+bailing out if the EA inode is too large.  This should have been fixed by
+the required e2fsck -f before running tune2fs -U random, but if
+the file system is crafted to make it appear that the file system
+ check has already been done, this requirement can be overriden.
+
+Also fix e2fsck to enforce the 64k extended attribute limit.
+
+Some security "experts" will claim that this is a serious security
+issue, but it requires tricking a system administrator to run "tune2fs
+-U random downloaded.img" on an file system image that was downloaded
+from the attackers web site.  This is considered a "one-click RCE",
+but if running an obscure tune2fs commmand as root is considered
+"one-click", the CVSS rules are *insane**.
+
+Please consider this before running around with your hair on fire when
+seeing a scary CVSS score.  It may not at **all** be resonable and
+reflective of real-world security considerations.
+
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+---
+ e2fsck/pass1.c             |  3 +++
+ lib/ext2fs/ext2_ext_attr.h | 10 ++--------
+ misc/tune2fs.c             |  5 ++++-
+ 3 files changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
+index fdde76cc2..c97114465 100644
+--- a/e2fsck/pass1.c
++++ b/e2fsck/pass1.c
+@@ -340,11 +340,14 @@ static problem_t check_large_ea_inode(e2fsck_t ctx,
+ 		pctx->num = entry->e_value_inum;
+ 		return PR_1_ATTR_VALUE_EA_INODE;
+ 	}
++	if (entry->e_value_size > EXT2_XATTR_SIZE_MAX)
++		goto bad_ea_size;
+ 
+ 	e2fsck_read_inode(ctx, entry->e_value_inum, &inode, "pass1");
+ 
+ 	if (entry->e_value_size == 0 ||
+ 	    entry->e_value_size != EXT2_I_SIZE(&inode)) {
++	bad_ea_size:
+ 		pctx->num = entry->e_value_size;
+ 		return PR_1_ATTR_VALUE_SIZE;
+ 	}
+diff --git a/lib/ext2fs/ext2_ext_attr.h b/lib/ext2fs/ext2_ext_attr.h
+index c6068c482..1a6a5e20a 100644
+--- a/lib/ext2fs/ext2_ext_attr.h
++++ b/lib/ext2fs/ext2_ext_attr.h
+@@ -58,15 +58,9 @@ struct ext2_ext_attr_entry {
+ 	(((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
+ 
+ /*
+- * XATTR_SIZE_MAX is currently 64k, but for the purposes of checking
+- * for file system consistency errors, we use a somewhat bigger value.
+- * This allows XATTR_SIZE_MAX to grow in the future, but by using this
+- * instead of INT_MAX for certain consistency checks, we don't need to
+- * worry about arithmetic overflows.  (Actually XATTR_SIZE_MAX is
+- * defined in include/uapi/linux/limits.h, so changing it is going
+- * not going to be trivial....)
++ * XATTR_SIZE_MAX as defined in include/uapi/linux/limits.h is 64k
+  */
+-#define EXT2_XATTR_SIZE_MAX (1 << 24)
++#define EXT2_XATTR_SIZE_MAX (64 * 1024)
+ 
+ #ifdef __KERNEL__
+ # ifdef CONFIG_EXT2_FS_EXT_ATTR
+diff --git a/misc/tune2fs.c b/misc/tune2fs.c
+index 3db57632c..e6df37635 100644
+--- a/misc/tune2fs.c
++++ b/misc/tune2fs.c
+@@ -751,6 +751,9 @@ static void update_ea_inode_hash(struct rewrite_context *ctx, ext2_ino_t ino,
+ 	ext2_file_t file;
+ 	__u32 hash;
+ 
++	if (EXT2_I_SIZE(inode) > EXT2_XATTR_SIZE_MAX)
++		fatal_err(0, "ea_inode %u has an invalid size %llu", ino,
++			  EXT2_I_SIZE(inode));
+ 	retval = ext2fs_file_open(ctx->fs, ino, 0, &file);
+ 	if (retval)
+ 		fatal_err(retval, "open ea_inode");
+@@ -943,7 +946,7 @@ static void rewrite_inodes(ext2_filsys fs, unsigned int flags)
+ 	if (retval)
+ 		fatal_err(retval, "while allocating memory");
+ 
+-	retval = ext2fs_get_mem(64 * 1024, &ctx.ea_buf);
++	retval = ext2fs_get_mem(EXT2_XATTR_SIZE_MAX, &ctx.ea_buf);
+ 	if (retval)
+ 		fatal_err(retval, "while allocating memory");
+ 
diff --git a/e2fsprogs-tune2fs-inline-xattr-overrun.patch b/e2fsprogs-tune2fs-inline-xattr-overrun.patch
new file mode 100644
index 0000000..88f40e9
--- /dev/null
+++ b/e2fsprogs-tune2fs-inline-xattr-overrun.patch
@@ -0,0 +1,45 @@
+From cda3b67031da437beb327a784994ad65e51c2a96 Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso at mit.edu>
+Date: Thu, 3 Sep 2026 12:20:53 -0400
+Subject: [PATCH] tune2fs: avoid a 4-byte heap buffer overrun when rewriting an
+ inline xattr
+
+If a maliciously crafted file system contains an inline extended
+attribute which extends beyond the inode, when rewriting an extended
+attribute while enabling metadata checksums, this can result in a
+4-byte write beyond the end of an allocated buffer.  Fix this by
+checking for this invalid file system.  This should have been fixed by
+the required e2fsck -f before running tune2fs -O metadata_csum, but if
+the file system is crafted to make it appear that the file system
+check has already been done, this requirement can be overriden.
+
+Some security "experts" will claim that this is a serious security
+issue, but it requires tricking a system administrator to run "tune2fs
+-O metadata_csum downloadeded.img" on an file system image that was
+downloaded from the attackers web site.  This is considered a
+"one-click RCE", but if running an obscure tune2fs commmand as root is
+considered "one-click", the CVSS rules are *insane**.
+
+Please consider this before running around with your hair on fire when
+seeing a scary CVSS score.  It may not at **all** be resonable and
+reflective of real-world security considerations.
+
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+---
+ misc/tune2fs.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/misc/tune2fs.c b/misc/tune2fs.c
+index e6df37635..68bc05684 100644
+--- a/misc/tune2fs.c
++++ b/misc/tune2fs.c
+@@ -778,6 +778,9 @@ static int update_xattr_entry_hashes(ext2_filsys fs,
+ 	errcode_t retval;
+ 
+ 	while (entry < end && !EXT2_EXT_IS_LAST_ENTRY(entry)) {
++		if ((char *) entry + sizeof(struct ext2_ext_attr_entry) >=
++		    (char *) end)
++			fatal_err(0, "corrupted extended attribute field");
+ 		if (entry->e_value_inum) {
+ 			retval = ext2fs_ext_attr_hash_entry2(fs, entry, NULL,
+ 							     &entry->e_hash);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/e2fsprogs.git/commitdiff/93d83f14ca8efcf7e4ec4e489599d785019c8000



More information about the pld-cvs-commit mailing list