dm clone: Add missing casts to prevent overflows and data corruption
authorNikos Tsironis <ntsironis@arrikto.com>
Fri, 27 Mar 2020 14:01:10 +0000 (16:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2020 08:50:24 +0000 (10:50 +0200)
commit33344a7661a1e4780f3513505e0b354c59cfa76b
treefa6ccb00f8a8a69da636b59d6f3ad340b4d333dd
parent2d7eb7ee36a3600118edc328b9aef9444a89f401
dm clone: Add missing casts to prevent overflows and data corruption

[ Upstream commit 9fc06ff56845cc5ccafec52f545fc2e08d22f849 ]

Add missing casts when converting from regions to sectors.

In case BITS_PER_LONG == 32, the lack of the appropriate casts can lead
to overflows and miscalculation of the device sector.

As a result, we could end up discarding and/or copying the wrong parts
of the device, thus corrupting the device's data.

Fixes: 7431b7835f55 ("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: Sasha Levin <sashal@kernel.org>
drivers/md/dm-clone-target.c