From 80abfebc673bb2a1496dec88f7f0601e7325d3c2 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 1 May 2024 16:54:26 -0400 Subject: [PATCH 01/34] e2image: add support for post-2038 dates in the e2image header Signed-off-by: Theodore Ts'o --- lib/ext2fs/e2image.h | 5 +++-- misc/e2image.c | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/e2image.h b/lib/ext2fs/e2image.h index 53b20cc73..143e0dc6c 100644 --- a/lib/ext2fs/e2image.h +++ b/lib/ext2fs/e2image.h @@ -26,8 +26,9 @@ struct ext2_image_hdr { __u32 image_device; /* Device number of image file */ __u32 image_inode; /* Inode number of image file */ - __u32 image_time; /* Time of image creation */ - __u32 image_reserved[8]; + __u32 image_time_lo; /* Time of image creation */ + __u32 image_time_hi; /* High bits of image test creation */ + __u32 image_reserved[7]; __u32 offset_super; /* Byte offset of the sb and descriptors */ __u32 offset_inode; /* Byte offset of the inode table */ diff --git a/misc/e2image.c b/misc/e2image.c index 1ae03001f..2c46d3ff8 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -239,6 +239,7 @@ static void write_image_file(ext2_filsys fs, int fd) struct ext2_image_hdr hdr; struct stat st; errcode_t retval; + time_t now = time(0); write_header(fd, NULL, sizeof(struct ext2_image_hdr), fs->blocksize); memset(&hdr, 0, sizeof(struct ext2_image_hdr)); @@ -292,7 +293,12 @@ static void write_image_file(ext2_filsys fs, int fd) } memcpy(hdr.fs_uuid, fs->super->s_uuid, sizeof(hdr.fs_uuid)); - hdr.image_time = ext2fs_cpu_to_le32(time(0)); + hdr.image_time_lo = ext2fs_cpu_to_le32(now & 0xFFFFFFFF); +#if (SIZEOF_TIME_T > 4) + hdr.image_time_hi = ext2fs_cpu_to_le32(now >> 32); +#else + hdr_image_time_hi = 0; +#endif write_header(fd, &hdr, sizeof(struct ext2_image_hdr), fs->blocksize); } From 1b9e68e0ff22933d1bab5defa761268e904daf28 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 1 May 2024 16:58:50 -0400 Subject: [PATCH 02/34] libsupport: use explicit type widths instead of time_t The in-memory data structures used time_t for the grace period (which is a delta timestamp denominated in seconds), as well as the soft limit expiration time (which is an actual time_t). Use an explicit __u32 for the former, and the __u64 for the latter. This silences a Coverity warning, but more importantly, using an explicit __u64 for the expiration time means that running e2fsck on a platform with a 32-bit time_t, and it needs to read and then modify a quota structure, we won't lose the high 32-bits of the quota expiration time. Addresses-Coverity-Bug: 1531824 Signed-off-by: Theodore Ts'o --- lib/support/quotaio.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/support/quotaio.h b/lib/support/quotaio.h index 390f7dc92..6152416fb 100644 --- a/lib/support/quotaio.h +++ b/lib/support/quotaio.h @@ -101,8 +101,8 @@ struct quotafile_ops; /* Generic information about quotafile */ struct util_dqinfo { - time_t dqi_bgrace; /* Block grace time for given quotafile */ - time_t dqi_igrace; /* Inode grace time for given quotafile */ + __u32 dqi_bgrace; /* Block grace time for given quotafile */ + __u32 dqi_igrace; /* Inode grace time for given quotafile */ union { struct v2_mem_dqinfo v2_mdqi; } u; /* Format specific info about quotafile */ @@ -137,8 +137,8 @@ struct util_dqblk { qsize_t dqb_bhardlimit; qsize_t dqb_bsoftlimit; qsize_t dqb_curspace; - time_t dqb_btime; - time_t dqb_itime; + __u64 dqb_btime; + __u64 dqb_itime; union { struct v2_mem_dqblk v2_mdqb; } u; /* Format specific dquot information */ From d04a708ecf955610654a2015de8657642857912d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 1 May 2024 17:22:55 -0400 Subject: [PATCH 03/34] e4defrag: use snprintf to assure that there can't be a buffer overflow The size of msg_buffer is carefully calculated so it can never overflow, but it triggers a Coverity warning. Use snprintf instead of sprintf to silence the Coverity warning. Addresses-Coverty-Bug: 1520603 Signed-off-by: Theodore Ts'o --- misc/e4defrag.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/misc/e4defrag.c b/misc/e4defrag.c index e3011d7cd..5bfa6ff14 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -1206,9 +1206,8 @@ static int file_statistic(const char *file, const struct stat64 *buf, if (mode_flag & DETAIL) { /* Print statistic info */ - sprintf(msg_buffer, "[%u/%u]%.*s", - defraged_file_count, total_count, - PATH_MAX, file); + snprintf(msg_buffer, sizeof(msg_buffer), "[%u/%u]%.*s", + defraged_file_count, total_count, PATH_MAX, file); if (current_uid == ROOT_UID) { if (strlen(msg_buffer) > 40) printf("\033[79;0H\033[K%s\n" From 8a253f09ec5295a9fc1c5168a99a5f4efc8bbce2 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 1 May 2024 17:27:24 -0400 Subject: [PATCH 04/34] libsupport: silence gcc -Wall complaints Signed-off-by: Theodore Ts'o --- lib/support/print_fs_flags.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/support/print_fs_flags.c b/lib/support/print_fs_flags.c index f47cd6653..093820f14 100644 --- a/lib/support/print_fs_flags.c +++ b/lib/support/print_fs_flags.c @@ -14,6 +14,7 @@ #include "config.h" #include +#include "print_fs_flags.h" #include "ext2fs/ext2fs.h" struct flags_name { From 79677f9aaa8618560798228e99099fd59b22ad3b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 1 May 2024 22:10:34 -0400 Subject: [PATCH 05/34] debian: build-depend on pkgconf instead of pkg-config The pkg-config package has been obsoleted by pkgconf. Signed-off-by: Theodore Ts'o --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index e3712d402..e641b3712 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: e2fsprogs Section: admin Priority: required Maintainer: Theodore Y. Ts'o -Build-Depends: dpkg-dev (>= 1.22.5), gettext, texinfo, pkg-config, libarchive-dev, libfuse3-dev [linux-any kfreebsd-any] , debhelper-compat (= 12), dh-exec, libblkid-dev, uuid-dev, m4, udev [linux-any], systemd [linux-any], systemd-dev [linux-any], cron [linux-any], dh-sequence-movetousr +Build-Depends: dpkg-dev (>= 1.22.5), gettext, texinfo, pkgconf, libarchive-dev, libfuse3-dev [linux-any kfreebsd-any] , debhelper-compat (= 12), dh-exec, libblkid-dev, uuid-dev, m4, udev [linux-any], systemd [linux-any], systemd-dev [linux-any], cron [linux-any], dh-sequence-movetousr Rules-Requires-Root: no Standards-Version: 4.7.0 Homepage: http://e2fsprogs.sourceforge.net From 66b0b3c1fc6262605d38f443641cdb9ab09d14e2 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 1 May 2024 23:02:31 -0400 Subject: [PATCH 06/34] e2image: fix typo which causes a compile failure on i386 Fixes: 80abfebc673b ("e2image: add support for post-2038 dates...") Signed-off-by: Theodore Ts'o --- misc/e2image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/e2image.c b/misc/e2image.c index 2c46d3ff8..a92672464 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -297,7 +297,7 @@ static void write_image_file(ext2_filsys fs, int fd) #if (SIZEOF_TIME_T > 4) hdr.image_time_hi = ext2fs_cpu_to_le32(now >> 32); #else - hdr_image_time_hi = 0; + hdr.image_time_hi = 0; #endif write_header(fd, &hdr, sizeof(struct ext2_image_hdr), fs->blocksize); } From b88b3b46cf1cfd4f0682374918fb3ba4aa0decdd Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 2 May 2024 12:23:44 -0400 Subject: [PATCH 07/34] libext2fs: fix potential divide by zero bug caused by a lxcfs bug If sysconf(_SC_NPROCESSORS_CONF) returns zero, this can cause a divide by zero. Make ext2fs_rw_bitmaps() more robust defaulting to 4 threads if _SC_NPROCESSORS_CONF returns an invalid value. https://github.com/tytso/e2fsprogs/issues/114 Signed-off-by: Theodore Ts'o --- lib/ext2fs/rw_bitmaps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index 1fe65f744..1da75e4a0 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -557,7 +557,7 @@ errcode_t ext2fs_rw_bitmaps(ext2_filsys fs, int flags, int num_threads) * MacOS, FreeBSD, etc. * ref: https://stackoverflow.com/questions/150355 */ - if (num_threads < 0) + if (num_threads <= 0) num_threads = 4; if ((unsigned) num_threads > fs->group_desc_count) From 9ebb163c44a9512bb2902fc231659aedb66d1f73 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 4 May 2024 23:56:12 -0400 Subject: [PATCH 08/34] configure: remove duplicated/unnecessary test for compiler fuzzing support Signed-off-by: Theodore Ts'o --- configure | 3 --- configure.ac | 3 --- 2 files changed, 6 deletions(-) diff --git a/configure b/configure index 2b712e5d3..cba3191c2 100755 --- a/configure +++ b/configure @@ -15645,9 +15645,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -fi -if test "$enable_fuzzer" = "yes" && test "$have_fuzzer" != "yes"; then - as_fn_error $? "Fuzzing not supported by compiler." "$LINENO" 5 fi LINUX_CMT="#" diff --git a/configure.ac b/configure.ac index e00e8d0e0..131caef38 100644 --- a/configure.ac +++ b/configure.ac @@ -1664,9 +1664,6 @@ if test "$enable_fuzzing" = "yes" || test "$enable_fuzzing" = "probe"; then AC_SUBST(fuzzer_cflags) AC_SUBST(fuzzer_ldflags) fi -if test "$enable_fuzzer" = "yes" && test "$have_fuzzer" != "yes"; then - AC_MSG_ERROR([Fuzzing not supported by compiler.]) -fi AC_SUBST(FUZZING_CMT) dnl dnl OS-specific uncomment control From 4c2fb1cc1848790735cb6bc78b5dfb8a30d326c2 Mon Sep 17 00:00:00 2001 From: Ye Bin Date: Thu, 18 Apr 2024 14:39:46 +0800 Subject: [PATCH 09/34] e2fsck: fix acl block leak when process orphan list 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2fsck/super.c b/e2fsck/super.c index 60c690c22..04d6ddee6 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; @@ -235,7 +235,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, if (pb.truncated_blocks) ext2fs_iblk_sub_blocks(fs, EXT2_INODE(inode), pb.truncated_blocks); - +release_acl: blk = ext2fs_file_acl_block(fs, EXT2_INODE(inode)); if (blk) { retval = ext2fs_adjust_ea_refcount3(fs, blk, block_buf, -1, From 849a9e6e133a903db7b005854ec58b35dc947150 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 6 May 2024 19:41:17 +0200 Subject: [PATCH 10/34] e2fsck: add more checks for ea inode consistency Currently checking of EA inodes was rather weak. Add several more consistency checks. 1) Check that EA inode is a regular file. 2) Check that EA_INODE feature is set if the filesystem has EA inodes. 3) Make sure that no EA inode is referenced from directory hierarchy. Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20240506174132.12883-1-jack@suse.cz Signed-off-by: Theodore Ts'o --- e2fsck/e2fsck.h | 6 ++++ e2fsck/pass1.c | 84 +++++++++++++++++++++++++++++++++++++++++------- e2fsck/pass2.c | 15 +++++++++ e2fsck/pass4.c | 53 +++++++++++++++++++----------- e2fsck/problem.c | 18 +++++++++++ e2fsck/problem.h | 12 +++++++ 6 files changed, 158 insertions(+), 30 deletions(-) diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index 55738fdc1..ae1273dc0 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -533,6 +533,12 @@ extern struct dx_dir_info *e2fsck_dx_dir_info_iter(e2fsck_t ctx, typedef __u64 ea_key_t; typedef __u64 ea_value_t; +/* + * Special refcount value we use for inodes which have EA_INODE flag set but we + * do not yet know about any references. + */ +#define EA_INODE_NO_REFS (~(ea_value_t)0) + extern errcode_t ea_refcount_create(size_t size, ext2_refcount_t *ret); extern void ea_refcount_free(ext2_refcount_t refcount); extern errcode_t ea_refcount_fetch(ext2_refcount_t refcount, ea_key_t ea_key, diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 8b6238e84..eb73922d3 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -387,34 +387,71 @@ static problem_t check_large_ea_inode(e2fsck_t ctx, return 0; } +static int alloc_ea_inode_refs(e2fsck_t ctx, struct problem_context *pctx) +{ + pctx->errcode = ea_refcount_create(0, &ctx->ea_inode_refs); + if (pctx->errcode) { + pctx->num = 4; + fix_problem(ctx, PR_1_ALLOCATE_REFCOUNT, pctx); + ctx->flags |= E2F_FLAG_ABORT; + return 0; + } + return 1; +} + static void inc_ea_inode_refs(e2fsck_t ctx, struct problem_context *pctx, struct ext2_ext_attr_entry *first, void *end) { struct ext2_ext_attr_entry *entry = first; struct ext2_ext_attr_entry *np = EXT2_EXT_ATTR_NEXT(entry); + ea_value_t refs; while ((void *) entry < end && (void *) np < end && !EXT2_EXT_IS_LAST_ENTRY(entry)) { if (!entry->e_value_inum) goto next; - if (!ctx->ea_inode_refs) { - pctx->errcode = ea_refcount_create(0, - &ctx->ea_inode_refs); - if (pctx->errcode) { - pctx->num = 4; - fix_problem(ctx, PR_1_ALLOCATE_REFCOUNT, pctx); - ctx->flags |= E2F_FLAG_ABORT; - return; - } - } - ea_refcount_increment(ctx->ea_inode_refs, entry->e_value_inum, - 0); + if (!ctx->ea_inode_refs && !alloc_ea_inode_refs(ctx, pctx)) + return; + ea_refcount_fetch(ctx->ea_inode_refs, entry->e_value_inum, + &refs); + if (refs == EA_INODE_NO_REFS) + refs = 1; + else + refs += 1; + ea_refcount_store(ctx->ea_inode_refs, entry->e_value_inum, refs); next: entry = np; np = EXT2_EXT_ATTR_NEXT(entry); } } +/* + * Make sure inode is tracked as EA inode. We use special EA_INODE_NO_REFS + * value if we didn't find any xattrs referencing this inode yet. + */ +static int track_ea_inode(e2fsck_t ctx, struct problem_context *pctx, + ext2_ino_t ino) +{ + ea_value_t refs; + + if (!ctx->ea_inode_refs && !alloc_ea_inode_refs(ctx, pctx)) + return 0; + + ea_refcount_fetch(ctx->ea_inode_refs, ino, &refs); + if (refs > 0) + return 1; + + pctx->errcode = ea_refcount_store(ctx->ea_inode_refs, ino, + EA_INODE_NO_REFS); + if (pctx->errcode) { + pctx->num = 5; + fix_problem(ctx, PR_1_ALLOCATE_REFCOUNT, pctx); + ctx->flags |= E2F_FLAG_ABORT; + return 0; + } + return 1; +} + static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx, struct ea_quota *ea_ibody_quota) { @@ -510,6 +547,12 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx, } else { blk64_t quota_blocks; + if (!ext2fs_has_feature_ea_inode(sb) && + fix_problem(ctx, PR_1_EA_INODE_FEATURE, pctx)) { + ext2fs_set_feature_ea_inode(sb); + ext2fs_mark_super_dirty(ctx->fs); + } + problem = check_large_ea_inode(ctx, entry, pctx, "a_blocks); if (problem != 0) @@ -1502,6 +1545,17 @@ void e2fsck_pass1(e2fsck_t ctx) e2fsck_write_inode(ctx, ino, inode, "pass1"); } + if (inode->i_flags & EXT4_EA_INODE_FL) { + if (!LINUX_S_ISREG(inode->i_mode) && + fix_problem(ctx, PR_1_EA_INODE_NONREG, &pctx)) { + inode->i_flags &= ~EXT4_EA_INODE_FL; + e2fsck_write_inode(ctx, ino, inode, "pass1"); + } + if (inode->i_flags & EXT4_EA_INODE_FL) + if (!track_ea_inode(ctx, &pctx, ino)) + continue; + } + /* Conflicting inlinedata/extents inode flags? */ if ((inode->i_flags & EXT4_INLINE_DATA_FL) && (inode->i_flags & EXT4_EXTENTS_FL)) { @@ -2622,6 +2676,12 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, problem_t problem; blk64_t entry_quota_blocks; + if (!ext2fs_has_feature_ea_inode(fs->super) && + fix_problem(ctx, PR_1_EA_INODE_FEATURE, pctx)) { + ext2fs_set_feature_ea_inode(fs->super); + ext2fs_mark_super_dirty(fs); + } + problem = check_large_ea_inode(ctx, entry, pctx, &entry_quota_blocks); if (problem && fix_problem(ctx, problem, pctx)) diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 08ab40fa8..036c0022d 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -1501,6 +1501,21 @@ static int check_dir_block(ext2_filsys fs, problem = PR_2_NULL_NAME; } + /* + * Check if inode was tracked as EA inode and has actual + * references from xattrs. In that case dir entry is likely + * bogus and we want to clear it. The case of EA inode without + * references from xattrs will be handled in pass 4. + */ + if (!problem && ctx->ea_inode_refs) { + ea_value_t refs; + + ea_refcount_fetch(ctx->ea_inode_refs, dirent->inode, + &refs); + if (refs && refs != EA_INODE_NO_REFS) + problem = PR_2_EA_INODE_DIR_LINK; + } + if (problem) { if (fix_problem(ctx, problem, &cd->pctx)) { dirent->inode = 0; diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c index d2dda02a9..cf0cf7c47 100644 --- a/e2fsck/pass4.c +++ b/e2fsck/pass4.c @@ -96,9 +96,10 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i, ext2_ino_t *last_ino, * an xattr inode at all. Return immediately if EA_INODE flag is not set. */ static void check_ea_inode(e2fsck_t ctx, ext2_ino_t i, ext2_ino_t *last_ino, - struct ext2_inode_large *inode, __u16 *link_counted) + struct ext2_inode_large *inode, __u16 *link_counted, + ea_value_t actual_refs) { - __u64 actual_refs = 0; + struct problem_context pctx; __u64 ref_count; if (*last_ino != i) { @@ -107,13 +108,26 @@ static void check_ea_inode(e2fsck_t ctx, ext2_ino_t i, ext2_ino_t *last_ino, "pass4: check_ea_inode"); *last_ino = i; } - if (!(inode->i_flags & EXT4_EA_INODE_FL)) - return; - if (ctx->ea_inode_refs) - ea_refcount_fetch(ctx->ea_inode_refs, i, &actual_refs); - if (!actual_refs) + clear_problem_context(&pctx); + pctx.ino = i; + pctx.inode = EXT2_INODE(inode); + + /* No references to the inode from xattrs? */ + if (actual_refs == EA_INODE_NO_REFS) { + /* + * No references from directory hierarchy either? Inode will + * will get attached to lost+found so clear EA_INODE_FL. + * Otherwise this is likely a spuriously set flag so clear it. + */ + if (*link_counted == 0 || + fix_problem(ctx, PR_4_EA_INODE_SPURIOUS_FLAG, &pctx)) { + /* Clear EA_INODE_FL (likely a normal file) */ + inode->i_flags &= ~EXT4_EA_INODE_FL; + e2fsck_write_inode(ctx, i, EXT2_INODE(inode), "pass4"); + } return; + } /* * There are some attribute references, link_counted is now considered @@ -127,10 +141,6 @@ static void check_ea_inode(e2fsck_t ctx, ext2_ino_t i, ext2_ino_t *last_ino, * However, their i_ctime and i_atime should be the same. */ if (ref_count != actual_refs && inode->i_ctime != inode->i_atime) { - struct problem_context pctx; - - clear_problem_context(&pctx); - pctx.ino = i; pctx.num = ref_count; pctx.num2 = actual_refs; if (fix_problem(ctx, PR_4_EA_INODE_REF_COUNT, &pctx)) { @@ -188,6 +198,7 @@ void e2fsck_pass4(e2fsck_t ctx) /* Protect loop from wrap-around if s_inodes_count maxed */ for (i = 1; i <= fs->super->s_inodes_count && i > 0; i++) { ext2_ino_t last_ino = 0; + ea_value_t ea_refs; int isdir; if (ctx->flags & E2F_FLAG_SIGNAL_MASK) @@ -211,13 +222,19 @@ void e2fsck_pass4(e2fsck_t ctx) ext2fs_icount_fetch(ctx->inode_link_info, i, &link_count); ext2fs_icount_fetch(ctx->inode_count, i, &link_counted); - if (link_counted == 0) { - /* - * link_counted is expected to be 0 for an ea_inode. - * check_ea_inode() will update link_counted if - * necessary. - */ - check_ea_inode(ctx, i, &last_ino, inode, &link_counted); + if (ctx->ea_inode_refs) { + ea_refcount_fetch(ctx->ea_inode_refs, i, &ea_refs); + if (ea_refs) { + /* + * Final consolidation of EA inodes. We either + * decide the inode is fine and set link_counted + * to one, or we decide this is actually a + * normal file and clear EA_INODE flag, or + * decide the inode should just be deleted. + */ + check_ea_inode(ctx, i, &last_ino, inode, + &link_counted, ea_refs); + } } if (link_counted == 0) { diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 207ebbb34..e433281fa 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -1309,6 +1309,16 @@ static struct e2fsck_problem problem_table[] = { N_("Orphan file @i %i is not in use, but contains data. "), PROMPT_CLEAR, PR_PREEN_OK }, + /* EA_INODE flag set on a non-regular file */ + { PR_1_EA_INODE_NONREG, + N_("@i %i has the ea_inode flag set but is not a regular file. "), + PROMPT_CLEAR_FLAG, 0, 0, 0, 0 }, + + /* EA_INODE present but the file system is missing the ea_inode feature */ + { PR_1_EA_INODE_FEATURE, + N_("@i %i references EA inode but @S is missing EA_INODE feature\n"), + PROMPT_FIX, PR_PREEN_OK, 0, 0, 0 }, + /* Pass 1b errors */ /* Pass 1B: Rescan for duplicate/bad blocks */ @@ -1860,6 +1870,10 @@ static struct e2fsck_problem problem_table[] = { N_("Duplicate filename @E found. "), PROMPT_CLEAR, 0, 0, 0, 0 }, + /* Directory filename is null */ + { PR_2_EA_INODE_DIR_LINK, + N_("@E references EA @i %Di.\n"), + PROMPT_CLEAR, 0, 0, 0, 0 }, /* Pass 3 errors */ @@ -2102,6 +2116,10 @@ static struct e2fsck_problem problem_table[] = { N_("@d @i %i ref count set to overflow but could be exact value %N. "), PROMPT_FIX, PR_PREEN_OK, 0, 0, 0 }, + { PR_4_EA_INODE_SPURIOUS_FLAG, + N_("Regular @f @i %i has EA_INODE flag set. "), + PROMPT_CLEAR, PR_PREEN_OK, 0, 0, 0 }, + /* Pass 5 errors */ /* Pass 5: Checking group summary information */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index b47b0c630..ef15b8c84 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -734,6 +734,12 @@ struct problem_context { /* Orphan file inode is not in use, but contains data */ #define PR_1_ORPHAN_FILE_NOT_CLEAR 0x010090 +/* Inode has EA_INODE_FL set but is not a regular file */ +#define PR_1_EA_INODE_NONREG 0x010091 + +/* Inode references EA inode but ea_inode feature is not enabled */ +#define PR_1_EA_INODE_FEATURE 0x010092 + /* * Pass 1b errors */ @@ -1061,6 +1067,9 @@ struct problem_context { /* Non-unique filename found, but can't rename */ #define PR_2_NON_UNIQUE_FILE_NO_RENAME 0x020054 +/* EA inode referenced from directory */ +#define PR_2_EA_INODE_DIR_LINK 0x020055 + /* * Pass 3 errors */ @@ -1203,6 +1212,9 @@ struct problem_context { /* Directory ref count set to overflow but it doesn't have to be */ #define PR_4_DIR_OVERFLOW_REF_COUNT 0x040007 +/* EA_INODE_FL set on normal file linked from directory hierarchy */ +#define PR_4_EA_INODE_SPURIOUS_FLAG 0x040008 + /* * Pass 5 errors */ From eb01b6e22a44a26668c9f8645ca1889d67a643c1 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 6 May 2024 19:41:18 +0200 Subject: [PATCH 11/34] e2fsck: add tests for EA inodes Add tests exercising EA inodes and testing various types of corruption. Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20240506174132.12883-2-jack@suse.cz Signed-off-by: Theodore Ts'o --- tests/f_ea_inode_dir_ref/expect.1 | 12 ++++++++++ tests/f_ea_inode_dir_ref/expect.2 | 7 ++++++ tests/f_ea_inode_dir_ref/image.gz | Bin 0 -> 1822 bytes tests/f_ea_inode_dir_ref/name | 1 + tests/f_ea_inode_disconnected/expect.1 | 23 ++++++++++++++++++++ tests/f_ea_inode_disconnected/expect.2 | 7 ++++++ tests/f_ea_inode_disconnected/image | Bin 0 -> 1048576 bytes tests/f_ea_inode_disconnected/image.gz | Bin 0 -> 1779 bytes tests/f_ea_inode_disconnected/name | 1 + tests/f_ea_inode_no_feature/expect.1 | 12 ++++++++++ tests/f_ea_inode_no_feature/expect.2 | 7 ++++++ tests/f_ea_inode_no_feature/image.gz | Bin 0 -> 1817 bytes tests/f_ea_inode_no_feature/name | 1 + tests/f_ea_inode_spurious_flag_dir/expect.1 | 11 ++++++++++ tests/f_ea_inode_spurious_flag_dir/expect.2 | 7 ++++++ tests/f_ea_inode_spurious_flag_dir/image | Bin 0 -> 1048576 bytes tests/f_ea_inode_spurious_flag_dir/image.gz | Bin 0 -> 1598 bytes tests/f_ea_inode_spurious_flag_dir/name | 1 + 18 files changed, 90 insertions(+) create mode 100644 tests/f_ea_inode_dir_ref/expect.1 create mode 100644 tests/f_ea_inode_dir_ref/expect.2 create mode 100644 tests/f_ea_inode_dir_ref/image.gz create mode 100644 tests/f_ea_inode_dir_ref/name create mode 100644 tests/f_ea_inode_disconnected/expect.1 create mode 100644 tests/f_ea_inode_disconnected/expect.2 create mode 100644 tests/f_ea_inode_disconnected/image create mode 100644 tests/f_ea_inode_disconnected/image.gz create mode 100644 tests/f_ea_inode_disconnected/name create mode 100644 tests/f_ea_inode_no_feature/expect.1 create mode 100644 tests/f_ea_inode_no_feature/expect.2 create mode 100644 tests/f_ea_inode_no_feature/image.gz create mode 100644 tests/f_ea_inode_no_feature/name create mode 100644 tests/f_ea_inode_spurious_flag_dir/expect.1 create mode 100644 tests/f_ea_inode_spurious_flag_dir/expect.2 create mode 100644 tests/f_ea_inode_spurious_flag_dir/image create mode 100644 tests/f_ea_inode_spurious_flag_dir/image.gz create mode 100644 tests/f_ea_inode_spurious_flag_dir/name diff --git a/tests/f_ea_inode_dir_ref/expect.1 b/tests/f_ea_inode_dir_ref/expect.1 new file mode 100644 index 000000000..fa6a872b8 --- /dev/null +++ b/tests/f_ea_inode_dir_ref/expect.1 @@ -0,0 +1,12 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Entry 'xlink' in / (2) references EA inode 13. +Clear? yes + +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information + +test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** +test_filesys: 13/128 files (0.0% non-contiguous), 63/1024 blocks +Exit status is 1 diff --git a/tests/f_ea_inode_dir_ref/expect.2 b/tests/f_ea_inode_dir_ref/expect.2 new file mode 100644 index 000000000..24d059a30 --- /dev/null +++ b/tests/f_ea_inode_dir_ref/expect.2 @@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 13/128 files (0.0% non-contiguous), 63/1024 blocks +Exit status is 0 diff --git a/tests/f_ea_inode_dir_ref/image.gz b/tests/f_ea_inode_dir_ref/image.gz new file mode 100644 index 0000000000000000000000000000000000000000..483cc725ee29f2ba26c3cff2571741d1e0c0da49 GIT binary patch literal 1822 zcmb2|=3tQjWs%0f{PwPIMvSWr!-tz^-5;y9MkR^bN*v7En9K7-h}Ci7jG!ak8X|8O z%CEb!#M7`dWQrLptF32|kbazw+?Pems|2J3Z7N@_Tq+p2Ix~bP2Ze-S;@gh zSHJ&mtu)TRcYE&toFDwo5ucnGy0UC!XF0#-?c%;Znx>Z`Lh@z}>PZ_+%j@`ht+QTZC_w?#X5@BS#e?_7W;KVN@O-detXURjQ> z?@#4&=q^>h+T5&v?AxyhKeMBs4>mh9M^58^;C3YD-?wisU;e&z_|TvEnORTlKm4Ei zX@CB&i_3$4f48ZwSC~BIzyH6Ymnm7N>ovrF@*h?Gzi`JBdy(mX+8<5&9}x3NzRUZc zbK%K)4LzWwsr`S(hNP8ucfXL)=y~wO7by?JTj(v|;go(SA>(v;Jl?)`Gx{-yiA zh4$U8w`*BvQ2FGoeOb+fQ$KDTdARk@pW@s9Gv9H1s!9(AlE12=f#j~__;(ym683WZ zwr9_JU;iI;W5cQM_e$r!4whf~b^ZU1KWkm1{x941yiZ|$`TH}nj&apxKz2)T=Ksr^ z@BCXY^KRAk+^>%x{q;Yd6WM$3d+@*ae{<^YM?L@Feq6fr*7siB8~>*|EsfjW`sID0 z_VmL|KmSYX&$0e>x9G2O{*s^mbM9GQ+*z2%KjWDH*Q>iviAO(9E3VC{-D-I3!{ceO z?QyrQt$v;2W!vl#_5bqkc@rq)UkHV45%F}0!>QBdijZCsIlq}q+NAU2|c zo}@jA7x7R$=%qc`n^8e83gX3<;6bgXq7?i%*7d#Jtl6efTPI|h-QOSH&dl34Z{GV2 z|Hn|anGgg40=+6QohIHF!sfV{DTh#t+bq?!VkGXwG95RMovT!9*;qA%di{~}S)*O^ zIDQ$Ub>7wU2bH+}Xdr|=vH$ho%|80;tq%{pTKVC?o4ZbLNKM+~u6_H{rE|ure?9-q z`%i!SHw|J3KBw`JkJFg$<8g}F+c*Yd_lgln0!_uLmN$J#5pVE>XE+68m! z_9=Wlde0L>agsO2az`vP>_x#HbEK#kB009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5a@tFy?*4y@MpbVkH7utKupIg3jzc>Bv6V; zKOC~s#<*?nmr5JsLHZ5fYP z`TPfI(DJ`fx6WV*0YpwkY>rWQ0xzf%Swcozzc=6%PyJ`I! zzqh@9;ri{h-MK$=XLru)a%c6%qQ5QL7Sr}^UEdBi3AHTb)+3-Ik?sl&xi5>_msy;qhxwI-^wdYEaD{`-`HqSOS^vzXJ z46fZDKg0a}+3MeEWz+u~w6uyd1%yn_4CYO=2)jI0;8;>@RK-Du`nJzFTD<@9zr*gw z!vE!6`}_LlW_i2chxLtb$6J4W`*WWE{+mVlnl>`Oo}Y`IIkR4Vb*jR@snasnA3L`2 z>N}mytM>)uRj{|eK7T#A)?Md&>y-Z+1Ne>q#Drs~}F-`0?G%CP0{!VtNh()9f?ax!oJw7rj68fRx>WwvjrrB&e* zhm8MW?_PWPzl`|2)A@YLOudGy0-OK*{U~0x|GN0Ung3^cssBIlKm1hvkiY)zzxx ztx|k5GuLEx@zUaDm+It-IQA|S+5Yvu_sdQDmu}l9`pve;uBFkS^iA*S+xLA_iyl3> zxb@GU;@kfN-w8hX`s~;pffqQtx+*K_hi2Bi;w%lRFDsJD>i(_Y{`#!PCe|Ltr!n24x6vz0|)a L>@2~+Aiw|sY0a}* literal 0 HcmV?d00001 diff --git a/tests/f_ea_inode_disconnected/name b/tests/f_ea_inode_disconnected/name new file mode 100644 index 000000000..ce04192e8 --- /dev/null +++ b/tests/f_ea_inode_disconnected/name @@ -0,0 +1 @@ +ea inode that is not connected anywhere diff --git a/tests/f_ea_inode_no_feature/expect.1 b/tests/f_ea_inode_no_feature/expect.1 new file mode 100644 index 000000000..f6a232bfc --- /dev/null +++ b/tests/f_ea_inode_no_feature/expect.1 @@ -0,0 +1,12 @@ +Pass 1: Checking inodes, blocks, and sizes +Inode 12 references EA inode but superblock is missing EA_INODE feature +Fix? yes + +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information + +test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** +test_filesys: 13/128 files (0.0% non-contiguous), 63/1024 blocks +Exit status is 1 diff --git a/tests/f_ea_inode_no_feature/expect.2 b/tests/f_ea_inode_no_feature/expect.2 new file mode 100644 index 000000000..24d059a30 --- /dev/null +++ b/tests/f_ea_inode_no_feature/expect.2 @@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 13/128 files (0.0% non-contiguous), 63/1024 blocks +Exit status is 0 diff --git a/tests/f_ea_inode_no_feature/image.gz b/tests/f_ea_inode_no_feature/image.gz new file mode 100644 index 0000000000000000000000000000000000000000..596d69a1c990ee5b79c7e2b291904fe5a5aab4b3 GIT binary patch literal 1817 zcmb2|=3oeZYmvsl{PwPIMvSWr!-vY*zEYDpf|5jSXEa|;x-D@cRg|SQ!Anp-XkiBb z-vZZP6SIUe18<3lyz!hgS)N^AjKAvQWVx1Q9917f1fo`T+?plgeel)Bb@^qR&EmIS zZ1MT}w=VJCnc3gVp4&_RJ1j75k3hpBsqXe7j=zSCzelIuEc@TLS2z3T{eSp;W#e_fId=Dd-MlXS{`{fE3$vfyy1Fv^bA+btPycNm z^_K77M87;J6#aqw>9X(N%#YuHd*b!(PoEq*e%i};6&jvcoB#fIjYZDAy1m!eRsVdV zy;@k60Rjq?x8Ay_{IEZ2?X^iMKQ>BD@X_=?v~I%Gs?WPF>P@YxmcIY+HJ|L#TIa*c z(yN^pvwv&(RsM8eR_0m0(D)nQVqi5~4pWt!k|MB{re=>7U*K3IV=facq z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z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 r2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7rc>Z6Uy%fq literal 0 HcmV?d00001 diff --git a/tests/f_ea_inode_spurious_flag_dir/image.gz b/tests/f_ea_inode_spurious_flag_dir/image.gz new file mode 100644 index 0000000000000000000000000000000000000000..af19132ce100fc006c8b83832683dbf2bcab6b53 GIT binary patch literal 1598 zcmb2|=3uD*Z;{5p{PwPYhi{+^`-l6#56}20=4G5>maM)kvt`z#q=QbHfs+*U@u5fM=e+?o@=-o6o`=~zxdzvR18lCHVT&vqaq_rF`wV>^xgfUwM;OT$N*^bh>Q+>MecQ`P*x&?moKN zyK&FX{RWRb{{1_iH|JjYhg;uV&%XX^em=)y->362zUTSBe>0c2xm%xp`@!A4%*M=z z`=^B@6`Q1eFO56?-e`)wR`HkXpU)kZT{Xk^WEP@m##nZGwxNctkC-(p!bRYsp|iLI9$}#ne_|{Vm7UxcE;mxeaeFB zOJ}U0Zi7+>`c0M}KW0BQZ|>)dPxI!!{CzL)75aVedXe_pu+DE% zFFzOl@Hi5X6Lan6^|R;gx1LOUCAg$?ss2}vOI3!ms#r3=&hxcx>R4G^X&SY@-ui!N z(n*{9)xZ6}+3yTJQ$PD#$+xMQ|Ejl|0oCuaxvzhr{?4?uE8PVO*YEf*IrsIyc}s18Qu9k{=K+VrH{>#UWLGp5hWSpVzR?4kfv bC8NC25Eu=C!5acoF1d$inN4J15MTfRZKqU& literal 0 HcmV?d00001 diff --git a/tests/f_ea_inode_spurious_flag_dir/name b/tests/f_ea_inode_spurious_flag_dir/name new file mode 100644 index 000000000..8ae52ccf0 --- /dev/null +++ b/tests/f_ea_inode_spurious_flag_dir/name @@ -0,0 +1 @@ +ea inode flag set on a directory From 7b2e837bf0eacb5c12396e994b4c7979f576019a Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 6 May 2024 19:41:19 +0200 Subject: [PATCH 12/34] e2fsck: fix golden output of several tests Some old tests of EA inodes were not in fact completely fixing the filesystem (like they were leaving directories with EA_INODE_FL set or EA inodes referenced from directory hierarchy). New e2fsck checks fix these so golden output changes. Update it. Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20240506174132.12883-3-jack@suse.cz Signed-off-by: Theodore Ts'o --- tests/f_bad_disconnected_inode/expect.1 | 8 ++++++++ tests/f_bad_fname/expect.1 | 2 ++ tests/f_ea_inode_self_ref/expect.1 | 2 ++ 3 files changed, 12 insertions(+) diff --git a/tests/f_bad_disconnected_inode/expect.1 b/tests/f_bad_disconnected_inode/expect.1 index d1479cef2..39c6958cf 100644 --- a/tests/f_bad_disconnected_inode/expect.1 +++ b/tests/f_bad_disconnected_inode/expect.1 @@ -1,11 +1,17 @@ Pass 1: Checking inodes, blocks, and sizes +Inode 1 has the ea_inode flag set but is not a regular file. Clear flag? yes + Inode 1 has EXTENTS_FL flag set on filesystem without extents support. Clear? yes Inode 9 has the casefold flag set but is not a directory. Clear flag? yes +Inode 10 has the ea_inode flag set but is not a regular file. Clear flag? yes + Inode 14 has the casefold flag set but is not a directory. Clear flag? yes +Inode 14 has the ea_inode flag set but is not a regular file. Clear flag? yes + Inode 14 has INLINE_DATA_FL flag on filesystem without inline data support. Clear? yes @@ -14,6 +20,8 @@ Clear? yes Inode 16 has the casefold flag set but is not a directory. Clear flag? yes +Inode 16 has the ea_inode flag set but is not a regular file. Clear flag? yes + Inode 16 has INLINE_DATA_FL flag on filesystem without inline data support. Clear? yes diff --git a/tests/f_bad_fname/expect.1 b/tests/f_bad_fname/expect.1 index 66f87df2b..60f64f67d 100644 --- a/tests/f_bad_fname/expect.1 +++ b/tests/f_bad_fname/expect.1 @@ -1,4 +1,6 @@ Pass 1: Checking inodes, blocks, and sizes +Inode 12 has the ea_inode flag set but is not a regular file. Clear flag? yes + Pass 2: Checking directory structure Entry 'AM-^?' in /ci_dir (12) has illegal UTF-8 characters in its name. Fix? yes diff --git a/tests/f_ea_inode_self_ref/expect.1 b/tests/f_ea_inode_self_ref/expect.1 index f94c04d96..35bea1417 100644 --- a/tests/f_ea_inode_self_ref/expect.1 +++ b/tests/f_ea_inode_self_ref/expect.1 @@ -7,6 +7,8 @@ Clear? yes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts +Regular filesystem inode 16 has EA_INODE flag set. Clear? yes + Pass 5: Checking group summary information Block bitmap differences: -20 Fix? yes From 45e2950dbc220e0c6a61a97fdbb8fc3686abf71a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 18 May 2024 00:56:58 -0400 Subject: [PATCH 13/34] libext2fs: add ext2_types.h to qcow2.h The qcow2.h header file uses types such __u32 which are defined in ext2_types.h. So include it directly to avoid relying on users of the qcow2.h header file to include right dependencies. Signed-off-by: Theodore Ts'o --- lib/ext2fs/qcow2.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ext2fs/qcow2.h b/lib/ext2fs/qcow2.h index b649c9cf4..343e85ab0 100644 --- a/lib/ext2fs/qcow2.h +++ b/lib/ext2fs/qcow2.h @@ -24,6 +24,8 @@ * %End-Header% */ +#include + /* Number of l2 tables in memory before writeback */ #define L2_CACHE_PREALLOC 512 From d17f167c294ccbf6ee75ad9beefcfe2581d04904 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 18 May 2024 01:00:14 -0400 Subject: [PATCH 14/34] libext2fs: avoid using a C++ reserved identifier in rbtree.h Signed-off-by: Theodore Ts'o --- lib/ext2fs/rbtree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ext2fs/rbtree.h b/lib/ext2fs/rbtree.h index 790f5c1c7..b96e6f2c2 100644 --- a/lib/ext2fs/rbtree.h +++ b/lib/ext2fs/rbtree.h @@ -163,7 +163,7 @@ extern struct rb_node *ext2fs_rb_first(const struct rb_root *); extern struct rb_node *ext2fs_rb_last(const struct rb_root *); /* Fast replacement of a single node without remove/rebalance/add/rebalance */ -extern void ext2fs_rb_replace_node(struct rb_node *victim, struct rb_node *new, +extern void ext2fs_rb_replace_node(struct rb_node *victim, struct rb_node *new_, struct rb_root *root); static inline void ext2fs_rb_link_node(struct rb_node * node, From 1f4724705a045e26269cc2b6c03203499ef5bb26 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 18 May 2024 01:10:01 -0400 Subject: [PATCH 15/34] Use ext2/ext3/ext4 instead of "second extended file system" in man pages Addresses-Debian-Bug: #1041115 Signed-off-by: Theodore Ts'o --- misc/lsattr.1.in | 4 ++-- misc/mklost+found.8.in | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/misc/lsattr.1.in b/misc/lsattr.1.in index 4d02a95a3..9884a4d6b 100644 --- a/misc/lsattr.1.in +++ b/misc/lsattr.1.in @@ -1,7 +1,7 @@ .\" -*- nroff -*- .TH LSATTR 1 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@" .SH NAME -lsattr \- list file attributes on a Linux second extended file system +lsattr \- list ext2/ext3/ext4 file attributes .SH SYNOPSIS .B lsattr [ @@ -12,7 +12,7 @@ lsattr \- list file attributes on a Linux second extended file system ] .SH DESCRIPTION .B lsattr -lists the file attributes on a second extended file system. See +lists the file attributes on an ext2/ext3/ext4 file system. See .BR chattr (1) for a description of the attributes and what they mean. .SH OPTIONS diff --git a/misc/mklost+found.8.in b/misc/mklost+found.8.in index d33823948..59b7e761c 100644 --- a/misc/mklost+found.8.in +++ b/misc/mklost+found.8.in @@ -4,15 +4,15 @@ .\" .TH MKLOST+FOUND 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@" .SH NAME -mklost+found \- create a lost+found directory on a mounted Linux -second extended file system +mklost+found \- create a lost+found directory on a mounted +ext2/ext3/ext4 file system .SH SYNOPSIS .B mklost+found .SH DESCRIPTION .B mklost+found is used to create a .I lost+found -directory in the current working directory on a Linux second extended +directory in the current working directory on an ext2/ext3/ext4 file system. There is normally a .I lost+found directory in the root directory of each file system. From 048424fdc056bb2b6bcd027e630cc68115a5922e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 2 Feb 2023 17:56:20 +0000 Subject: [PATCH 16/34] AOSP: Revert "Android: stop suppressing warnings from macOS build" Unfortunately, the macOS build is not tested either by presubmit or by local builds. A macOS build *is* being tested in the upstream GitHub Actions workflow now; however, that uses the autotools-based build system, and there can be issues specific to the Android build system. As a result, removing -Wno-error was not safe yet, and the macOS build is currently broken in postsubmit. As there could be multiple issues, let's restore -Wno-error until I've had a chance to fix the warnings. Bug: 267448785 Change-Id: I305f73d1f8637477da3d57b6c93037a6e3d9e829 From AOSP commit: 0ed82a3f0a393605b56672704379f4fc1e53d281 --- Android.bp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Android.bp b/Android.bp index 1e6aa1a58..9e229ddad 100644 --- a/Android.bp +++ b/Android.bp @@ -62,6 +62,10 @@ cc_defaults { "libdl", ], }, + darwin: { + // Still has unfixed/unsuppressed warnings. + cflags: ["-Wno-error"], + }, windows: { include_dirs: ["external/e2fsprogs/include/mingw"], }, From 5a54747af1389113bde7ebf326a16a27e506d747 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 2 Feb 2023 22:42:19 +0000 Subject: [PATCH 17/34] AOSP: Android: define HAVE_GETMNTINFO on macOS macOS supports getmntinfo(), but not getmntent(). To match what the 'configure' script detects, define HAVE_GETMNTINFO to 1. This prevents the following warning: #warning "Can't use getmntent or getmntinfo to check for mounted filesystems!" Bug: 267448785 Change-Id: I3131563fc317fa9fef7745937ec2c4b09a1d29b0 From AOSP commit: bb6d46cc9770f4f15a5e52122a16f762c1bb567a --- util/android_config.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/android_config.h b/util/android_config.h index 90b8f8a8f..c2288602e 100644 --- a/util/android_config.h +++ b/util/android_config.h @@ -54,6 +54,9 @@ # define HAVE_SYS_SELECT_H 1 # define HAVE_SYS_WAIT_H 1 #endif +#ifdef __APPLE__ +# define HAVE_GETMNTINFO 1 +#endif #if defined(__linux__) # define HAVE_EXT2_IOCTLS 1 # define HAVE_FALLOCATE 1 From 64ded5527ae72c553327ee219d6cfcc14f436492 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 8 Feb 2023 21:42:02 +0000 Subject: [PATCH 18/34] AOSP: Mostly restore -Werror for macOS build It turns out the "Can't use getmntent or getmntinfo" warning was the only warning remaining in the macOS build via the Android build system. So now that it's fixed, -Wno-error can be removed. That being said, the upstream CI (GitHub Actions) currently uses -Wno-error=deprecated-declarations for the macOS build, since it's still needed for some files (which aren't built by the Android build system). For now, let's just replace -Wno-error with -Wno-error=deprecated-declarations to match what the upstream CI uses. Change-Id: I77f6649b99432ef1d73a0c7e30bbb150c3111b27 From AOSP commit: 6ea38ded59fe970704612a31a3aea4ccaf923d6a --- Android.bp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Android.bp b/Android.bp index 9e229ddad..46f63348c 100644 --- a/Android.bp +++ b/Android.bp @@ -63,8 +63,8 @@ cc_defaults { ], }, darwin: { - // Still has unfixed/unsuppressed warnings. - cflags: ["-Wno-error"], + // This matches what the upstream CI uses + cflags: ["-Wno-error=deprecated-declarations"], }, windows: { include_dirs: ["external/e2fsprogs/include/mingw"], From e6402f03899af646016864255bf485f2994a9c2b Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 23 Mar 2023 00:44:21 +0000 Subject: [PATCH 19/34] AOSP: ext2simg: fix off-by-one errors causing corruption The chunk_end parameter to add_chunk() is exclusive, but two callers incorrectly treat it as inclusive: when the maximum chunk length of 'INT32_MAX - 12' bytes is reached, and when a chunk extends to the very end of the filesystem. The result is that the output simg file contains zeroes for the last block of these chunks instead of the correct data. A related bug is that the expanded size of the simg file is set to the filesystem size (in blocks) minus s_first_data_block. On filesystems where s_first_data_block != 0, i.e. 1K blocksize filesystems without bigalloc enabled, this truncates the last block of the filesystem. Fix these bugs by (a) making add_chunk() take the chunk length and passing the correct values, and (b) using the filesystem size properly. Here is a reproducer that shows the last block of the filesystem being truncated (bsize=1024) and being corrupted with zeroes (bsize=4096): for bsize in 1024 4096; do rm -f ext4.img mkfs.ext4 -b $bsize ext4.img 10000 mkdir -p mnt sudo mount -t ext4 -o loop ext4.img mnt sudo cp /dev/urandom mnt/fill sudo umount mnt ext2simg ext4.img ext4.simg simg2img ext4.simg ext4.img.restored cmp ext4.img ext4.img.restored done Fixes: db6f320912cf ("AOSP: android: add the ext2simg tool") Reported-by: Clemens Lang Change-Id: I3b64c4fbffa5821b431f29e99b36168617da7563 Signed-off-by: Eric Biggers From AOSP commit: 1e498908c6ac13b4d5ec0117f4ddcd577aac607e --- contrib/android/ext2simg.c | 49 +++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/contrib/android/ext2simg.c b/contrib/android/ext2simg.c index 017e16ff7..9ef54cfff 100644 --- a/contrib/android/ext2simg.c +++ b/contrib/android/ext2simg.c @@ -63,12 +63,16 @@ static struct buf_item { void *buf[0]; } *buf_list; -static void add_chunk(ext2_filsys fs, struct sparse_file *s, blk_t chunk_start, blk_t chunk_end) +/* + * Add @num_blks blocks, starting at index @chunk_start, of the filesystem @fs + * to the sparse file @s. + */ +static void add_chunk(ext2_filsys fs, struct sparse_file *s, + blk_t chunk_start, int num_blks) { int retval; - unsigned int nb_blk = chunk_end - chunk_start; - size_t len = nb_blk * fs->blocksize; - int64_t offset = (int64_t)chunk_start * (int64_t)fs->blocksize; + uint64_t len = (uint64_t)num_blks * fs->blocksize; + int64_t offset = (int64_t)chunk_start * fs->blocksize; if (params.overwrite_input == false) { if (sparse_file_add_file(s, params.in_file, offset, len, chunk_start) < 0) @@ -86,9 +90,9 @@ static void add_chunk(ext2_filsys fs, struct sparse_file *s, blk_t chunk_start, buf_list = bi; } - retval = io_channel_read_blk64(fs->io, chunk_start, nb_blk, bi->buf); + retval = io_channel_read_blk64(fs->io, chunk_start, num_blks, bi->buf); if (retval < 0) - ext2fs_fatal(retval, "reading block %u - %u", chunk_start, chunk_end); + ext2fs_fatal(retval, "reading data from %s", params.in_file); if (sparse_file_add_data(s, bi->buf, len, chunk_start) < 0) sparse_fatal("adding data to the sparse file"); @@ -112,7 +116,7 @@ static struct sparse_file *ext_to_sparse(const char *in_file) ext2_filsys fs; struct sparse_file *s; int64_t chunk_start = -1; - blk_t first_blk, last_blk, nb_blk, cur_blk; + blk_t fs_blks, cur_blk; retval = ext2fs_open(in_file, 0, 0, 0, unix_io_manager, &fs); if (retval) @@ -122,11 +126,9 @@ static struct sparse_file *ext_to_sparse(const char *in_file) if (retval) ext2fs_fatal(retval, "while reading block bitmap of %s", in_file); - first_blk = ext2fs_get_block_bitmap_start2(fs->block_map); - last_blk = ext2fs_get_block_bitmap_end2(fs->block_map); - nb_blk = last_blk - first_blk + 1; + fs_blks = ext2fs_blocks_count(fs->super); - s = sparse_file_new(fs->blocksize, (uint64_t)fs->blocksize * (uint64_t)nb_blk); + s = sparse_file_new(fs->blocksize, (uint64_t)fs_blks * fs->blocksize); if (!s) sparse_fatal("creating sparse file"); @@ -140,22 +142,37 @@ static struct sparse_file *ext_to_sparse(const char *in_file) */ int64_t max_blk_per_chunk = (INT32_MAX - 12) / fs->blocksize; - /* Iter on the blocks to merge contiguous chunk */ - for (cur_blk = first_blk; cur_blk <= last_blk; ++cur_blk) { + /* + * Iterate through the filesystem's blocks, identifying "chunks" that + * are contiguous ranges of blocks that are in-use by the filesystem. + * Add each chunk to the sparse_file. + */ + for (cur_blk = ext2fs_get_block_bitmap_start2(fs->block_map); + cur_blk < fs_blks; ++cur_blk) { if (ext2fs_test_block_bitmap2(fs->block_map, cur_blk)) { + /* + * @cur_blk is in-use. Append it to the pending chunk + * if there is one, otherwise start a new chunk. + */ if (chunk_start == -1) { chunk_start = cur_blk; } else if (cur_blk - chunk_start + 1 == max_blk_per_chunk) { - add_chunk(fs, s, chunk_start, cur_blk); + /* + * Appending @cur_blk to the pending chunk made + * it reach the maximum length, so end it. + */ + add_chunk(fs, s, chunk_start, max_blk_per_chunk); chunk_start = -1; } } else if (chunk_start != -1) { - add_chunk(fs, s, chunk_start, cur_blk); + /* @cur_blk is not in-use, so end the pending chunk. */ + add_chunk(fs, s, chunk_start, cur_blk - chunk_start); chunk_start = -1; } } + /* If there's still a pending chunk, end it. */ if (chunk_start != -1) - add_chunk(fs, s, chunk_start, cur_blk - 1); + add_chunk(fs, s, chunk_start, cur_blk - chunk_start); ext2fs_free(fs); return s; From eb6c137c51dcda142637981413e9a45da81b34e9 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 23 Mar 2023 00:44:21 +0000 Subject: [PATCH 20/34] AOSP: ext2simg: fix same_file() to check st_dev File identity is determined by the combination of st_dev and st_ino, not by st_ino alone. This fixes a bug where ext2simg would needlessly make a copy of all the data when the input and output files happened to have the same st_ino. Fixes: db6f320912cf ("AOSP: android: add the ext2simg tool") Change-Id: I94e4bf57d9f91b31e5438768805e9f10bec3411d Signed-off-by: Eric Biggers From AOSP commit: 0749f83a2cf4c134a2403701ab78388500e53f76 --- contrib/android/ext2simg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/android/ext2simg.c b/contrib/android/ext2simg.c index 9ef54cfff..1bc23080c 100644 --- a/contrib/android/ext2simg.c +++ b/contrib/android/ext2simg.c @@ -189,7 +189,7 @@ static bool same_file(const char *in, const char *out) ext2fs_fatal(errno, "stat %s\n", in); if (lstat(out, &st2) == -1) ext2fs_fatal(errno, "stat %s\n", out); - return st1.st_ino == st2.st_ino; + return st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino; } int main(int argc, char *argv[]) From 0794e403fa7af9877efbf3cffd0bbe990e8c3671 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 23 Mar 2023 00:44:21 +0000 Subject: [PATCH 21/34] AOSP: ext2simg: use bool where appropriate For the values that get used as the 'bool' parameters of sparse_file_write(), use 'bool' in ext2simg too. No change in behavior. Change-Id: I05f7d6fd3027eb10231c035f9fdc8e946e2c4c90 Signed-off-by: Eric Biggers From AOSP commit: 2728c6e766976acbf442d3721f2d93960e13682e --- contrib/android/ext2simg.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/contrib/android/ext2simg.c b/contrib/android/ext2simg.c index 1bc23080c..efb4e41a2 100644 --- a/contrib/android/ext2simg.c +++ b/contrib/android/ext2simg.c @@ -24,16 +24,14 @@ #include struct { - int crc; - int sparse; - int gzip; + bool crc; + bool sparse; + bool gzip; char *in_file; char *out_file; bool overwrite_input; } params = { - .crc = 0, - .sparse = 1, - .gzip = 0, + .sparse = true, }; #define ext2fs_fatal(Retval, Format, ...) \ @@ -201,13 +199,13 @@ int main(int argc, char *argv[]) while ((opt = getopt(argc, argv, "czS")) != -1) { switch(opt) { case 'c': - params.crc = 1; + params.crc = true; break; case 'z': - params.gzip = 1; + params.gzip = true; break; case 'S': - params.sparse = 0; + params.sparse = false; break; default: usage(argv[0]); From c642b9c3a6119a701dc2b33f0d1f7e98e2a543aa Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 23 Mar 2023 00:44:21 +0000 Subject: [PATCH 22/34] AOSP: ext2simg: use a standard flexible array Use a standard flexible array instead of a nonstandard zero-length array. No change in behavior. Change-Id: Ifdce24f5d6e2471634bb785527def3fe8fefc202 Signed-off-by: Eric Biggers From AOSP commit: c88ea796fbf7f4c79155196ec483681b3733bbff --- contrib/android/ext2simg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/android/ext2simg.c b/contrib/android/ext2simg.c index efb4e41a2..9b594f371 100644 --- a/contrib/android/ext2simg.c +++ b/contrib/android/ext2simg.c @@ -58,7 +58,7 @@ static void usage(char *path) static struct buf_item { struct buf_item *next; - void *buf[0]; + void *buf[]; } *buf_list; /* From 087061b9cc1eba1965d6cd169183a10fc4165e85 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 23 Mar 2023 00:44:22 +0000 Subject: [PATCH 23/34] AOSP: ext2simg: clean up add_chunk() Remove a level of indentation, check a bool in the normal way, and simplify the linked list handling. No change in behavior. Change-Id: I12589a254f155b1c40418458a666b87c7ef5c1cf Signed-off-by: Eric Biggers From AOSP commit: 7d0f5c1aca332da22e4878f5825e0ffb5122f96b --- contrib/android/ext2simg.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/contrib/android/ext2simg.c b/contrib/android/ext2simg.c index 9b594f371..811c60d62 100644 --- a/contrib/android/ext2simg.c +++ b/contrib/android/ext2simg.c @@ -68,33 +68,27 @@ static struct buf_item { static void add_chunk(ext2_filsys fs, struct sparse_file *s, blk_t chunk_start, int num_blks) { - int retval; uint64_t len = (uint64_t)num_blks * fs->blocksize; int64_t offset = (int64_t)chunk_start * fs->blocksize; + struct buf_item *bi; + int retval; - if (params.overwrite_input == false) { + if (!params.overwrite_input) { if (sparse_file_add_file(s, params.in_file, offset, len, chunk_start) < 0) sparse_fatal("adding data to the sparse file"); - } else { - /* - * The input file will be overwritten, make a copy of - * the blocks - */ - struct buf_item *bi = calloc(1, sizeof(struct buf_item) + len); - if (buf_list == NULL) - buf_list = bi; - else { - bi->next = buf_list; - buf_list = bi; - } + return; + } - retval = io_channel_read_blk64(fs->io, chunk_start, num_blks, bi->buf); - if (retval < 0) - ext2fs_fatal(retval, "reading data from %s", params.in_file); + /* The input file will be overwritten, so make a copy of the blocks. */ + bi = calloc(1, sizeof(*bi) + len); + bi->next = buf_list; + buf_list = bi; + retval = io_channel_read_blk64(fs->io, chunk_start, num_blks, bi->buf); + if (retval < 0) + ext2fs_fatal(retval, "reading data from %s", params.in_file); - if (sparse_file_add_data(s, bi->buf, len, chunk_start) < 0) - sparse_fatal("adding data to the sparse file"); - } + if (sparse_file_add_data(s, bi->buf, len, chunk_start) < 0) + sparse_fatal("adding data to the sparse file"); } static void free_chunks(void) From be1e4efec9c511eb4a42d1bb9a60882c92cf0685 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 23 Mar 2023 00:44:22 +0000 Subject: [PATCH 24/34] AOSP: ext2simg: clean up integer types and check for too-large fs libsparse assumes 32-bit block numbers. Also, ext2simg might read nearly the entire filesystem into memory. Therefore, make ext2simg use appropriate integer types, and explicitly check for when the filesystem is too large or allocating memory failed. Change-Id: Ic415d0e974dce2b4ff6e7fa9265f6e86d371a274 Signed-off-by: Eric Biggers From AOSP commit: 8fff11068c100be627745967992fb88759dea9c1 --- contrib/android/ext2simg.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/contrib/android/ext2simg.c b/contrib/android/ext2simg.c index 811c60d62..13a9d5674 100644 --- a/contrib/android/ext2simg.c +++ b/contrib/android/ext2simg.c @@ -80,7 +80,11 @@ static void add_chunk(ext2_filsys fs, struct sparse_file *s, } /* The input file will be overwritten, so make a copy of the blocks. */ + if (len > SIZE_MAX - sizeof(*bi)) + sparse_fatal("filesystem is too large"); bi = calloc(1, sizeof(*bi) + len); + if (!bi) + sparse_fatal("out of memory"); bi->next = buf_list; buf_list = bi; retval = io_channel_read_blk64(fs->io, chunk_start, num_blks, bi->buf); @@ -102,6 +106,16 @@ static void free_chunks(void) } } +static blk_t fs_blocks_count(ext2_filsys fs) +{ + blk64_t blks = ext2fs_blocks_count(fs->super); + + /* libsparse assumes 32-bit block numbers. */ + if ((blk_t)blks != blks) + sparse_fatal("filesystem is too large"); + return blks; +} + static struct sparse_file *ext_to_sparse(const char *in_file) { errcode_t retval; @@ -118,7 +132,7 @@ static struct sparse_file *ext_to_sparse(const char *in_file) if (retval) ext2fs_fatal(retval, "while reading block bitmap of %s", in_file); - fs_blks = ext2fs_blocks_count(fs->super); + fs_blks = fs_blocks_count(fs); s = sparse_file_new(fs->blocksize, (uint64_t)fs_blks * fs->blocksize); if (!s) @@ -132,7 +146,7 @@ static struct sparse_file *ext_to_sparse(const char *in_file) * larger than INT32_MAX (32-bit _and_ 64-bit systems). * Make sure we do not create chunks larger than this limit. */ - int64_t max_blk_per_chunk = (INT32_MAX - 12) / fs->blocksize; + int32_t max_blk_per_chunk = (INT32_MAX - 12) / fs->blocksize; /* * Iterate through the filesystem's blocks, identifying "chunks" that From e5b299064df997dc6659659db345486e0c38aadc Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 23 Mar 2023 02:49:43 +0000 Subject: [PATCH 25/34] AOSP: ext2simg: fix error check of io_channel_read_blk64() Check the return value of io_channel_read_blk64() correctly, considering that it returns an errcode_t, which can be positive. Fixes: db6f320912cf ("AOSP: android: add the ext2simg tool") Change-Id: Iafc6c0169bc8ac79198f285da0246ff3b841ded8 Signed-off-by: Eric Biggers From AOSP commit: 60634ff32a0d8c0d7942c6e522a74a5051d4b6e9 --- contrib/android/ext2simg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/android/ext2simg.c b/contrib/android/ext2simg.c index 13a9d5674..d1b5dc4ee 100644 --- a/contrib/android/ext2simg.c +++ b/contrib/android/ext2simg.c @@ -88,7 +88,7 @@ static void add_chunk(ext2_filsys fs, struct sparse_file *s, bi->next = buf_list; buf_list = bi; retval = io_channel_read_blk64(fs->io, chunk_start, num_blks, bi->buf); - if (retval < 0) + if (retval) ext2fs_fatal(retval, "reading data from %s", params.in_file); if (sparse_file_add_data(s, bi->buf, len, chunk_start) < 0) From d553ae5bd39562bc02f791d9c353a530ca1c8a36 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 23 Mar 2023 02:52:09 +0000 Subject: [PATCH 26/34] AOSP: ext2simg: fix same_file() with symlinks Fix same_file() to use stat() instead of lstat() when checking the paths, so that symlinks are dereferenced. This is needed to be consistent with how the paths are actually accessed later. Otherwise, not all cases where the input and output file are the same are detected. Also just use the stat() result to check whether the output file exists, instead of using a separate call to access(). Fixes: db6f320912cf ("AOSP: android: add the ext2simg tool") Change-Id: Ie36981f9dbc19494732f518488a75fb92c0f0343 Signed-off-by: Eric Biggers From AOSP commit: 08c122f12fc231029a74c24b969e337203c7b6e2 --- contrib/android/ext2simg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/android/ext2simg.c b/contrib/android/ext2simg.c index d1b5dc4ee..2bf76b91a 100644 --- a/contrib/android/ext2simg.c +++ b/contrib/android/ext2simg.c @@ -188,13 +188,13 @@ static bool same_file(const char *in, const char *out) { struct stat st1, st2; - if (access(out, F_OK) == -1) - return false; - - if (lstat(in, &st1) == -1) + if (stat(in, &st1) == -1) ext2fs_fatal(errno, "stat %s\n", in); - if (lstat(out, &st2) == -1) + if (stat(out, &st2) == -1) { + if (errno == ENOENT) + return false; ext2fs_fatal(errno, "stat %s\n", out); + } return st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino; } From ab9302b087b086adc660c158f0c600b5ea765d63 Mon Sep 17 00:00:00 2001 From: "A. Cody Schuffelen" Date: Wed, 21 Jun 2023 18:19:08 -0700 Subject: [PATCH 27/34] AOSP: Compile libext2_blkid and libext2_uuid on Mac OS X for the Cuttlefish launcher Test: m libext2_blkid libext2_uuid Bug: 288342686 Change-Id: Ieaf2b73efe4b9e1ed0b52e12cf931d225cd8844d From AOSP commit: 24d1f08c6c42a292cb49c0526d2a39e889c50683 --- lib/blkid/Android.bp | 3 +++ lib/uuid/Android.bp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/blkid/Android.bp b/lib/blkid/Android.bp index 891c74a3a..89e39ab09 100644 --- a/lib/blkid/Android.bp +++ b/lib/blkid/Android.bp @@ -38,6 +38,9 @@ cc_library { shared_libs: ["libext2_uuid"], target: { + darwin: { + enabled: true, + }, windows: { enabled: true, }, diff --git a/lib/uuid/Android.bp b/lib/uuid/Android.bp index 3e6048d09..279592bd6 100644 --- a/lib/uuid/Android.bp +++ b/lib/uuid/Android.bp @@ -40,6 +40,9 @@ cc_library { "uuid_time.c", ], target: { + darwin: { + enabled: true, + }, windows: { enabled: true, }, From 4010ee526f67b2143868b3a826afca6c1d147c26 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 13 Oct 2023 12:53:10 -0700 Subject: [PATCH 28/34] AOSP: Make badblocks host-only It was being installed on some products when it shouldn't be. Bug: 205632228 Test: m installclean && m with aosp/2773149 Change-Id: I7f4642ba6fa8d97f7711b6df57c4e3fd781b40fd From AOSP commit: ecb8d2faa7411d9de228a3bd8b883ed2d5220188 --- misc/Android.bp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/misc/Android.bp b/misc/Android.bp index 0656bf484..a00ac9a87 100644 --- a/misc/Android.bp +++ b/misc/Android.bp @@ -191,9 +191,8 @@ cc_library_static { //######################################################################## // Build badblocks -cc_binary { +cc_binary_host { name: "badblocks", - host_supported: true, defaults: ["e2fsprogs-defaults"], srcs: ["badblocks.c"], From 90c534c7ee77a6431da206ad336e4404a1b93ae7 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Tue, 26 Mar 2024 10:35:02 -0700 Subject: [PATCH 29/34] AOSP: Make mke2fs/e2fsdroid available for vendor vendor_init needs to execute these binaries when converting partitions to EXT4. Test: th Bug: 293313353 Change-Id: I1fa49c1a0f802b3c36e96112ef262bae4d5d394a From AOSP commit: 0b54b8227815d447b52de76bb419735b21608941 --- contrib/android/Android.bp | 1 + lib/e2p/Android.bp | 1 + lib/et/Android.bp | 1 + lib/ext2fs/Android.bp | 1 + lib/support/Android.bp | 1 + misc/Android.bp | 2 ++ 6 files changed, 7 insertions(+) diff --git a/contrib/android/Android.bp b/contrib/android/Android.bp index 6c9dd5c5d..650824ce3 100644 --- a/contrib/android/Android.bp +++ b/contrib/android/Android.bp @@ -16,6 +16,7 @@ cc_binary { name: "e2fsdroid", host_supported: true, recovery_available: true, + vendor_available: true, defaults: ["e2fsprogs-defaults"], srcs: [ diff --git a/lib/e2p/Android.bp b/lib/e2p/Android.bp index bed92c120..02825cdb9 100644 --- a/lib/e2p/Android.bp +++ b/lib/e2p/Android.bp @@ -15,6 +15,7 @@ cc_library { host_supported: true, ramdisk_available: true, vendor_ramdisk_available: true, + vendor_available: true, recovery_available: true, unique_host_soname: true, defaults: ["e2fsprogs-defaults"], diff --git a/lib/et/Android.bp b/lib/et/Android.bp index 565feb594..5d4a129d2 100644 --- a/lib/et/Android.bp +++ b/lib/et/Android.bp @@ -18,6 +18,7 @@ cc_library { ramdisk_available: true, vendor_ramdisk_available: true, recovery_available: true, + vendor_available: true, unique_host_soname: true, defaults: ["e2fsprogs-defaults"], srcs: [ diff --git a/lib/ext2fs/Android.bp b/lib/ext2fs/Android.bp index db8b3b7e7..af4c2db94 100644 --- a/lib/ext2fs/Android.bp +++ b/lib/ext2fs/Android.bp @@ -19,6 +19,7 @@ cc_library { host_supported: true, ramdisk_available: true, vendor_ramdisk_available: true, + vendor_available: true, recovery_available: true, unique_host_soname: true, defaults: ["e2fsprogs-defaults"], diff --git a/lib/support/Android.bp b/lib/support/Android.bp index af9b28df6..ded3d4018 100644 --- a/lib/support/Android.bp +++ b/lib/support/Android.bp @@ -15,6 +15,7 @@ cc_library { host_supported: true, ramdisk_available: true, vendor_ramdisk_available: true, + vendor_available: true, recovery_available: true, unique_host_soname: true, defaults: ["e2fsprogs-defaults"], diff --git a/misc/Android.bp b/misc/Android.bp index a00ac9a87..846edf953 100644 --- a/misc/Android.bp +++ b/misc/Android.bp @@ -18,6 +18,7 @@ cc_library { name: "libext2_misc", host_supported: true, recovery_available: true, + vendor_available: true, defaults: ["e2fsprogs-defaults"], target: { @@ -58,6 +59,7 @@ cc_defaults { cc_binary { name: "mke2fs", host_supported: true, + vendor_available: true, defaults: ["mke2fs_defaults"], target: { host: { From eb5788f29c988bfb238c166623365010760aee9e Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Mon, 15 Apr 2024 23:07:31 +0000 Subject: [PATCH 30/34] AOSP: e2fsdroid: disable asan leak detection borked and breaks asan build Bugs: me Test: build with SANITIZE_HOST=address Change-Id: I9ae15ba328081c38e31c61834e80ce10765f9e30 From AOSP commit: eff2c071b546c3d2d3ea5eb89328babcc48e4bc2 --- contrib/android/e2fsdroid.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/android/e2fsdroid.c b/contrib/android/e2fsdroid.c index 6e5141409..82bd3408e 100644 --- a/contrib/android/e2fsdroid.c +++ b/contrib/android/e2fsdroid.c @@ -22,6 +22,11 @@ #define UID_GID_MAP_MAX_EXTENTS 340 #endif +// disable leak detection, breaks host asan build +const char *__asan_default_options() { + return "detect_leaks=0"; +} + static char *prog_name = "e2fsdroid"; static char *in_file; static char *block_list; From 0cdf513e82f80a091f8a2dc1883d2c86d0590ad1 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 1 May 2024 16:17:36 +0900 Subject: [PATCH 31/34] AOSP: Use no_full_install: true instead of installable: false So far, we have used `instalable: false` to avoid collision with the other modules that are installed to the same path. A typical example was and .microdroid. The latter is a modified version of the former for the inclusion of the microdroid image. They however both have the same instalation path (ex: system/bin) and stem (ex: foo) so that we can reference them using the same path regardless of whether we are in Android or microdroid. However, the use of `installable: false` for the purpose is actually incorrect, because `installable: false` also means, obviously, "this module shouldn't be installed". The only reason this incorrect way has worked is simply because packaging modules (ex: android_filesystem) didn't respect the property when gathering the modules. As packaging modules are now fixed to respect `installable: false`, we need a correct way of avoiding the collision. `no_full_install: true` is it. If a module has this property set to true, it is never installed to the full instal path like out/target/product//... It can be installed only via packaging modules. Bug: 338160898 Test: m Change-Id: Idb173a7e3528c96b23f857bb3bdf5f37e698c445 From AOSP commit: 21a895548df7de83ce1e2e146e1718e5f723af7f --- misc/Android.bp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/Android.bp b/misc/Android.bp index 846edf953..4edac23e2 100644 --- a/misc/Android.bp +++ b/misc/Android.bp @@ -128,7 +128,7 @@ cc_binary { symlinks: ["mkfs.ext4.microdroid"], }, }, - installable: false, + no_full_install: true, stem: "mke2fs", visibility: ["//packages/modules/Virtualization/microdroid"], } From 13b8af33186e61c5acd3f86fb58ca19e6681bc9f Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 20 May 2024 15:46:10 -0400 Subject: [PATCH 32/34] Update makefile dependencies Signed-off-by: Theodore Ts'o --- debugfs/Makefile.in | 18 ++++++++++-------- lib/support/Makefile.in | 9 +++++---- misc/Makefile.in | 17 +++++++++-------- tests/progs/Makefile.in | 9 +++++++++ 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/debugfs/Makefile.in b/debugfs/Makefile.in index b845a6f02..50a21e528 100644 --- a/debugfs/Makefile.in +++ b/debugfs/Makefile.in @@ -363,16 +363,18 @@ create_inode.o: $(srcdir)/../misc/create_inode.c $(top_builddir)/lib/config.h \ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/fiemap.h \ $(srcdir)/../misc/create_inode.h $(top_srcdir)/lib/e2p/e2p.h \ - $(top_srcdir)/lib/support/nls-enable.h + $(top_srcdir)/lib/support/nls-enable.h \ + $(srcdir)/../misc/create_inode_libarchive.h create_inode_libarchive.o: $(srcdir)/../misc/create_inode_libarchive.c \ - $(top_builddir)/lib/config.h $(srcdir)/../misc/create_inode_libarchive.h \ - $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2fs.h \ - $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \ - $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \ - $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(top_builddir)/lib/config.h $(top_builddir)/lib/dirpaths.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/../misc/create_inode.h \ + $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/e2p/e2p.h \ + $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext2fs.h \ + $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/ext2fs/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h \ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \ - $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/fiemap.h \ - $(srcdir)/../misc/create_inode.h $(top_srcdir)/lib/e2p/e2p.h \ + $(top_srcdir)/lib/ext2fs/bitops.h \ + $(srcdir)/../misc/create_inode_libarchive.h \ $(top_srcdir)/lib/support/nls-enable.h xattrs.o: $(srcdir)/xattrs.c $(top_builddir)/lib/config.h \ $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/support/cstring.h \ diff --git a/lib/support/Makefile.in b/lib/support/Makefile.in index b6229091f..3f26cd301 100644 --- a/lib/support/Makefile.in +++ b/lib/support/Makefile.in @@ -137,10 +137,11 @@ plausible.o: $(srcdir)/plausible.c $(top_builddir)/lib/config.h \ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \ $(top_srcdir)/lib/ext2fs/bitops.h $(srcdir)/nls-enable.h print_fs_flags.o: $(srcdir)/print_fs_flags.c $(top_builddir)/lib/config.h \ - $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2fs.h \ - $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \ - $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \ - $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(top_builddir)/lib/dirpaths.h $(srcdir)/print_fs_flags.h \ + $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \ + $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \ + $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h \ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \ $(top_srcdir)/lib/ext2fs/bitops.h profile.o: $(srcdir)/profile.c $(top_builddir)/lib/config.h \ diff --git a/misc/Makefile.in b/misc/Makefile.in index 37c269991..8769620a9 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -107,6 +107,7 @@ SRCS= $(srcdir)/tune2fs.c $(srcdir)/mklost+found.c $(srcdir)/mke2fs.c $(srcdir)/ $(srcdir)/filefrag.c $(srcdir)/base_device.c \ $(srcdir)/ismounted.c $(srcdir)/e2undo.c \ $(srcdir)/e2freefrag.c $(srcdir)/create_inode.c \ + $(srcdir)/create_inode_libarchive.c \ $(srcdir)/fuse2fs.c $(srcdir)/e2fuzz.c \ $(srcdir)/check_fuzzer.c \ $(srcdir)/../debugfs/journal.c $(srcdir)/../e2fsck/revoke.c \ @@ -857,16 +858,16 @@ create_inode.o: $(srcdir)/create_inode.c $(top_builddir)/lib/config.h \ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/fiemap.h \ $(srcdir)/create_inode.h $(top_srcdir)/lib/e2p/e2p.h \ - $(top_srcdir)/lib/support/nls-enable.h + $(top_srcdir)/lib/support/nls-enable.h $(srcdir)/create_inode_libarchive.h create_inode_libarchive.o: $(srcdir)/create_inode_libarchive.c \ - $(top_builddir)/lib/config.h \ - $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2fs.h \ - $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \ - $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \ - $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(top_builddir)/lib/config.h $(top_builddir)/lib/dirpaths.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(srcdir)/create_inode.h \ + $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/e2p/e2p.h \ + $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext2fs.h \ + $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/ext2fs/ext2_io.h \ + $(top_builddir)/lib/ext2fs/ext2_err.h \ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \ - $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/fiemap.h \ - $(srcdir)/create_inode.h $(top_srcdir)/lib/e2p/e2p.h \ + $(top_srcdir)/lib/ext2fs/bitops.h $(srcdir)/create_inode_libarchive.h \ $(top_srcdir)/lib/support/nls-enable.h fuse2fs.o: $(srcdir)/fuse2fs.c $(top_builddir)/lib/config.h \ $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2fs.h \ diff --git a/tests/progs/Makefile.in b/tests/progs/Makefile.in index 47d7adfa9..1a8e9299a 100644 --- a/tests/progs/Makefile.in +++ b/tests/progs/Makefile.in @@ -73,6 +73,15 @@ distclean: clean # Makefile dependencies follow. This must be the last section in # the Makefile.in file # +test_icount.o: $(srcdir)/test_icount.c $(top_builddir)/lib/config.h \ + $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \ + $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/et/com_err.h \ + $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ + $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \ + $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ + $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \ + $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/irel.h \ + $(top_srcdir)/lib/ext2fs/brel.h $(srcdir)/test_icount.h test_rel.o: $(srcdir)/test_rel.c $(top_builddir)/lib/config.h \ $(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/et/com_err.h \ $(top_srcdir)/lib/ss/ss.h $(top_builddir)/lib/ss/ss_err.h \ From fe84877cf1c237af04c383901acdd1d74f8ac7ff Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 20 May 2024 15:31:17 -0400 Subject: [PATCH 33/34] Update release notes, etc., for the 1.47.1 release Signed-off-by: Theodore Ts'o --- debian/changelog | 21 ++++++++++++++++++++- doc/RelNotes/v1.47.1.txt | 21 ++++++++++++++++++--- e2fsprogs.lsm | 2 +- version.h | 4 ++-- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6265c395d..7d8ba53d5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,24 @@ +e2fsprogs (1.47.1-1) unstable; urgency=medium + + * New upstream version + * Clarify the lsattr and mklost+found man pages that they are applicable + for ext2, ext3, and ext4 file systems and not just for ext2. (Closes: + #1041115) + * Replace the build-depend on pkg-config with pkgconf to fix a Lintian + warning. + * E2fsck will now perform more consistency checks on EA (extended + attribute value) inodes. + * Fix a big where e2fsck could potentially leak an acl block when + releasing an orphan inode. + * Avoid a divide by zero crash in libext2fs if the container + infrastructure, such as lxcfs, reports that the system has zero CPU's + via sysconf(_SC_NPROCESSORS_CONF). + + -- Theodore Y. Ts'o Mon, 20 May 2024 15:28:06 -0400 + e2fsprogs (1.47.1~rc2-1) unstable; urgency=medium + * New upstream version * Update Chinese, Czech, French, Polish Romainian, Swedish, and Ukrainian translations * Fix libarchive support in mke2fs on mips64el (Closes: #1070042) @@ -7,7 +26,7 @@ e2fsprogs (1.47.1~rc2-1) unstable; urgency=medium systemd. (Closes: #1070107) * Update to standards 4.7.0 - -- Theodore Y. Ts'o Wed, 01 May 2024 00:50:49 -0400 + -- Theodore Y. Ts'o Mon, 20 May 2024 15:24:47 -0400 e2fsprogs (1.47.1~rc1-3) unstable; urgency=medium diff --git a/doc/RelNotes/v1.47.1.txt b/doc/RelNotes/v1.47.1.txt index ccc46d68d..4e7d4557d 100644 --- a/doc/RelNotes/v1.47.1.txt +++ b/doc/RelNotes/v1.47.1.txt @@ -1,5 +1,5 @@ -E2fsprogs 1.47.1 (May 1, 2024) -============================== +E2fsprogs 1.47.1 (May 20, 2024) +=============================== Updates/Fixes since v1.47.0: @@ -60,6 +60,16 @@ In the case where e2fsck comes across an orphan file which is empty but the orphan_present feature is set, in preen mode, e2fsck will now clear the orphan_present feature flag silently. +E2fsck will now perform more consistency checks on EA (extended +attribute value) inodes. + +Fix a big where e2fsck could potentially leak an acl block when +releasing an orphan inode. + +Avoid a divide by zero crash in libext2fs if the container +infrastructure, such as lxcfs, reports that the system has zero CPU's +via sysconf(_SC_NPROCESSORS_CONF). + When resize2fs is performing an online resize, it's possible for reading the superblock can race with a kernel modifying the superblock with the checksum being invalid and causing the resize to fail with an bad @@ -123,7 +133,8 @@ systemd. (Addresses Debian Bug #1070107) Fixed/improved various Debian packaging issues. -Update and clarify various man pages. (Addresses Debian Bug #1038286) +Update and clarify various man pages. (Addresses Debian Bugs #1038286, +#1041115) @@ -169,6 +180,10 @@ Fix various portability problems in the regression test suite. Fix various sanitizer, static code analysis, and compiler warnings. +Synchronized changes from Android's AOSP e2fsprogs tree. + +Updated config.guess and config.sub with newer versions from the FSF. + Add Romainian translation. Update Chinese, Czech, French, Malay, Polish, Swedish, and Ukrainian diff --git a/e2fsprogs.lsm b/e2fsprogs.lsm index 116edf6c8..645a3fec6 100644 --- a/e2fsprogs.lsm +++ b/e2fsprogs.lsm @@ -1,7 +1,7 @@ Begin3 Title: EXT2 Filesystem utilities Version: 1.47.1 -Entered-date: 2024-05-01 +Entered-date: 2024-05-20 Description: The filesystem utilities for the EXT2, EXT3, and EXT4 filesystems, including e2fsck, mke2fs, dumpe2fs, and others. Keywords: utilities, filesystem, Ext2fs, ext3, ext4 diff --git a/version.h b/version.h index 6753cc7e8..af575f4da 100644 --- a/version.h +++ b/version.h @@ -9,5 +9,5 @@ * License v2. */ -#define E2FSPROGS_VERSION "1.47.1-rc2" -#define E2FSPROGS_DATE "01-May-2024" +#define E2FSPROGS_VERSION "1.47.1" +#define E2FSPROGS_DATE "20-May-2024" From 950a0d69c82b585aba30118f01bf80151deffe8c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 20 May 2024 22:52:47 -0400 Subject: [PATCH 34/34] ext4.5: add preprocessor hint This fixes a Lintian warning which is triggered by an arbtrary MANROFFSEQ='' environment variable: an.tmac::376: warning: tbl preprocessor failed, or it or soelim was not run; table(s) likely not rendered (TE macro called with TW register undefined) Signed-off-by: Theodore Ts'o --- misc/ext4.5.in | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/ext4.5.in b/misc/ext4.5.in index c835a3441..6fb67ebf8 100644 --- a/misc/ext4.5.in +++ b/misc/ext4.5.in @@ -1,3 +1,4 @@ +'\" t .\" -*- nroff -*- .\" Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved. .\" This file may be copied under the terms of the GNU Public License.