dm flakey: clone pages on write bio before corrupting them
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 1 May 2023 13:19:45 +0000 (09:19 -0400)
committerMike Snitzer <snitzer@kernel.org>
Fri, 16 Jun 2023 22:24:13 +0000 (18:24 -0400)
commit1d9a943898533e83f20370c0e1448d606627522e
treec7dbbe4101e1784fa27e4c9c5d387dad31b209ca
parent5054e778fcd9cd29ddaa8109077cd235527e4f94
dm flakey: clone pages on write bio before corrupting them

dm-flakey has an option to corrupt write bios. It corrupts the memory that
is being written. This can cause system crashes or security bugs - for
example, if the user writes a shared library code with O_DIRECT flag to a
dm-flakey device, it corrupts the memory for all users that have the
shared library mapped.

Fix this bug by cloning the bio and corrupting the clone rather than
the original.

Also drop the test for ZERO_PAGE(0) - it can't happen because we write
the cloned pages.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-flakey.c