[PATCH v4 2/9] ocfs2: reject xattr names that overlap the header or entries

From: Siddh Raman Pant

Date: Sat Dec 05 2026 - 05:15:12 EST


ocfs2_validate_xattr_entries_flat() checks where a name ends, but
allows it to start inside the header or the entry array. A lookup
can then return entry metadata as the xattr value.

Require the name to start after the entry array and before the end
of xattr storage.

Fixes: cf1d6c763fbc ("ocfs2: Add extended attribute support")
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@xxxxxxxxxx>
---
fs/ocfs2/xattr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 5fc71934b069..2d32cba2a36f 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -1128,7 +1128,8 @@ static int ocfs2_validate_xattr_entries_flat(struct super_block *sb, u64 blkno,
if (ret)
return ret;

- if (name_offset > nv_limit ||
+ if (name_offset < struct_size(xh, xh_entries, xattr_count) ||
+ name_offset >= nv_limit ||
xe->xe_name_len > nv_limit - name_offset)
return ocfs2_error(sb,
"Invalid xattr in block %llu: entry %d name is out of bounds\n",
--
2.53.0