]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/dm-integrity-correctly-calculate-the-size-of-metadata-area.patch
Linux 5.0.19
[thirdparty/kernel/stable-queue.git] / queue-4.19 / dm-integrity-correctly-calculate-the-size-of-metadata-area.patch
1 From 30bba430ddf737978e40561198693ba91386dac1 Mon Sep 17 00:00:00 2001
2 From: Mikulas Patocka <mpatocka@redhat.com>
3 Date: Tue, 7 May 2019 14:28:35 -0400
4 Subject: dm integrity: correctly calculate the size of metadata area
5
6 From: Mikulas Patocka <mpatocka@redhat.com>
7
8 commit 30bba430ddf737978e40561198693ba91386dac1 upstream.
9
10 When we use separate devices for data and metadata, dm-integrity would
11 incorrectly calculate the size of the metadata device as if it had
12 512-byte block size - and it would refuse activation with larger block
13 size and smaller metadata device.
14
15 Fix this so that it takes actual block size into account, which fixes
16 the following reported issue:
17 https://gitlab.com/cryptsetup/cryptsetup/issues/450
18
19 Fixes: 356d9d52e122 ("dm integrity: allow separate metadata device")
20 Cc: stable@vger.kernel.org # v4.19+
21 Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
22 Signed-off-by: Mike Snitzer <snitzer@redhat.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 drivers/md/dm-integrity.c | 4 ++--
27 1 file changed, 2 insertions(+), 2 deletions(-)
28
29 --- a/drivers/md/dm-integrity.c
30 +++ b/drivers/md/dm-integrity.c
31 @@ -2557,7 +2557,7 @@ static int calculate_device_limits(struc
32 if (last_sector < ic->start || last_sector >= ic->meta_device_sectors)
33 return -EINVAL;
34 } else {
35 - __u64 meta_size = ic->provided_data_sectors * ic->tag_size;
36 + __u64 meta_size = (ic->provided_data_sectors >> ic->sb->log2_sectors_per_block) * ic->tag_size;
37 meta_size = (meta_size + ((1U << (ic->log2_buffer_sectors + SECTOR_SHIFT)) - 1))
38 >> (ic->log2_buffer_sectors + SECTOR_SHIFT);
39 meta_size <<= ic->log2_buffer_sectors;
40 @@ -3428,7 +3428,7 @@ try_smaller_buffer:
41 DEBUG_print(" journal_sections %u\n", (unsigned)le32_to_cpu(ic->sb->journal_sections));
42 DEBUG_print(" journal_entries %u\n", ic->journal_entries);
43 DEBUG_print(" log2_interleave_sectors %d\n", ic->sb->log2_interleave_sectors);
44 - DEBUG_print(" device_sectors 0x%llx\n", (unsigned long long)ic->device_sectors);
45 + DEBUG_print(" data_device_sectors 0x%llx\n", (unsigned long long)ic->data_device_sectors);
46 DEBUG_print(" initial_sectors 0x%x\n", ic->initial_sectors);
47 DEBUG_print(" metadata_run 0x%x\n", ic->metadata_run);
48 DEBUG_print(" log2_metadata_run %d\n", ic->log2_metadata_run);