]> git.itanic.dy.fi Git - linux-stable/commitdiff
dm integrity: fix a crash if "recalculate" used without "internal_hash"
authorMikulas Patocka <mpatocka@redhat.com>
Wed, 20 Jan 2021 11:02:31 +0000 (06:02 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jan 2021 10:47:41 +0000 (11:47 +0100)
commit 2d06dfecb132a1cc2e374a44eae83b5c4356b8b4 upstream.

Recalculate can only be specified with internal_hash.

Cc: stable@vger.kernel.org # v4.19+
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-integrity.c

index 25efe382e78fa2af75322c3b1fe718cd3897e542..57f66f2ad98dc915a6ed10137013ce92b1451bc1 100644 (file)
@@ -4059,6 +4059,12 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
                        r = -ENOMEM;
                        goto bad;
                }
+       } else {
+               if (ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING)) {
+                       ti->error = "Recalculate can only be specified with internal_hash";
+                       r = -EINVAL;
+                       goto bad;
+               }
        }
 
        ic->bufio = dm_bufio_client_create(ic->meta_dev ? ic->meta_dev->bdev : ic->dev->bdev,