Skip to content

Commit

Permalink
btrfs: check file extent backref offset underflow
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yan, Zheng authored and David Sterba committed Oct 20, 2011
1 parent 016fc6a commit 84850e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/btrfs/relocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 84850e8

Please sign in to comment.