Vitaly - 2024-08-28

The root cause is ext4magic was not updated after update of the e2fsprogs. Two new fields are added into ext2_extent_handle and extent_path structures (e2fsprogs commits a14f0a647 and 2d30ab20a). As a result structure memory layout is changed and ext4magic overwrites structure fields incorrectly. It is correctly reported by valgrind.

Possible quickfix is applying the following patch:

diff -r -u a/src/block.c b/src/block.c
--- a/src/block.c   2014-03-12 04:54:03.000000000 +0400
+++ b/src/block.c   2024-04-10 09:10:06.436387279 +0300
@@ -64,6 +64,7 @@
         int             visit_num;
         int             flags;
         blk64_t         end_blk;
+        blk64_t         blk;
         void            *curr;
 };

@@ -79,6 +80,7 @@
         int                     type;
         int                     level;
         int                     max_depth;
+        int                     max_paths;
         struct extent_path      *path;
 };

@@ -180,6 +182,7 @@
                 ((((__u64) handle->inode->i_size_high << 32) +
                   handle->inode->i_size + (fs->blocksize - 1))
                  >> EXT2_BLOCK_SIZE_BITS(fs->super));
+        handle->path[0].blk = 0;
         handle->path[0].visit_num = 1;
         handle->level = 0;
         handle->magic = EXT2_ET_MAGIC_EXTENT_HANDLE;

It seems to work because:
- blk field is used only by internal e2fsprogs logic;
- while max_path field logic is updated it is still compatible with old logic (basically max_path value is equal to the max_depth + 1).

Proper fix without changing the code is to link the ext4magic to the e2fsprogs v1.42.13 (the last one before commit a14f0a647).

Originally posted this in Arch Linux packaging repo