Skip to content

Commit 96fa515

Browse files
adam900710kdave
authored andcommitted
btrfs: tree-checker: fix the incorrect inode ref size check
[BUG] Inside check_inode_ref(), we need to make sure every structure, including the btrfs_inode_extref header, is covered by the item. But our code is incorrectly using "sizeof(iref)", where @iref is just a pointer. This means "sizeof(iref)" will always be "sizeof(void *)", which is much smaller than "sizeof(struct btrfs_inode_extref)". This will allow some bad inode extrefs to sneak in, defeating tree-checker. [FIX] Fix the typo by calling "sizeof(*iref)", which is the same as "sizeof(struct btrfs_inode_extref)", and will be the correct behavior we want. Fixes: 71bf92a ("btrfs: tree-checker: Add check for INODE_REF") CC: [email protected] # 6.1+ Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Filipe Manana <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 80eb65c commit 96fa515

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/tree-checker.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,10 +1756,10 @@ static int check_inode_ref(struct extent_buffer *leaf,
17561756
while (ptr < end) {
17571757
u16 namelen;
17581758

1759-
if (unlikely(ptr + sizeof(iref) > end)) {
1759+
if (unlikely(ptr + sizeof(*iref) > end)) {
17601760
inode_ref_err(leaf, slot,
17611761
"inode ref overflow, ptr %lu end %lu inode_ref_size %zu",
1762-
ptr, end, sizeof(iref));
1762+
ptr, end, sizeof(*iref));
17631763
return -EUCLEAN;
17641764
}
17651765

0 commit comments

Comments
 (0)