CVE-2026-99964: ocfs2: use the stored hash when checking xattr bucket collision
In the Linux kernel, the following vulnerability has been resolved:
ocfs2: use the stored hash when checking xattr bucket collision
ocfs2checkxattrbucketcollision() decides whether splitting a full bucket can make room for the entry being set by recomputing the hash of the name:
u32 namehash = ocfs2xattrnamehash(inode, name, strlen(name));
if (namehash != le32tocpu(xh->xhentries[0].xenamehash)) return 0;
For a new entry that is the hash it will be stored under, so comparing it is correct. An existing entry keeps the hash it already has: an update never rewrites xenamehash, since ocfs2xaaddentry() is the only writer of that field for a real entry and ocfs2xaprepareentry() calls it only when loc->xlentry is NULL.
An entry stored by a kernel that sign-extended the name bytes when hashing can still be updated, because ocfs2xattrfindentry() searches a non-indexed xattr block by memcmp on the name and never looks at xenamehash. Growing it past the space left in the block converts the block into a tree, ocfs2cpxattrblocktobucket() fills the bucket in stored hash order, and the update runs out of room in the bucket too. The collision check then compares the unsigned hash against the legacy hashes in the bucket and reports no collision.
ocfs2xattrsetentryindexblock() goes on to allocate a bucket that ocfs2dividexattrbucket() cannot fill: a bucket whose entries all share one hash has no divide position, so all it does is append an empty bucket with a sentinel hash one above the last entry's.
The re-search that follows depends on where the unsigned hash sorts. Below the legacy ones, it comes back to the full bucket and the set fails with -ENOSPC, having grown the tree for nothing. Above them, it lands on the new empty bucket, which ocfs2xattrbucketfind() handles explicitly and ocfs2findxeinbucket() scans zero times, so the set stores a second copy of the entry under the unsigned hash and returns success. The original stays in the full bucket, listxattr reports the name twice and getxattr returns the new copy.
Pass the hash the entry is stored under instead: the stored one for an existing entry, the unsigned one for a new entry. A tree whose entries are all stored under the unsigned hash sees no change, since there the two are the same value.