]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit9e77d66d3ef7c6309d005a323f4b724b04b4f607
treefa6ccb00f8a8a69da636b59d6f3ad340b4d333dd
parent66839c462af1980b7642e6f6c14da71d09545088
dm clone: Add missing casts to prevent overflows and data corruption

[ Upstream commit 98e3f61aadd69a5122353ec652166af58d8bc5a3 ]

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