btrfs: tree-checker: validate name length for extref items

We are validating the name length of inode ref items, but we miss the same
validation for extref items. Sashiko pointed this out while reviewing
other patch. Add the missing validation, similar to what was done in commit
3dc22abc21 ("btrfs: tree-checker: validate INODE_REF's namelen").

Reviewed-by: Boris Burkov <boris@bur.io>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Filipe Manana 2026-09-03 17:24:16 +01:00 committed by David Sterba
parent b18f0f8334
commit 09f1294ee2

View File

@ -1990,6 +1990,13 @@ static int check_inode_extref(struct extent_buffer *leaf,
}
namelen = btrfs_inode_extref_name_len(leaf, extref);
if (unlikely(namelen == 0 || namelen > BTRFS_NAME_LEN)) {
inode_ref_err(leaf, slot,
"invalid inode extref name length, has %u expect [1, %u]",
namelen, BTRFS_NAME_LEN);
return -EUCLEAN;
}
if (unlikely(ptr + sizeof(*extref) + namelen > end)) {
inode_ref_err(leaf, slot,
"inode extref overflow, ptr %lu end %lu namelen %u",