[PATCH v3 1/9] ocfs2: reject local xattrs with both an empty name and an empty value
From: Siddh Raman Pant
Date: Sat Dec 05 2026 - 03:09:35 EST
ocfs2_validate_xattr_entries_flat() allows xe_name_offset to equal
region_size when both the name and local value are empty. Converting
the block to a bucket moves that offset to OCFS2_XATTR_BUCKET_SIZE.
If the entry survives the update, ocfs2_validate_xattr_bucket()
rejects it on the next read and makes the filesystem read-only.
Even an empty pair that starts inside its block can reach the end.
ocfs2_xa_block_wipe_namevalue() can shift it there when removing
another entry. ocfs2_defrag_xattr_bucket() can also place it there
when packing a bucket, and the next lookup uses a nonexistent buffer.
Reject an empty local pair in ocfs2_validate_xattr_entry(), which
checks both blocks and buckets. An ACL has an empty name and a
value. A named attribute can still have an empty value.
A Sashiko review of another patch exposed this missing bounds check.
Fixes: 012255961c9e ("ocfs2: Enable xattr set in index btree")
Reported-by: Sashiko AI <sashiko-bot@xxxxxxxxxx>
Link: https://sashiko.dev/#/patchset/20261204120536.161006-1-siddh.raman.pant@xxxxxxxxxx?part=1
Link: https://sashiko.dev/#/patchset/20261204152650.349289-1-siddh.raman.pant@xxxxxxxxxx?part=2
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@xxxxxxxxxx>
---
fs/ocfs2/xattr.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 71e5986bafaa..5fc71934b069 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -242,6 +242,11 @@ static int ocfs2_validate_xattr_entry(struct super_block *sb, u64 blkno,
{
u64 value_len = le64_to_cpu(xe->xe_value_size);
+ if (ocfs2_xattr_is_local(xe) && !xe->xe_name_len && !value_len)
+ return ocfs2_error(sb,
+ "Xattr in block %llu has neither a name nor a value\n",
+ (unsigned long long)blkno);
+
if (value_len > OCFS2_XATTR_INLINE_SIZE &&
ocfs2_xattr_is_local(xe))
return ocfs2_error(sb,
--
2.53.0