]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
btrfs: check file extent backref offset underflow
authorYan, Zheng <zheng.z.yan@intel.com>
Mon, 29 Aug 2011 01:25:53 +0000 (09:25 +0800)
committerDavid Sterba <dsterba@suse.cz>
Thu, 20 Oct 2011 16:10:31 +0000 (18:10 +0200)
Offset field in data extent backref can underflow if clone range ioctl
is used. We can reliably detect the underflow because max file size is
limited to 2^63 and max data extent size is limited by block group size.

Signed-off-by: Zheng Yan <zheng.z.yan@intel.com>
fs/btrfs/relocation.c

index 10af6a0e08651c281ed0484dd5aacff9b17738d5..24d654ce7a061206347173c407196fdcf0bc8742 100644 (file)
@@ -3322,8 +3322,11 @@ static int find_data_references(struct reloc_control *rc,
        }
 
        key.objectid = ref_objectid;
-       key.offset = ref_offset;
        key.type = BTRFS_EXTENT_DATA_KEY;
+       if (ref_offset > ((u64)-1 << 32))
+               key.offset = 0;
+       else
+               key.offset = ref_offset;
 
        path->search_commit_root = 1;
        path->skip_locking = 1;