summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-crypt.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-16 18:55:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-16 18:55:48 -0400
commit311f71281ff4b24f86a39c60c959f485c68a6d36 (patch)
tree05983f559c3e7eb7fc2e0cdab5d14e2ecaf1bf5a /drivers/md/dm-crypt.c
parent7878c231dae05bae9dcf2ad4d309f02e51625033 (diff)
parent8454fca4f53bbe5e0a71613192674c8ce5c52318 (diff)
Merge tag 'for-5.2/dm-changes-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper updates from Mike Snitzer: - Improve DM snapshot target's scalability by using finer grained locking. Requires some list_bl interface improvements. - Add ability for DM integrity to use a bitmap mode, that tracks regions where data and metadata are out of sync, instead of using a journal. - Improve DM thin provisioning target to not write metadata changes to disk if the thin-pool and associated thin devices are merely activated but not used. This avoids metadata corruption due to concurrent activation of thin devices across different OS instances (e.g. split brain scenarios, which ultimately would be avoided if proper device filters were used -- but not having proper filtering has proven a very common configuration mistake) - Fix missing call to path selector type->end_io in DM multipath. This fixes reported performance problems due to inaccurate path selector IO accounting causing an imbalance of IO (e.g. avoiding issuing IO to particular path due to it seemingly being heavily used). - Fix bug in DM cache metadata's loading of its discard bitset that could lead to all cache blocks being discarded if the very first cache block was discarded (thankfully in practice the first cache block is generally in use; be it FS superblock, partition table, disk label, etc). - Add testing-only DM dust target which simulates a device that has failing sectors and/or read failures. - Fix a DM init error path reference count hang that caused boot hangs if user supplied malformed input on kernel commandline. - Fix a couple issues with DM crypt target's logging being overly verbose or lacking context. - Various other small fixes to DM init, DM multipath, DM zoned, and DM crypt. * tag 'for-5.2/dm-changes-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: (42 commits) dm: fix a couple brace coding style issues dm crypt: print device name in integrity error message dm crypt: move detailed message into debug level dm ioctl: fix hang in early create error condition dm integrity: whitespace, coding style and dead code cleanup dm integrity: implement synchronous mode for reboot handling dm integrity: handle machine reboot in bitmap mode dm integrity: add a bitmap mode dm integrity: introduce a function add_new_range_and_wait() dm integrity: allow large ranges to be described dm ingerity: pass size to dm_integrity_alloc_page_list() dm integrity: introduce rw_journal_sectors() dm integrity: update documentation dm integrity: don't report unused options dm integrity: don't check null pointer before kvfree and vfree dm integrity: correctly calculate the size of metadata area dm dust: Make dm_dust_init and dm_dust_exit static dm dust: remove redundant unsigned comparison to less than zero dm mpath: always free attached_handler_name in parse_path() dm init: fix max devices/targets checks ...
Diffstat (limited to 'drivers/md/dm-crypt.c')
-rw-r--r--drivers/md/dm-crypt.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 7f6462f74ac8..1b16d34bb785 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -946,6 +946,7 @@ static int crypt_integrity_ctr(struct crypt_config *cc, struct dm_target *ti)
946{ 946{
947#ifdef CONFIG_BLK_DEV_INTEGRITY 947#ifdef CONFIG_BLK_DEV_INTEGRITY
948 struct blk_integrity *bi = blk_get_integrity(cc->dev->bdev->bd_disk); 948 struct blk_integrity *bi = blk_get_integrity(cc->dev->bdev->bd_disk);
949 struct mapped_device *md = dm_table_get_md(ti->table);
949 950
950 /* From now we require underlying device with our integrity profile */ 951 /* From now we require underlying device with our integrity profile */
951 if (!bi || strcasecmp(bi->profile->name, "DM-DIF-EXT-TAG")) { 952 if (!bi || strcasecmp(bi->profile->name, "DM-DIF-EXT-TAG")) {
@@ -965,7 +966,7 @@ static int crypt_integrity_ctr(struct crypt_config *cc, struct dm_target *ti)
965 966
966 if (crypt_integrity_aead(cc)) { 967 if (crypt_integrity_aead(cc)) {
967 cc->integrity_tag_size = cc->on_disk_tag_size - cc->integrity_iv_size; 968 cc->integrity_tag_size = cc->on_disk_tag_size - cc->integrity_iv_size;
968 DMINFO("Integrity AEAD, tag size %u, IV size %u.", 969 DMDEBUG("%s: Integrity AEAD, tag size %u, IV size %u.", dm_device_name(md),
969 cc->integrity_tag_size, cc->integrity_iv_size); 970 cc->integrity_tag_size, cc->integrity_iv_size);
970 971
971 if (crypto_aead_setauthsize(any_tfm_aead(cc), cc->integrity_tag_size)) { 972 if (crypto_aead_setauthsize(any_tfm_aead(cc), cc->integrity_tag_size)) {
@@ -973,7 +974,7 @@ static int crypt_integrity_ctr(struct crypt_config *cc, struct dm_target *ti)
973 return -EINVAL; 974 return -EINVAL;
974 } 975 }
975 } else if (cc->integrity_iv_size) 976 } else if (cc->integrity_iv_size)
976 DMINFO("Additional per-sector space %u bytes for IV.", 977 DMDEBUG("%s: Additional per-sector space %u bytes for IV.", dm_device_name(md),
977 cc->integrity_iv_size); 978 cc->integrity_iv_size);
978 979
979 if ((cc->integrity_tag_size + cc->integrity_iv_size) != bi->tag_size) { 980 if ((cc->integrity_tag_size + cc->integrity_iv_size) != bi->tag_size) {
@@ -1031,11 +1032,11 @@ static u8 *org_iv_of_dmreq(struct crypt_config *cc,
1031 return iv_of_dmreq(cc, dmreq) + cc->iv_size; 1032 return iv_of_dmreq(cc, dmreq) + cc->iv_size;
1032} 1033}
1033 1034
1034static uint64_t *org_sector_of_dmreq(struct crypt_config *cc, 1035static __le64 *org_sector_of_dmreq(struct crypt_config *cc,
1035 struct dm_crypt_request *dmreq) 1036 struct dm_crypt_request *dmreq)
1036{ 1037{
1037 u8 *ptr = iv_of_dmreq(cc, dmreq) + cc->iv_size + cc->iv_size; 1038 u8 *ptr = iv_of_dmreq(cc, dmreq) + cc->iv_size + cc->iv_size;
1038 return (uint64_t*) ptr; 1039 return (__le64 *) ptr;
1039} 1040}
1040 1041
1041static unsigned int *org_tag_of_dmreq(struct crypt_config *cc, 1042static unsigned int *org_tag_of_dmreq(struct crypt_config *cc,
@@ -1071,7 +1072,7 @@ static int crypt_convert_block_aead(struct crypt_config *cc,
1071 struct bio_vec bv_out = bio_iter_iovec(ctx->bio_out, ctx->iter_out); 1072 struct bio_vec bv_out = bio_iter_iovec(ctx->bio_out, ctx->iter_out);
1072 struct dm_crypt_request *dmreq; 1073 struct dm_crypt_request *dmreq;
1073 u8 *iv, *org_iv, *tag_iv, *tag; 1074 u8 *iv, *org_iv, *tag_iv, *tag;
1074 uint64_t *sector; 1075 __le64 *sector;
1075 int r = 0; 1076 int r = 0;
1076 1077
1077 BUG_ON(cc->integrity_iv_size && cc->integrity_iv_size != cc->iv_size); 1078 BUG_ON(cc->integrity_iv_size && cc->integrity_iv_size != cc->iv_size);
@@ -1143,9 +1144,11 @@ static int crypt_convert_block_aead(struct crypt_config *cc,
1143 r = crypto_aead_decrypt(req); 1144 r = crypto_aead_decrypt(req);
1144 } 1145 }
1145 1146
1146 if (r == -EBADMSG) 1147 if (r == -EBADMSG) {
1147 DMERR_LIMIT("INTEGRITY AEAD ERROR, sector %llu", 1148 char b[BDEVNAME_SIZE];
1149 DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b),
1148 (unsigned long long)le64_to_cpu(*sector)); 1150 (unsigned long long)le64_to_cpu(*sector));
1151 }
1149 1152
1150 if (!r && cc->iv_gen_ops && cc->iv_gen_ops->post) 1153 if (!r && cc->iv_gen_ops && cc->iv_gen_ops->post)
1151 r = cc->iv_gen_ops->post(cc, org_iv, dmreq); 1154 r = cc->iv_gen_ops->post(cc, org_iv, dmreq);
@@ -1166,7 +1169,7 @@ static int crypt_convert_block_skcipher(struct crypt_config *cc,
1166 struct scatterlist *sg_in, *sg_out; 1169 struct scatterlist *sg_in, *sg_out;
1167 struct dm_crypt_request *dmreq; 1170 struct dm_crypt_request *dmreq;
1168 u8 *iv, *org_iv, *tag_iv; 1171 u8 *iv, *org_iv, *tag_iv;
1169 uint64_t *sector; 1172 __le64 *sector;
1170 int r = 0; 1173 int r = 0;
1171 1174
1172 /* Reject unexpected unaligned bio. */ 1175 /* Reject unexpected unaligned bio. */
@@ -1788,7 +1791,8 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
1788 error = cc->iv_gen_ops->post(cc, org_iv_of_dmreq(cc, dmreq), dmreq); 1791 error = cc->iv_gen_ops->post(cc, org_iv_of_dmreq(cc, dmreq), dmreq);
1789 1792
1790 if (error == -EBADMSG) { 1793 if (error == -EBADMSG) {
1791 DMERR_LIMIT("INTEGRITY AEAD ERROR, sector %llu", 1794 char b[BDEVNAME_SIZE];
1795 DMERR_LIMIT("%s: INTEGRITY AEAD ERROR, sector %llu", bio_devname(ctx->bio_in, b),
1792 (unsigned long long)le64_to_cpu(*org_sector_of_dmreq(cc, dmreq))); 1796 (unsigned long long)le64_to_cpu(*org_sector_of_dmreq(cc, dmreq)));
1793 io->error = BLK_STS_PROTECTION; 1797 io->error = BLK_STS_PROTECTION;
1794 } else if (error < 0) 1798 } else if (error < 0)
@@ -1887,7 +1891,7 @@ static int crypt_alloc_tfms_skcipher(struct crypt_config *cc, char *ciphermode)
1887 * algorithm implementation is used. Help people debug performance 1891 * algorithm implementation is used. Help people debug performance
1888 * problems by logging the ->cra_driver_name. 1892 * problems by logging the ->cra_driver_name.
1889 */ 1893 */
1890 DMINFO("%s using implementation \"%s\"", ciphermode, 1894 DMDEBUG_LIMIT("%s using implementation \"%s\"", ciphermode,
1891 crypto_skcipher_alg(any_tfm(cc))->base.cra_driver_name); 1895 crypto_skcipher_alg(any_tfm(cc))->base.cra_driver_name);
1892 return 0; 1896 return 0;
1893} 1897}
@@ -1907,7 +1911,7 @@ static int crypt_alloc_tfms_aead(struct crypt_config *cc, char *ciphermode)
1907 return err; 1911 return err;
1908 } 1912 }
1909 1913
1910 DMINFO("%s using implementation \"%s\"", ciphermode, 1914 DMDEBUG_LIMIT("%s using implementation \"%s\"", ciphermode,
1911 crypto_aead_alg(any_tfm_aead(cc))->base.cra_driver_name); 1915 crypto_aead_alg(any_tfm_aead(cc))->base.cra_driver_name);
1912 return 0; 1916 return 0;
1913} 1917}