dm integrity: conditionally disable "recalculate" feature
authorMikulas Patocka <mpatocka@redhat.com>
Wed, 20 Jan 2021 18:59:11 +0000 (13:59 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jan 2021 10:54:55 +0000 (11:54 +0100)
commit9cb683c3c471f99018891f7551390217de4b0a8f
tree0600004b5eff70a2785f660fc54a8e495f5e19d9
parentde4fabc02a58daf85b85cc3e770835e4d77bbc54
dm integrity: conditionally disable "recalculate" feature

commit 5c02406428d5219c367c5f53457698c58bc5f917 upstream.

Otherwise a malicious user could (ab)use the "recalculate" feature
that makes dm-integrity calculate the checksums in the background
while the device is already usable. When the system restarts before all
checksums have been calculated, the calculation continues where it was
interrupted even if the recalculate feature is not requested the next
time the dm device is set up.

Disable recalculating if we use internal_hash or journal_hash with a
key (e.g. HMAC) and we don't have the "legacy_recalculate" flag.

This may break activation of a volume, created by an older kernel,
that is not yet fully recalculated -- if this happens, the user should
add the "legacy_recalculate" flag to constructor parameters.

Cc: stable@vger.kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reported-by: Daniel Glockner <dg@emlix.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/admin-guide/device-mapper/dm-integrity.rst
drivers/md/dm-integrity.c