From: Yan, Zheng Date: Mon, 29 Aug 2011 01:25:53 +0000 (+0800) Subject: btrfs: check file extent backref offset underflow X-Git-Tag: v2.6.39-400.9.0~845^2~55 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4dfb74768c9a7342fef0d7c7a6f30c7ca4468733;p=users%2Fjedix%2Flinux-maple.git btrfs: check file extent backref offset underflow 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 (cherry picked from commit 84850e8d8a5ec7b9d3c47d224e9a10c9da52ff1b) --- diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 10af6a0e08651..24d654ce7a061 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -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;