• Filipe Manana's avatar
    btrfs: fix off-by-one when checking chunk map includes logical address · 5fba5a57
    Filipe Manana authored
    
    
    At btrfs_get_chunk_map() we get the extent map for the chunk that contains
    the given logical address stored in the 'logical' argument. Then we do
    sanity checks to verify the extent map contains the logical address. One
    of these checks verifies if the extent map covers a range with an end
    offset behind the target logical address - however this check has an
    off-by-one error since it will consider an extent map whose start offset
    plus its length matches the target logical address as inclusive, while
    the fact is that the last byte it covers is behind the target logical
    address (by 1).
    
    So fix this condition by using '<=' rather than '<' when comparing the
    extent map's "start + length" against the target logical address.
    
    CC: stable@vger.kernel.org # 4.14+
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    5fba5a57
volumes.c 216 KB