aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2013-03-01 17:45:44 -0500
committerAlasdair G Kergon <agk@redhat.com>2013-03-01 17:45:44 -0500
commitfd7c092e711ebab55b2688d3859d95dfd0301f73 (patch)
tree3cc99f96f4a2de8e22347feb86b0ecd5dd7200d0 /drivers/md
parent16245bdc9d3e22d1460341a655c8b5288953bc14 (diff)
dm: fix truncated status strings
Avoid returning a truncated table or status string instead of setting the DM_BUFFER_FULL_FLAG when the last target of a table fills the buffer. When processing a table or status request, the function retrieve_status calls ti->type->status. If ti->type->status returns non-zero, retrieve_status assumes that the buffer overflowed and sets DM_BUFFER_FULL_FLAG. However, targets don't return non-zero values from their status method on overflow. Most targets returns always zero. If a buffer overflow happens in a target that is not the last in the table, it gets noticed during the next iteration of the loop in retrieve_status; but if a buffer overflow happens in the last target, it goes unnoticed and erroneously truncated data is returned. In the current code, the targets behave in the following way: * dm-crypt returns -ENOMEM if there is not enough space to store the key, but it returns 0 on all other overflows. * dm-thin returns errors from the status method if a disk error happened. This is incorrect because retrieve_status doesn't check the error code, it assumes that all non-zero values mean buffer overflow. * all the other targets always return 0. This patch changes the ti->type->status function to return void (because most targets don't use the return code). Overflow is detected in retrieve_status: if the status method fills up the remaining space completely, it is assumed that buffer overflow happened. Cc: stable@vger.kernel.org Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-crypt.c39
-rw-r--r--drivers/md/dm-delay.c8
-rw-r--r--drivers/md/dm-flakey.c7
-rw-r--r--drivers/md/dm-ioctl.c14
-rw-r--r--drivers/md/dm-linear.c7
-rw-r--r--drivers/md/dm-mpath.c8
-rw-r--r--drivers/md/dm-raid.c8
-rw-r--r--drivers/md/dm-raid1.c8
-rw-r--r--drivers/md/dm-snap.c16
-rw-r--r--drivers/md/dm-stripe.c7
-rw-r--r--drivers/md/dm-thin.c80
-rw-r--r--drivers/md/dm-verity.c8
12 files changed, 97 insertions, 113 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index f7369f9d8595..2ae151e59c0c 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1234,20 +1234,6 @@ static int crypt_decode_key(u8 *key, char *hex, unsigned int size)
1234 return 0; 1234 return 0;
1235} 1235}
1236 1236
1237/*
1238 * Encode key into its hex representation
1239 */
1240static void crypt_encode_key(char *hex, u8 *key, unsigned int size)
1241{
1242 unsigned int i;
1243
1244 for (i = 0; i < size; i++) {
1245 sprintf(hex, "%02x", *key);
1246 hex += 2;
1247 key++;
1248 }
1249}
1250
1251static void crypt_free_tfms(struct crypt_config *cc) 1237static void crypt_free_tfms(struct crypt_config *cc)
1252{ 1238{
1253 unsigned i; 1239 unsigned i;
@@ -1717,11 +1703,11 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
1717 return DM_MAPIO_SUBMITTED; 1703 return DM_MAPIO_SUBMITTED;
1718} 1704}
1719 1705
1720static int crypt_status(struct dm_target *ti, status_type_t type, 1706static void crypt_status(struct dm_target *ti, status_type_t type,
1721 unsigned status_flags, char *result, unsigned maxlen) 1707 unsigned status_flags, char *result, unsigned maxlen)
1722{ 1708{
1723 struct crypt_config *cc = ti->private; 1709 struct crypt_config *cc = ti->private;
1724 unsigned int sz = 0; 1710 unsigned i, sz = 0;
1725 1711
1726 switch (type) { 1712 switch (type) {
1727 case STATUSTYPE_INFO: 1713 case STATUSTYPE_INFO:
@@ -1731,17 +1717,11 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
1731 case STATUSTYPE_TABLE: 1717 case STATUSTYPE_TABLE:
1732 DMEMIT("%s ", cc->cipher_string); 1718 DMEMIT("%s ", cc->cipher_string);
1733 1719
1734 if (cc->key_size > 0) { 1720 if (cc->key_size > 0)
1735 if ((maxlen - sz) < ((cc->key_size << 1) + 1)) 1721 for (i = 0; i < cc->key_size; i++)
1736 return -ENOMEM; 1722 DMEMIT("%02x", cc->key[i]);
1737 1723 else
1738 crypt_encode_key(result + sz, cc->key, cc->key_size); 1724 DMEMIT("-");
1739 sz += cc->key_size << 1;
1740 } else {
1741 if (sz >= maxlen)
1742 return -ENOMEM;
1743 result[sz++] = '-';
1744 }
1745 1725
1746 DMEMIT(" %llu %s %llu", (unsigned long long)cc->iv_offset, 1726 DMEMIT(" %llu %s %llu", (unsigned long long)cc->iv_offset,
1747 cc->dev->name, (unsigned long long)cc->start); 1727 cc->dev->name, (unsigned long long)cc->start);
@@ -1751,7 +1731,6 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
1751 1731
1752 break; 1732 break;
1753 } 1733 }
1754 return 0;
1755} 1734}
1756 1735
1757static void crypt_postsuspend(struct dm_target *ti) 1736static void crypt_postsuspend(struct dm_target *ti)
@@ -1845,7 +1824,7 @@ static int crypt_iterate_devices(struct dm_target *ti,
1845 1824
1846static struct target_type crypt_target = { 1825static struct target_type crypt_target = {
1847 .name = "crypt", 1826 .name = "crypt",
1848 .version = {1, 12, 0}, 1827 .version = {1, 12, 1},
1849 .module = THIS_MODULE, 1828 .module = THIS_MODULE,
1850 .ctr = crypt_ctr, 1829 .ctr = crypt_ctr,
1851 .dtr = crypt_dtr, 1830 .dtr = crypt_dtr,
diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
index cc1bd048acb2..c0d03b006e40 100644
--- a/drivers/md/dm-delay.c
+++ b/drivers/md/dm-delay.c
@@ -293,8 +293,8 @@ static int delay_map(struct dm_target *ti, struct bio *bio)
293 return delay_bio(dc, dc->read_delay, bio); 293 return delay_bio(dc, dc->read_delay, bio);
294} 294}
295 295
296static int delay_status(struct dm_target *ti, status_type_t type, 296static void delay_status(struct dm_target *ti, status_type_t type,
297 unsigned status_flags, char *result, unsigned maxlen) 297 unsigned status_flags, char *result, unsigned maxlen)
298{ 298{
299 struct delay_c *dc = ti->private; 299 struct delay_c *dc = ti->private;
300 int sz = 0; 300 int sz = 0;
@@ -314,8 +314,6 @@ static int delay_status(struct dm_target *ti, status_type_t type,
314 dc->write_delay); 314 dc->write_delay);
315 break; 315 break;
316 } 316 }
317
318 return 0;
319} 317}
320 318
321static int delay_iterate_devices(struct dm_target *ti, 319static int delay_iterate_devices(struct dm_target *ti,
@@ -337,7 +335,7 @@ out:
337 335
338static struct target_type delay_target = { 336static struct target_type delay_target = {
339 .name = "delay", 337 .name = "delay",
340 .version = {1, 2, 0}, 338 .version = {1, 2, 1},
341 .module = THIS_MODULE, 339 .module = THIS_MODULE,
342 .ctr = delay_ctr, 340 .ctr = delay_ctr,
343 .dtr = delay_dtr, 341 .dtr = delay_dtr,
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index 9721f2ffb1a2..5d6c04cceee0 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -337,8 +337,8 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
337 return error; 337 return error;
338} 338}
339 339
340static int flakey_status(struct dm_target *ti, status_type_t type, 340static void flakey_status(struct dm_target *ti, status_type_t type,
341 unsigned status_flags, char *result, unsigned maxlen) 341 unsigned status_flags, char *result, unsigned maxlen)
342{ 342{
343 unsigned sz = 0; 343 unsigned sz = 0;
344 struct flakey_c *fc = ti->private; 344 struct flakey_c *fc = ti->private;
@@ -368,7 +368,6 @@ static int flakey_status(struct dm_target *ti, status_type_t type,
368 368
369 break; 369 break;
370 } 370 }
371 return 0;
372} 371}
373 372
374static int flakey_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg) 373static int flakey_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg)
@@ -411,7 +410,7 @@ static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_
411 410
412static struct target_type flakey_target = { 411static struct target_type flakey_target = {
413 .name = "flakey", 412 .name = "flakey",
414 .version = {1, 3, 0}, 413 .version = {1, 3, 1},
415 .module = THIS_MODULE, 414 .module = THIS_MODULE,
416 .ctr = flakey_ctr, 415 .ctr = flakey_ctr,
417 .dtr = flakey_dtr, 416 .dtr = flakey_dtr,
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 0666b5d14b88..eee353da3742 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1067,6 +1067,7 @@ static void retrieve_status(struct dm_table *table,
1067 num_targets = dm_table_get_num_targets(table); 1067 num_targets = dm_table_get_num_targets(table);
1068 for (i = 0; i < num_targets; i++) { 1068 for (i = 0; i < num_targets; i++) {
1069 struct dm_target *ti = dm_table_get_target(table, i); 1069 struct dm_target *ti = dm_table_get_target(table, i);
1070 size_t l;
1070 1071
1071 remaining = len - (outptr - outbuf); 1072 remaining = len - (outptr - outbuf);
1072 if (remaining <= sizeof(struct dm_target_spec)) { 1073 if (remaining <= sizeof(struct dm_target_spec)) {
@@ -1093,14 +1094,17 @@ static void retrieve_status(struct dm_table *table,
1093 if (ti->type->status) { 1094 if (ti->type->status) {
1094 if (param->flags & DM_NOFLUSH_FLAG) 1095 if (param->flags & DM_NOFLUSH_FLAG)
1095 status_flags |= DM_STATUS_NOFLUSH_FLAG; 1096 status_flags |= DM_STATUS_NOFLUSH_FLAG;
1096 if (ti->type->status(ti, type, status_flags, outptr, remaining)) { 1097 ti->type->status(ti, type, status_flags, outptr, remaining);
1097 param->flags |= DM_BUFFER_FULL_FLAG;
1098 break;
1099 }
1100 } else 1098 } else
1101 outptr[0] = '\0'; 1099 outptr[0] = '\0';
1102 1100
1103 outptr += strlen(outptr) + 1; 1101 l = strlen(outptr) + 1;
1102 if (l == remaining) {
1103 param->flags |= DM_BUFFER_FULL_FLAG;
1104 break;
1105 }
1106
1107 outptr += l;
1104 used = param->data_start + (outptr - outbuf); 1108 used = param->data_start + (outptr - outbuf);
1105 1109
1106 outptr = align_ptr(outptr); 1110 outptr = align_ptr(outptr);
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index 328cad5617ab..5be301c1e809 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -95,8 +95,8 @@ static int linear_map(struct dm_target *ti, struct bio *bio)
95 return DM_MAPIO_REMAPPED; 95 return DM_MAPIO_REMAPPED;
96} 96}
97 97
98static int linear_status(struct dm_target *ti, status_type_t type, 98static void linear_status(struct dm_target *ti, status_type_t type,
99 unsigned status_flags, char *result, unsigned maxlen) 99 unsigned status_flags, char *result, unsigned maxlen)
100{ 100{
101 struct linear_c *lc = (struct linear_c *) ti->private; 101 struct linear_c *lc = (struct linear_c *) ti->private;
102 102
@@ -110,7 +110,6 @@ static int linear_status(struct dm_target *ti, status_type_t type,
110 (unsigned long long)lc->start); 110 (unsigned long long)lc->start);
111 break; 111 break;
112 } 112 }
113 return 0;
114} 113}
115 114
116static int linear_ioctl(struct dm_target *ti, unsigned int cmd, 115static int linear_ioctl(struct dm_target *ti, unsigned int cmd,
@@ -155,7 +154,7 @@ static int linear_iterate_devices(struct dm_target *ti,
155 154
156static struct target_type linear_target = { 155static struct target_type linear_target = {
157 .name = "linear", 156 .name = "linear",
158 .version = {1, 2, 0}, 157 .version = {1, 2, 1},
159 .module = THIS_MODULE, 158 .module = THIS_MODULE,
160 .ctr = linear_ctr, 159 .ctr = linear_ctr,
161 .dtr = linear_dtr, 160 .dtr = linear_dtr,
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 573bd04591bf..d267bb5705e9 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1378,8 +1378,8 @@ static void multipath_resume(struct dm_target *ti)
1378 * [priority selector-name num_ps_args [ps_args]* 1378 * [priority selector-name num_ps_args [ps_args]*
1379 * num_paths num_selector_args [path_dev [selector_args]* ]+ ]+ 1379 * num_paths num_selector_args [path_dev [selector_args]* ]+ ]+
1380 */ 1380 */
1381static int multipath_status(struct dm_target *ti, status_type_t type, 1381static void multipath_status(struct dm_target *ti, status_type_t type,
1382 unsigned status_flags, char *result, unsigned maxlen) 1382 unsigned status_flags, char *result, unsigned maxlen)
1383{ 1383{
1384 int sz = 0; 1384 int sz = 0;
1385 unsigned long flags; 1385 unsigned long flags;
@@ -1485,8 +1485,6 @@ static int multipath_status(struct dm_target *ti, status_type_t type,
1485 } 1485 }
1486 1486
1487 spin_unlock_irqrestore(&m->lock, flags); 1487 spin_unlock_irqrestore(&m->lock, flags);
1488
1489 return 0;
1490} 1488}
1491 1489
1492static int multipath_message(struct dm_target *ti, unsigned argc, char **argv) 1490static int multipath_message(struct dm_target *ti, unsigned argc, char **argv)
@@ -1695,7 +1693,7 @@ out:
1695 *---------------------------------------------------------------*/ 1693 *---------------------------------------------------------------*/
1696static struct target_type multipath_target = { 1694static struct target_type multipath_target = {
1697 .name = "multipath", 1695 .name = "multipath",
1698 .version = {1, 5, 0}, 1696 .version = {1, 5, 1},
1699 .module = THIS_MODULE, 1697 .module = THIS_MODULE,
1700 .ctr = multipath_ctr, 1698 .ctr = multipath_ctr,
1701 .dtr = multipath_dtr, 1699 .dtr = multipath_dtr,
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 9e58dbd8d8cb..5a578d89da2d 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -1201,8 +1201,8 @@ static int raid_map(struct dm_target *ti, struct bio *bio)
1201 return DM_MAPIO_SUBMITTED; 1201 return DM_MAPIO_SUBMITTED;
1202} 1202}
1203 1203
1204static int raid_status(struct dm_target *ti, status_type_t type, 1204static void raid_status(struct dm_target *ti, status_type_t type,
1205 unsigned status_flags, char *result, unsigned maxlen) 1205 unsigned status_flags, char *result, unsigned maxlen)
1206{ 1206{
1207 struct raid_set *rs = ti->private; 1207 struct raid_set *rs = ti->private;
1208 unsigned raid_param_cnt = 1; /* at least 1 for chunksize */ 1208 unsigned raid_param_cnt = 1; /* at least 1 for chunksize */
@@ -1344,8 +1344,6 @@ static int raid_status(struct dm_target *ti, status_type_t type,
1344 DMEMIT(" -"); 1344 DMEMIT(" -");
1345 } 1345 }
1346 } 1346 }
1347
1348 return 0;
1349} 1347}
1350 1348
1351static int raid_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, void *data) 1349static int raid_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, void *data)
@@ -1405,7 +1403,7 @@ static void raid_resume(struct dm_target *ti)
1405 1403
1406static struct target_type raid_target = { 1404static struct target_type raid_target = {
1407 .name = "raid", 1405 .name = "raid",
1408 .version = {1, 4, 1}, 1406 .version = {1, 4, 2},
1409 .module = THIS_MODULE, 1407 .module = THIS_MODULE,
1410 .ctr = raid_ctr, 1408 .ctr = raid_ctr,
1411 .dtr = raid_dtr, 1409 .dtr = raid_dtr,
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index fa519185ebba..7f2419099b50 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1347,8 +1347,8 @@ static char device_status_char(struct mirror *m)
1347} 1347}
1348 1348
1349 1349
1350static int mirror_status(struct dm_target *ti, status_type_t type, 1350static void mirror_status(struct dm_target *ti, status_type_t type,
1351 unsigned status_flags, char *result, unsigned maxlen) 1351 unsigned status_flags, char *result, unsigned maxlen)
1352{ 1352{
1353 unsigned int m, sz = 0; 1353 unsigned int m, sz = 0;
1354 struct mirror_set *ms = (struct mirror_set *) ti->private; 1354 struct mirror_set *ms = (struct mirror_set *) ti->private;
@@ -1383,8 +1383,6 @@ static int mirror_status(struct dm_target *ti, status_type_t type,
1383 if (ms->features & DM_RAID1_HANDLE_ERRORS) 1383 if (ms->features & DM_RAID1_HANDLE_ERRORS)
1384 DMEMIT(" 1 handle_errors"); 1384 DMEMIT(" 1 handle_errors");
1385 } 1385 }
1386
1387 return 0;
1388} 1386}
1389 1387
1390static int mirror_iterate_devices(struct dm_target *ti, 1388static int mirror_iterate_devices(struct dm_target *ti,
@@ -1403,7 +1401,7 @@ static int mirror_iterate_devices(struct dm_target *ti,
1403 1401
1404static struct target_type mirror_target = { 1402static struct target_type mirror_target = {
1405 .name = "mirror", 1403 .name = "mirror",
1406 .version = {1, 13, 1}, 1404 .version = {1, 13, 2},
1407 .module = THIS_MODULE, 1405 .module = THIS_MODULE,
1408 .ctr = mirror_ctr, 1406 .ctr = mirror_ctr,
1409 .dtr = mirror_dtr, 1407 .dtr = mirror_dtr,
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 10079e07edf4..6e45e3774eab 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1836,8 +1836,8 @@ static void snapshot_merge_resume(struct dm_target *ti)
1836 start_merge(s); 1836 start_merge(s);
1837} 1837}
1838 1838
1839static int snapshot_status(struct dm_target *ti, status_type_t type, 1839static void snapshot_status(struct dm_target *ti, status_type_t type,
1840 unsigned status_flags, char *result, unsigned maxlen) 1840 unsigned status_flags, char *result, unsigned maxlen)
1841{ 1841{
1842 unsigned sz = 0; 1842 unsigned sz = 0;
1843 struct dm_snapshot *snap = ti->private; 1843 struct dm_snapshot *snap = ti->private;
@@ -1883,8 +1883,6 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
1883 maxlen - sz); 1883 maxlen - sz);
1884 break; 1884 break;
1885 } 1885 }
1886
1887 return 0;
1888} 1886}
1889 1887
1890static int snapshot_iterate_devices(struct dm_target *ti, 1888static int snapshot_iterate_devices(struct dm_target *ti,
@@ -2138,8 +2136,8 @@ static void origin_resume(struct dm_target *ti)
2138 ti->max_io_len = get_origin_minimum_chunksize(dev->bdev); 2136 ti->max_io_len = get_origin_minimum_chunksize(dev->bdev);
2139} 2137}
2140 2138
2141static int origin_status(struct dm_target *ti, status_type_t type, 2139static void origin_status(struct dm_target *ti, status_type_t type,
2142 unsigned status_flags, char *result, unsigned maxlen) 2140 unsigned status_flags, char *result, unsigned maxlen)
2143{ 2141{
2144 struct dm_dev *dev = ti->private; 2142 struct dm_dev *dev = ti->private;
2145 2143
@@ -2152,8 +2150,6 @@ static int origin_status(struct dm_target *ti, status_type_t type,
2152 snprintf(result, maxlen, "%s", dev->name); 2150 snprintf(result, maxlen, "%s", dev->name);
2153 break; 2151 break;
2154 } 2152 }
2155
2156 return 0;
2157} 2153}
2158 2154
2159static int origin_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 2155static int origin_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
@@ -2180,7 +2176,7 @@ static int origin_iterate_devices(struct dm_target *ti,
2180 2176
2181static struct target_type origin_target = { 2177static struct target_type origin_target = {
2182 .name = "snapshot-origin", 2178 .name = "snapshot-origin",
2183 .version = {1, 8, 0}, 2179 .version = {1, 8, 1},
2184 .module = THIS_MODULE, 2180 .module = THIS_MODULE,
2185 .ctr = origin_ctr, 2181 .ctr = origin_ctr,
2186 .dtr = origin_dtr, 2182 .dtr = origin_dtr,
@@ -2193,7 +2189,7 @@ static struct target_type origin_target = {
2193 2189
2194static struct target_type snapshot_target = { 2190static struct target_type snapshot_target = {
2195 .name = "snapshot", 2191 .name = "snapshot",
2196 .version = {1, 11, 0}, 2192 .version = {1, 11, 1},
2197 .module = THIS_MODULE, 2193 .module = THIS_MODULE,
2198 .ctr = snapshot_ctr, 2194 .ctr = snapshot_ctr,
2199 .dtr = snapshot_dtr, 2195 .dtr = snapshot_dtr,
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index c89cde86d400..aaecefa63935 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -312,8 +312,8 @@ static int stripe_map(struct dm_target *ti, struct bio *bio)
312 * 312 *
313 */ 313 */
314 314
315static int stripe_status(struct dm_target *ti, status_type_t type, 315static void stripe_status(struct dm_target *ti, status_type_t type,
316 unsigned status_flags, char *result, unsigned maxlen) 316 unsigned status_flags, char *result, unsigned maxlen)
317{ 317{
318 struct stripe_c *sc = (struct stripe_c *) ti->private; 318 struct stripe_c *sc = (struct stripe_c *) ti->private;
319 char buffer[sc->stripes + 1]; 319 char buffer[sc->stripes + 1];
@@ -340,7 +340,6 @@ static int stripe_status(struct dm_target *ti, status_type_t type,
340 (unsigned long long)sc->stripe[i].physical_start); 340 (unsigned long long)sc->stripe[i].physical_start);
341 break; 341 break;
342 } 342 }
343 return 0;
344} 343}
345 344
346static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error) 345static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
@@ -428,7 +427,7 @@ static int stripe_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
428 427
429static struct target_type stripe_target = { 428static struct target_type stripe_target = {
430 .name = "striped", 429 .name = "striped",
431 .version = {1, 5, 0}, 430 .version = {1, 5, 1},
432 .module = THIS_MODULE, 431 .module = THIS_MODULE,
433 .ctr = stripe_ctr, 432 .ctr = stripe_ctr,
434 .dtr = stripe_dtr, 433 .dtr = stripe_dtr,
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 5409607d4875..7a66d73148e6 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -2299,8 +2299,8 @@ static void emit_flags(struct pool_features *pf, char *result,
2299 * <transaction id> <used metadata sectors>/<total metadata sectors> 2299 * <transaction id> <used metadata sectors>/<total metadata sectors>
2300 * <used data sectors>/<total data sectors> <held metadata root> 2300 * <used data sectors>/<total data sectors> <held metadata root>
2301 */ 2301 */
2302static int pool_status(struct dm_target *ti, status_type_t type, 2302static void pool_status(struct dm_target *ti, status_type_t type,
2303 unsigned status_flags, char *result, unsigned maxlen) 2303 unsigned status_flags, char *result, unsigned maxlen)
2304{ 2304{
2305 int r; 2305 int r;
2306 unsigned sz = 0; 2306 unsigned sz = 0;
@@ -2326,32 +2326,41 @@ static int pool_status(struct dm_target *ti, status_type_t type,
2326 if (!(status_flags & DM_STATUS_NOFLUSH_FLAG) && !dm_suspended(ti)) 2326 if (!(status_flags & DM_STATUS_NOFLUSH_FLAG) && !dm_suspended(ti))
2327 (void) commit_or_fallback(pool); 2327 (void) commit_or_fallback(pool);
2328 2328
2329 r = dm_pool_get_metadata_transaction_id(pool->pmd, 2329 r = dm_pool_get_metadata_transaction_id(pool->pmd, &transaction_id);
2330 &transaction_id); 2330 if (r) {
2331 if (r) 2331 DMERR("dm_pool_get_metadata_transaction_id returned %d", r);
2332 return r; 2332 goto err;
2333 }
2333 2334
2334 r = dm_pool_get_free_metadata_block_count(pool->pmd, 2335 r = dm_pool_get_free_metadata_block_count(pool->pmd, &nr_free_blocks_metadata);
2335 &nr_free_blocks_metadata); 2336 if (r) {
2336 if (r) 2337 DMERR("dm_pool_get_free_metadata_block_count returned %d", r);
2337 return r; 2338 goto err;
2339 }
2338 2340
2339 r = dm_pool_get_metadata_dev_size(pool->pmd, &nr_blocks_metadata); 2341 r = dm_pool_get_metadata_dev_size(pool->pmd, &nr_blocks_metadata);
2340 if (r) 2342 if (r) {
2341 return r; 2343 DMERR("dm_pool_get_metadata_dev_size returned %d", r);
2344 goto err;
2345 }
2342 2346
2343 r = dm_pool_get_free_block_count(pool->pmd, 2347 r = dm_pool_get_free_block_count(pool->pmd, &nr_free_blocks_data);
2344 &nr_free_blocks_data); 2348 if (r) {
2345 if (r) 2349 DMERR("dm_pool_get_free_block_count returned %d", r);
2346 return r; 2350 goto err;
2351 }
2347 2352
2348 r = dm_pool_get_data_dev_size(pool->pmd, &nr_blocks_data); 2353 r = dm_pool_get_data_dev_size(pool->pmd, &nr_blocks_data);
2349 if (r) 2354 if (r) {
2350 return r; 2355 DMERR("dm_pool_get_data_dev_size returned %d", r);
2356 goto err;
2357 }
2351 2358
2352 r = dm_pool_get_metadata_snap(pool->pmd, &held_root); 2359 r = dm_pool_get_metadata_snap(pool->pmd, &held_root);
2353 if (r) 2360 if (r) {
2354 return r; 2361 DMERR("dm_pool_get_metadata_snap returned %d", r);
2362 goto err;
2363 }
2355 2364
2356 DMEMIT("%llu %llu/%llu %llu/%llu ", 2365 DMEMIT("%llu %llu/%llu %llu/%llu ",
2357 (unsigned long long)transaction_id, 2366 (unsigned long long)transaction_id,
@@ -2388,8 +2397,10 @@ static int pool_status(struct dm_target *ti, status_type_t type,
2388 emit_flags(&pt->requested_pf, result, sz, maxlen); 2397 emit_flags(&pt->requested_pf, result, sz, maxlen);
2389 break; 2398 break;
2390 } 2399 }
2400 return;
2391 2401
2392 return 0; 2402err:
2403 DMEMIT("Error");
2393} 2404}
2394 2405
2395static int pool_iterate_devices(struct dm_target *ti, 2406static int pool_iterate_devices(struct dm_target *ti,
@@ -2468,7 +2479,7 @@ static struct target_type pool_target = {
2468 .name = "thin-pool", 2479 .name = "thin-pool",
2469 .features = DM_TARGET_SINGLETON | DM_TARGET_ALWAYS_WRITEABLE | 2480 .features = DM_TARGET_SINGLETON | DM_TARGET_ALWAYS_WRITEABLE |
2470 DM_TARGET_IMMUTABLE, 2481 DM_TARGET_IMMUTABLE,
2471 .version = {1, 6, 0}, 2482 .version = {1, 6, 1},
2472 .module = THIS_MODULE, 2483 .module = THIS_MODULE,
2473 .ctr = pool_ctr, 2484 .ctr = pool_ctr,
2474 .dtr = pool_dtr, 2485 .dtr = pool_dtr,
@@ -2676,8 +2687,8 @@ static void thin_postsuspend(struct dm_target *ti)
2676/* 2687/*
2677 * <nr mapped sectors> <highest mapped sector> 2688 * <nr mapped sectors> <highest mapped sector>
2678 */ 2689 */
2679static int thin_status(struct dm_target *ti, status_type_t type, 2690static void thin_status(struct dm_target *ti, status_type_t type,
2680 unsigned status_flags, char *result, unsigned maxlen) 2691 unsigned status_flags, char *result, unsigned maxlen)
2681{ 2692{
2682 int r; 2693 int r;
2683 ssize_t sz = 0; 2694 ssize_t sz = 0;
@@ -2687,7 +2698,7 @@ static int thin_status(struct dm_target *ti, status_type_t type,
2687 2698
2688 if (get_pool_mode(tc->pool) == PM_FAIL) { 2699 if (get_pool_mode(tc->pool) == PM_FAIL) {
2689 DMEMIT("Fail"); 2700 DMEMIT("Fail");
2690 return 0; 2701 return;
2691 } 2702 }
2692 2703
2693 if (!tc->td) 2704 if (!tc->td)
@@ -2696,12 +2707,16 @@ static int thin_status(struct dm_target *ti, status_type_t type,
2696 switch (type) { 2707 switch (type) {
2697 case STATUSTYPE_INFO: 2708 case STATUSTYPE_INFO:
2698 r = dm_thin_get_mapped_count(tc->td, &mapped); 2709 r = dm_thin_get_mapped_count(tc->td, &mapped);
2699 if (r) 2710 if (r) {
2700 return r; 2711 DMERR("dm_thin_get_mapped_count returned %d", r);
2712 goto err;
2713 }
2701 2714
2702 r = dm_thin_get_highest_mapped_block(tc->td, &highest); 2715 r = dm_thin_get_highest_mapped_block(tc->td, &highest);
2703 if (r < 0) 2716 if (r < 0) {
2704 return r; 2717 DMERR("dm_thin_get_highest_mapped_block returned %d", r);
2718 goto err;
2719 }
2705 2720
2706 DMEMIT("%llu ", mapped * tc->pool->sectors_per_block); 2721 DMEMIT("%llu ", mapped * tc->pool->sectors_per_block);
2707 if (r) 2722 if (r)
@@ -2721,7 +2736,10 @@ static int thin_status(struct dm_target *ti, status_type_t type,
2721 } 2736 }
2722 } 2737 }
2723 2738
2724 return 0; 2739 return;
2740
2741err:
2742 DMEMIT("Error");
2725} 2743}
2726 2744
2727static int thin_iterate_devices(struct dm_target *ti, 2745static int thin_iterate_devices(struct dm_target *ti,
@@ -2748,7 +2766,7 @@ static int thin_iterate_devices(struct dm_target *ti,
2748 2766
2749static struct target_type thin_target = { 2767static struct target_type thin_target = {
2750 .name = "thin", 2768 .name = "thin",
2751 .version = {1, 7, 0}, 2769 .version = {1, 7, 1},
2752 .module = THIS_MODULE, 2770 .module = THIS_MODULE,
2753 .ctr = thin_ctr, 2771 .ctr = thin_ctr,
2754 .dtr = thin_dtr, 2772 .dtr = thin_dtr,
diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c
index 52cde982164a..6ad538375c3c 100644
--- a/drivers/md/dm-verity.c
+++ b/drivers/md/dm-verity.c
@@ -508,8 +508,8 @@ static int verity_map(struct dm_target *ti, struct bio *bio)
508/* 508/*
509 * Status: V (valid) or C (corruption found) 509 * Status: V (valid) or C (corruption found)
510 */ 510 */
511static int verity_status(struct dm_target *ti, status_type_t type, 511static void verity_status(struct dm_target *ti, status_type_t type,
512 unsigned status_flags, char *result, unsigned maxlen) 512 unsigned status_flags, char *result, unsigned maxlen)
513{ 513{
514 struct dm_verity *v = ti->private; 514 struct dm_verity *v = ti->private;
515 unsigned sz = 0; 515 unsigned sz = 0;
@@ -540,8 +540,6 @@ static int verity_status(struct dm_target *ti, status_type_t type,
540 DMEMIT("%02x", v->salt[x]); 540 DMEMIT("%02x", v->salt[x]);
541 break; 541 break;
542 } 542 }
543
544 return 0;
545} 543}
546 544
547static int verity_ioctl(struct dm_target *ti, unsigned cmd, 545static int verity_ioctl(struct dm_target *ti, unsigned cmd,
@@ -860,7 +858,7 @@ bad:
860 858
861static struct target_type verity_target = { 859static struct target_type verity_target = {
862 .name = "verity", 860 .name = "verity",
863 .version = {1, 1, 0}, 861 .version = {1, 1, 1},
864 .module = THIS_MODULE, 862 .module = THIS_MODULE,
865 .ctr = verity_ctr, 863 .ctr = verity_ctr,
866 .dtr = verity_dtr, 864 .dtr = verity_dtr,