]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
Change the xattr entry hash to use an unsighed char by default
authorTheodore Ts'o <tytso@mit.edu>
Sat, 28 Jan 2023 06:22:29 +0000 (01:22 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 30 Jan 2023 04:16:38 +0000 (23:16 -0500)
commit38e988643a085ee804b5274fc39bc8a4befe6106
tree303d51a57af6540f22b1baf724c1e068b9005afe
parent04cee87699b32b1c4e0c41ffc5ca4540e7a3232f
Change the xattr entry hash to use an unsighed char by default

Starting in Linux 6.2, char is forced to always unsigned when
compiling the kernel, even on those platforms (such as x86) where char
was traditionally signed.  This exposed a bug in ext4, where when
calculating the extended attribute entry hash, we used a char value
from the extended attribute name.  This resulted with the entry hash,
which is stored on-disk, to variable depending on whether the plaform
used a signed or unsigned char.

Fortunately, the xattr names tend to be ASCII characters with the 8th
bit zero, so it wasn't noticed two decades (this bugs dates back to
the introduction of extended attribute support to ext2 in 2.5.46).
However, when this change was made in v6.2-rc1, the inconsistency
between the extended attribute hash calculated by e2fsprogs (which was
still using a signed char on x86) was different from an x86 kernel,
and this triggered a test failure in generic/454.

This was fixed in kernel commit f3bbac32475b (" ext4: deal with legacy
signed xattr name hash values"), where Linus decreed that it wasn't
worth it to fix this the same way we had addressed has used by the
dir_index feature.  Instead, starting in the 6.2 kernel, ext4 will
accept both the hash calculated using signed and unsigned chars, but
set the entry hash using the unsigned char.  This commit makes
e2fsprogs follow suit.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass1.c
lib/ext2fs/ext2fs.h
lib/ext2fs/ext_attr.c
tests/f_ea_signed_hash/expect.1 [new file with mode: 0644]
tests/f_ea_signed_hash/image.gz [new file with mode: 0644]
tests/f_ea_signed_hash/script [new file with mode: 0644]
tests/f_ea_unsigned_hash/expect.1 [new file with mode: 0644]
tests/f_ea_unsigned_hash/image.gz [new file with mode: 0644]
tests/f_ea_unsigned_hash/script [new file with mode: 0644]