]> 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2020 08:50:17 +0000 (10:50 +0200)
commitef25dd9b227cd1ec3cb6a4bbf62691aff610b4aa
treecbe23853a7ab74bd83a9c3fb1ec75d85a13abc31
parentb3b78a6eb1e95d83ae3075974af2e88104df98e4
dm clone: Add overflow check for number of regions

commit ba39a7ceb8579e898d6ea6d84bdedc881ce0031d upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-clone-target.c