Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-5.2/dm-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:

- Fix incorrect uses of kstrndup and DM logging macros in DM's early
init code.

- Fix DM log-writes target's handling of super block sectors so updates
are made in order through use of completion.

- Fix DM core's argument splitting code to avoid undefined behaviour
reported as a side-effect of UBSAN analysis on ppc64le.

- Fix DM verity target to limit the amount of error messages that can
result from a corrupt block being found.

* tag 'for-5.2/dm-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm verity: use message limit for data block corruption message
dm table: don't copy from a NULL pointer in realloc_argv()
dm log writes: make sure super sector log updates are written in order
dm init: remove trailing newline from calls to DMERR() and DMINFO()
dm init: fix incorrect uses of kstrndup()

+29 -10
+5 -5
drivers/md/dm-init.c
··· 140 140 return ERR_PTR(-EINVAL); 141 141 } 142 142 /* target_args */ 143 - dev->target_args_array[n] = kstrndup(field[3], GFP_KERNEL, 144 - DM_MAX_STR_SIZE); 143 + dev->target_args_array[n] = kstrndup(field[3], DM_MAX_STR_SIZE, 144 + GFP_KERNEL); 145 145 if (!dev->target_args_array[n]) 146 146 return ERR_PTR(-ENOMEM); 147 147 ··· 272 272 return 0; 273 273 274 274 if (strlen(create) >= DM_MAX_STR_SIZE) { 275 - DMERR("Argument is too big. Limit is %d\n", DM_MAX_STR_SIZE); 275 + DMERR("Argument is too big. Limit is %d", DM_MAX_STR_SIZE); 276 276 return -EINVAL; 277 277 } 278 - str = kstrndup(create, GFP_KERNEL, DM_MAX_STR_SIZE); 278 + str = kstrndup(create, DM_MAX_STR_SIZE, GFP_KERNEL); 279 279 if (!str) 280 280 return -ENOMEM; 281 281 ··· 283 283 if (r) 284 284 goto out; 285 285 286 - DMINFO("waiting for all devices to be available before creating mapped devices\n"); 286 + DMINFO("waiting for all devices to be available before creating mapped devices"); 287 287 wait_for_device_probe(); 288 288 289 289 list_for_each_entry(dev, &devices, list) {
+21 -2
drivers/md/dm-log-writes.c
··· 60 60 61 61 #define WRITE_LOG_VERSION 1ULL 62 62 #define WRITE_LOG_MAGIC 0x6a736677736872ULL 63 + #define WRITE_LOG_SUPER_SECTOR 0 63 64 64 65 /* 65 66 * The disk format for this is braindead simple. ··· 116 115 struct list_head logging_blocks; 117 116 wait_queue_head_t wait; 118 117 struct task_struct *log_kthread; 118 + struct completion super_done; 119 119 }; 120 120 121 121 struct pending_block { ··· 182 180 bio_put(bio); 183 181 } 184 182 183 + static void log_end_super(struct bio *bio) 184 + { 185 + struct log_writes_c *lc = bio->bi_private; 186 + 187 + complete(&lc->super_done); 188 + log_end_io(bio); 189 + } 190 + 185 191 /* 186 192 * Meant to be called if there is an error, it will free all the pages 187 193 * associated with the block. ··· 225 215 bio->bi_iter.bi_size = 0; 226 216 bio->bi_iter.bi_sector = sector; 227 217 bio_set_dev(bio, lc->logdev->bdev); 228 - bio->bi_end_io = log_end_io; 218 + bio->bi_end_io = (sector == WRITE_LOG_SUPER_SECTOR) ? 219 + log_end_super : log_end_io; 229 220 bio->bi_private = lc; 230 221 bio_set_op_attrs(bio, REQ_OP_WRITE, 0); 231 222 ··· 429 418 super.nr_entries = cpu_to_le64(lc->logged_entries); 430 419 super.sectorsize = cpu_to_le32(lc->sectorsize); 431 420 432 - if (write_metadata(lc, &super, sizeof(super), NULL, 0, 0)) { 421 + if (write_metadata(lc, &super, sizeof(super), NULL, 0, 422 + WRITE_LOG_SUPER_SECTOR)) { 433 423 DMERR("Couldn't write super"); 434 424 return -1; 435 425 } 426 + 427 + /* 428 + * Super sector should be writen in-order, otherwise the 429 + * nr_entries could be rewritten incorrectly by an old bio. 430 + */ 431 + wait_for_completion_io(&lc->super_done); 436 432 437 433 return 0; 438 434 } ··· 549 531 INIT_LIST_HEAD(&lc->unflushed_blocks); 550 532 INIT_LIST_HEAD(&lc->logging_blocks); 551 533 init_waitqueue_head(&lc->wait); 534 + init_completion(&lc->super_done); 552 535 atomic_set(&lc->io_blocks, 0); 553 536 atomic_set(&lc->pending_blocks, 0); 554 537
+1 -1
drivers/md/dm-table.c
··· 561 561 gfp = GFP_NOIO; 562 562 } 563 563 argv = kmalloc_array(new_size, sizeof(*argv), gfp); 564 - if (argv) { 564 + if (argv && old_argv) { 565 565 memcpy(argv, old_argv, *size * sizeof(*argv)); 566 566 *size = new_size; 567 567 }
+2 -2
drivers/md/dm-verity-target.c
··· 235 235 BUG(); 236 236 } 237 237 238 - DMERR("%s: %s block %llu is corrupted", v->data_dev->name, type_str, 239 - block); 238 + DMERR_LIMIT("%s: %s block %llu is corrupted", v->data_dev->name, 239 + type_str, block); 240 240 241 241 if (v->corrupted_errs == DM_VERITY_MAX_CORRUPTED_ERRS) 242 242 DMERR("%s: reached maximum errors", v->data_dev->name);