]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: check for extended attributes with ea_inode but a zero ea_size
authorTheodore Ts'o <tytso@mit.edu>
Fri, 26 Sep 2025 01:11:52 +0000 (21:11 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 11 Nov 2025 18:44:19 +0000 (13:44 -0500)
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 <tytso@mit.edu>
e2fsck/pass1.c
tests/f_ea_inode_self_ref/expect.1
tests/f_ea_zero_size/expect.1 [new file with mode: 0644]
tests/f_ea_zero_size/expect.2 [new file with mode: 0644]
tests/f_ea_zero_size/image.gz [new file with mode: 0644]
tests/f_ea_zero_size/name [new file with mode: 0644]

index e7d5d0ae90d97e34fd4bf548cc62a1a28af70bc4..fdde76cc2263f673fa40aaa15995c6573e89b4e2 100644 (file)
@@ -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) {
index f94c04d966e5bb77c57b986ce58938080391c837..339df1844894660b6c65e1319ca4bc50badb3ae7 100644 (file)
@@ -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 (file)
index 0000000..2aa0ae6
--- /dev/null
@@ -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 (file)
index 0000000..17211da
--- /dev/null
@@ -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 (file)
index 0000000..fff5b20
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 (file)
index 0000000..95d9893
--- /dev/null
@@ -0,0 +1 @@
+zero extended attribute size with ea_inode