diff options
| author | Joseph Qi <joseph.qi@linux.alibaba.com> | 2026-10-08 20:27:43 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-08 23:06:53 -0700 |
| commit | 798a826532c05994f7bf1c111207311338b66d44 (patch) | |
| tree | 7ddea8e46fc19e209c73b1595d016617d9649390 /tools/lib/python/kdoc/python_version.py | |
| parent | d0f77a722746c9cb2153dc9c275f5c1218ffa841 (diff) | |
| download | linux-next-798a826532c05994f7bf1c111207311338b66d44.tar.gz linux-next-798a826532c05994f7bf1c111207311338b66d44.zip | |
ocfs2: deal with legacy signed xattr name hash values
Commit 3bc753c06dd0 ("kbuild: treat char as always unsigned") set
-funsigned-char globally, which changed the result of the naked 'char'
load in ocfs2_xattr_name_hash():
hash = (hash << OCFS2_HASH_SHIFT) ^
(hash >> (8*sizeof(hash) - OCFS2_HASH_SHIFT)) ^
*name++;
A name byte >= 0x80 used to sign-extend and now zero-extends, so the hash
no longer matches the xe_name_hash an older kernel stored. An indexed
xattr tree is searched by that hash alone, and both the bucket binary
search and the entry scan within it stop as soon as the wanted hash falls
below an entry's, so the entry is never reached: getxattr, setxattr and
removexattr return -ENODATA for a name that listxattr still lists.
Search with the current unsigned hash and, on a miss, retry with the
legacy signed one, as ext4 does in commit f3bbac32475b2 ("ext4: deal with
legacy signed xattr name hash values"). New entries are always stored
under the unsigned hash. Skip the retry when the two hashes are equal, so
that a miss on an ASCII name does not walk the tree twice.
A miss is not empty handed: ocfs2_xattr_bucket_find() leaves xs->bucket
holding the bucket a new entry would go into. So after a double miss drop
it and search once more with the unsigned hash, otherwise a new entry
would be placed by its legacy hash and stored under its unsigned one,
breaking the ordering the search relies on.
Only indexed trees are affected; inline xattrs and non-indexed xattr
blocks compare names with memcmp and never look at the hash.
Also spell out the signedness instead of leaving the current hash to
-funsigned-char, as commit 854f0912f813 ("ext4: make xattr char
unsignedness in hash explicit") did, so that both variants stay correct if
this is backported to a kernel without the flag.
Exposed-by: 3bc753c06dd0 ("kbuild: treat char as always unsigned")
Link: https://lore.kernel.org/20261008122743.616779-2-joseph.qi@linux.alibaba.com
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: Anderson Ferneda <anderson.ferneda@braza.com.br>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: <stable@vger.kernel.org> # 6.2+
Diffstat (limited to 'tools/lib/python/kdoc/python_version.py')
0 files changed, 0 insertions, 0 deletions
