From: Theodore Ts'o Date: Fri, 26 Sep 2025 01:11:52 +0000 (-0400) Subject: e2fsck: check for extended attributes with ea_inode but a zero ea_size X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e4c9d0111e2894c19e46403119de5e4d6e576c12;p=thirdparty%2Fe2fsprogs.git e2fsck: check for extended attributes with ea_inode but a zero ea_size The combination of e_value_inum != 0 and e_value_size == 0 is invalid and can trigger kernel warnings. This should only happen with delierately corrupted extended attribute entries; so if we come across one, just clear the xattrs. Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index e7d5d0ae9..fdde76cc2 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -343,6 +343,12 @@ static problem_t check_large_ea_inode(e2fsck_t ctx, e2fsck_read_inode(ctx, entry->e_value_inum, &inode, "pass1"); + if (entry->e_value_size == 0 || + entry->e_value_size != EXT2_I_SIZE(&inode)) { + pctx->num = entry->e_value_size; + return PR_1_ATTR_VALUE_SIZE; + } + retval = ext2fs_ext_attr_hash_entry3(ctx->fs, entry, NULL, &hash, &signed_hash); if (retval) { diff --git a/tests/f_ea_inode_self_ref/expect.1 b/tests/f_ea_inode_self_ref/expect.1 index f94c04d96..339df1844 100644 --- a/tests/f_ea_inode_self_ref/expect.1 +++ b/tests/f_ea_inode_self_ref/expect.1 @@ -1,7 +1,7 @@ Pass 1: Checking inodes, blocks, and sizes Inode 16 has INLINE_DATA_FL flag but extended attribute not found. Truncate? yes -Extended attribute in inode 16 has a hash (553648128) which is invalid +Extended attribute in inode 16 has a value size (0) which is invalid Clear? yes Pass 2: Checking directory structure diff --git a/tests/f_ea_zero_size/expect.1 b/tests/f_ea_zero_size/expect.1 new file mode 100644 index 000000000..2aa0ae653 --- /dev/null +++ b/tests/f_ea_zero_size/expect.1 @@ -0,0 +1,30 @@ +Pass 1: Checking inodes, blocks, and sizes +Extended attribute in inode 12 has a value size (0) which is invalid +Clear? yes + +Inode 12, i_blocks is 8, should be 0. Fix? yes + +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Regular filesystem inode 14 has EA_INODE flag set. Clear? yes + +Unattached inode 14 +Connect to /lost+found? yes + +Inode 14 ref count is 2, should be 1. Fix? yes + +Pass 5: Checking group summary information +Block bitmap differences: -13 +Fix? yes + +Free blocks count wrong for group #0 (46, counted=47). +Fix? yes + +Free blocks count wrong (46, counted=47). +Fix? yes + + +test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** +test_filesys: 21/32 files (0.0% non-contiguous), 17/64 blocks +Exit status is 1 diff --git a/tests/f_ea_zero_size/expect.2 b/tests/f_ea_zero_size/expect.2 new file mode 100644 index 000000000..17211daf9 --- /dev/null +++ b/tests/f_ea_zero_size/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: 21/32 files (0.0% non-contiguous), 17/64 blocks +Exit status is 0 diff --git a/tests/f_ea_zero_size/image.gz b/tests/f_ea_zero_size/image.gz new file mode 100644 index 000000000..fff5b203f Binary files /dev/null and b/tests/f_ea_zero_size/image.gz differ diff --git a/tests/f_ea_zero_size/name b/tests/f_ea_zero_size/name new file mode 100644 index 000000000..95d9893c1 --- /dev/null +++ b/tests/f_ea_zero_size/name @@ -0,0 +1 @@ +zero extended attribute size with ea_inode