diff -Nru e2fsprogs-1.46.3/debian/changelog e2fsprogs-1.46.3/debian/changelog --- e2fsprogs-1.46.3/debian/changelog 2021-08-10 10:07:26.000000000 +0200 +++ e2fsprogs-1.46.3/debian/changelog 2021-08-11 19:04:33.000000000 +0200 @@ -1,3 +1,13 @@ +e2fsprogs (1.46.3-1ubuntu2) impish; urgency=medium + + * Fix failing tests on bigendian system (LP: #1939409) + using upstream patches queued for 1.46.4: + + - e2fsck: fix f_baddotdir failure on big-endian systems + - libext2fs: fix translation of Posix ACL's on big-endian systems + + -- Heinrich Schuchardt Wed, 11 Aug 2021 19:04:33 +0200 + e2fsprogs (1.46.3-1ubuntu1) impish; urgency=medium * Merge from Debian experimental. Remaining changes: diff -Nru e2fsprogs-1.46.3/debian/patches/0001-e2fsck-fix-f_baddotdir-failure-on-big-endian-systems.patch e2fsprogs-1.46.3/debian/patches/0001-e2fsck-fix-f_baddotdir-failure-on-big-endian-systems.patch --- e2fsprogs-1.46.3/debian/patches/0001-e2fsck-fix-f_baddotdir-failure-on-big-endian-systems.patch 1970-01-01 01:00:00.000000000 +0100 +++ e2fsprogs-1.46.3/debian/patches/0001-e2fsck-fix-f_baddotdir-failure-on-big-endian-systems.patch 2021-08-11 19:00:41.000000000 +0200 @@ -0,0 +1,63 @@ +From 225e5d093b519f9dbe9fcaacd995426f0e5194f6 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Wed, 28 Jul 2021 13:51:13 -0400 +Subject: [PATCH] e2fsck: fix f_baddotdir failure on big-endian systems + +Commit 63f44aafb1f2 ("e2fsck: fix ".." more gracefully if possible") +changed the check_dot() function to try to avoid resetting the '..' +entry when the '.' entry is too large.. But if we do that, then on +big-endian systems, we need to try byte swapping the rest of the +directory entries, or else the f_baddotdir test will fail on +big-endian systems. + +Also add a check to avoid UBSAN warning when there is not enough space +at the end of the directory block for a directory entry, and so we can +potentially overflow some pointer arithmetic when trying to byte swap +the remainder of the (negative) space in the directory block. + +Fixes: 63f44aafb1f2 ("e2fsck: fix ".." more gracefully if possible") +Signed-off-by: Theodore Ts'o +--- + e2fsck/pass2.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c +index f00cb40e..bd974c55 100644 +--- a/e2fsck/pass2.c ++++ b/e2fsck/pass2.c +@@ -458,6 +458,12 @@ static int check_dot(e2fsck_t ctx, + ext2fs_dirent_set_name_len(nextdir, 0); + ext2fs_dirent_set_file_type(nextdir, + ftype); ++#ifdef WORDS_BIGENDIAN ++ } else { ++ (void) ext2fs_dirent_swab_in2(ctx->fs, ++ (char *) nextdir, ++ ctx->fs->blocksize - 12, 0); ++#endif + } + status = 1; + } +@@ -1370,12 +1376,14 @@ skip_checksum: + hash_in_dirent); + #ifdef WORDS_BIGENDIAN + if (need_reswab) { ++ unsigned int len; ++ + (void) ext2fs_get_rec_len(fs, +- dirent, &rec_len); +- ext2fs_dirent_swab_in2(fs, +- ((char *)dirent) + offset + rec_len, +- max_block_size - offset - rec_len, +- 0); ++ dirent, &len); ++ len += offset; ++ if (max_block_size > len) ++ ext2fs_dirent_swab_in2(fs, ++ ((char *)dirent) + len, max_block_size - len, 0); + } + #endif + dir_modified++; +-- +2.20.1 + diff -Nru e2fsprogs-1.46.3/debian/patches/0001-libext2fs-fix-translation-of-Posix-ACL-s-on-big-endi.patch e2fsprogs-1.46.3/debian/patches/0001-libext2fs-fix-translation-of-Posix-ACL-s-on-big-endi.patch --- e2fsprogs-1.46.3/debian/patches/0001-libext2fs-fix-translation-of-Posix-ACL-s-on-big-endi.patch 1970-01-01 01:00:00.000000000 +0100 +++ e2fsprogs-1.46.3/debian/patches/0001-libext2fs-fix-translation-of-Posix-ACL-s-on-big-endi.patch 2021-08-11 19:03:54.000000000 +0200 @@ -0,0 +1,70 @@ +From 7a97083d4350b93f4055bdd8465667cecbb36438 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Fri, 30 Jul 2021 12:29:44 -0400 +Subject: [PATCH] libext2fs: fix translation of Posix ACL's on big-endian + systems + +The ACL returned by the kernel in lgetxattr(2) is returned in Little +Endian, even on Big Endian systems. Fix the functions +convert_posix_acl_to_disk_buffer() and convert_disk_buffer_to_posix_acl() +to work correctly on Big Endian systems. This fixes a failure of +the test m_rootdir_acl. + +Signed-off-by: Theodore Ts'o +--- + lib/ext2fs/ext_attr.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c +index 148fae5b..4f6371de 100644 +--- a/lib/ext2fs/ext_attr.c ++++ b/lib/ext2fs/ext_attr.c +@@ -556,10 +556,10 @@ static errcode_t convert_posix_acl_to_disk_buffer(const void *value, size_t size + s = sizeof(ext4_acl_header); + for (end = entry + count; entry != end;entry++) { + ext4_acl_entry *disk_entry = (ext4_acl_entry*) e; +- disk_entry->e_tag = ext2fs_cpu_to_le16(entry->e_tag); +- disk_entry->e_perm = ext2fs_cpu_to_le16(entry->e_perm); ++ disk_entry->e_tag = entry->e_tag; ++ disk_entry->e_perm = entry->e_perm; + +- switch(entry->e_tag) { ++ switch(ext2fs_le16_to_cpu(entry->e_tag)) { + case ACL_USER_OBJ: + case ACL_GROUP_OBJ: + case ACL_MASK: +@@ -569,7 +569,7 @@ static errcode_t convert_posix_acl_to_disk_buffer(const void *value, size_t size + break; + case ACL_USER: + case ACL_GROUP: +- disk_entry->e_id = ext2fs_cpu_to_le32(entry->e_id); ++ disk_entry->e_id = entry->e_id; + e += sizeof(ext4_acl_entry); + s += sizeof(ext4_acl_entry); + break; +@@ -608,10 +608,10 @@ static errcode_t convert_disk_buffer_to_posix_acl(const void *value, size_t size + while (size > 0) { + const ext4_acl_entry *disk_entry = (const ext4_acl_entry *) cp; + +- entry->e_tag = ext2fs_le16_to_cpu(disk_entry->e_tag); +- entry->e_perm = ext2fs_le16_to_cpu(disk_entry->e_perm); ++ entry->e_tag = disk_entry->e_tag; ++ entry->e_perm = disk_entry->e_perm; + +- switch(entry->e_tag) { ++ switch(ext2fs_le16_to_cpu(entry->e_tag)) { + case ACL_USER_OBJ: + case ACL_GROUP_OBJ: + case ACL_MASK: +@@ -622,7 +622,7 @@ static errcode_t convert_disk_buffer_to_posix_acl(const void *value, size_t size + break; + case ACL_USER: + case ACL_GROUP: +- entry->e_id = ext2fs_le32_to_cpu(disk_entry->e_id); ++ entry->e_id = disk_entry->e_id; + cp += sizeof(ext4_acl_entry); + size -= sizeof(ext4_acl_entry); + break; +-- +2.30.2 + diff -Nru e2fsprogs-1.46.3/debian/patches/series e2fsprogs-1.46.3/debian/patches/series --- e2fsprogs-1.46.3/debian/patches/series 2021-08-10 10:07:14.000000000 +0200 +++ e2fsprogs-1.46.3/debian/patches/series 2021-08-11 19:04:17.000000000 +0200 @@ -1 +1,3 @@ default-to-4k.patch +0001-e2fsck-fix-f_baddotdir-failure-on-big-endian-systems.patch +0001-libext2fs-fix-translation-of-Posix-ACL-s-on-big-endi.patch