]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: fix off-by-one when checking chunk map includes logical address
authorFilipe Manana <fdmanana@suse.com>
Tue, 21 Nov 2023 13:38:32 +0000 (13:38 +0000)
committerDavid Sterba <dsterba@suse.com>
Thu, 23 Nov 2023 21:27:42 +0000 (22:27 +0100)
commit5fba5a571858ce2d787fdaf55814e42725bfa895
treedf880320cc0d084fc039382b77eef03719cc815b
parentf91192cd68591c6b037da345bc9fcd5e50540358
btrfs: fix off-by-one when checking chunk map includes logical address

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: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c