From 3c042605db2238c09f56c197a58624d4e10c5d2e Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 6 Jun 2018 15:27:13 +0800 Subject: btrfs-progs: Get rid of the confusing btrfs_file_extent_inline_len() [BUG] If one uncompressed inline extent has incorrect ram_bytes, neither btrfs check nor dump-tree could detect such corruption. [CAUSE] Every caller tries to read inline extent ram_bytes is using btrfs_file_extent_inline_len(), other than directly calling btrfs_file_extent_ram_bytes(). For compressed extent, it's just calling btrfs_file_extent_ram_bytes(). However for uncompressed extent, it falls back to btrfs_file_extent_inline_item_len(), makes us unable to detect anything wrong in ram_bytes. [FIX] Just get rid of such confusing btrfs_file_extent_inline_len() function. Reported-by: Steve Leung Tested-by: Steve Leung Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index f5e645c4..056be104 100644 --- a/file.c +++ b/file.c @@ -255,8 +255,7 @@ int btrfs_read_file(struct btrfs_root *root, u64 ino, u64 start, int len, /* Inline extent, one inode should only one inline extent */ if (btrfs_file_extent_type(leaf, fi) == BTRFS_FILE_EXTENT_INLINE) { - extent_len = btrfs_file_extent_inline_len(leaf, slot, - fi); + extent_len = btrfs_file_extent_ram_bytes(leaf, fi); if (extent_start + extent_len <= start) goto next; read_extent_buffer(leaf, dest, -- cgit v1.2.3