]> git.baikalelectronics.ru Git - kernel.git/commit
dm clone: Add overflow check for number of regions
authorNikos Tsironis <ntsironis@arrikto.com>
Fri, 27 Mar 2020 14:01:09 +0000 (16:01 +0200)
committerMike Snitzer <snitzer@redhat.com>
Fri, 27 Mar 2020 18:41:46 +0000 (14:41 -0400)
commitba39a7ceb8579e898d6ea6d84bdedc881ce0031d
treece0a92f40d99c7c2905bd1b6000e23632b5a8219
parentec2dbfed663f45fd39081aa698fa7f9614fea532
dm clone: Add overflow check for number of regions

Add overflow check for clone->nr_regions variable, which holds the
number of regions of the target.

The overflow can occur with sufficiently large devices, if BITS_PER_LONG
== 32. E.g., if the region size is 8 sectors (4K), the overflow would
occur for device sizes > 34359738360 sectors (~16TB).

This could result in multiple device sectors wrongly mapping to the same
region number, due to the truncation from 64 bits to 32 bits, which
would lead to data corruption.

Fixes: 926c5639707c ("dm: add clone target")
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Nikos Tsironis <ntsironis@arrikto.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-clone-target.c