summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2026-09-03 17:24:16 +0100
committerDavid Sterba <dsterba@suse.com>2026-09-07 18:36:38 +0200
commit09f1294ee2abee7fe1c2d600671498b7642e0fe0 (patch)
tree49f8fcc12a0e853e6f4a30fb71cd14f460148289
parentb18f0f8334e6d7e4ed4baf1f404658537659cb57 (diff)
downloadlinux-09f1294ee2abee7fe1c2d600671498b7642e0fe0.tar.gz
linux-09f1294ee2abee7fe1c2d600671498b7642e0fe0.zip
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 3dc22abc21f5 ("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>
-rw-r--r--fs/btrfs/tree-checker.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 83f7b0aaab21..ab5abbb475e2 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -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",