Lines Matching full:md

68 static int dm_ima_alloc_and_copy_name_uuid(struct mapped_device *md, char **dev_name,  in dm_ima_alloc_and_copy_name_uuid()  argument
84 r = dm_copy_name_and_uuid(md, *dev_name, *dev_uuid); in dm_ima_alloc_and_copy_name_uuid()
103 static int dm_ima_alloc_and_copy_device_data(struct mapped_device *md, char **device_data, in dm_ima_alloc_and_copy_device_data() argument
109 r = dm_ima_alloc_and_copy_name_uuid(md, &dev_name, &dev_uuid, noio); in dm_ima_alloc_and_copy_device_data()
121 dev_name, dev_uuid, md->disk->major, md->disk->first_minor, in dm_ima_alloc_and_copy_device_data()
122 md->disk->minors, num_targets); in dm_ima_alloc_and_copy_device_data()
150 static int dm_ima_alloc_and_copy_capacity_str(struct mapped_device *md, char **capacity_str, in dm_ima_alloc_and_copy_capacity_str() argument
155 capacity = get_capacity(md->disk); in dm_ima_alloc_and_copy_capacity_str()
170 void dm_ima_reset_data(struct mapped_device *md) in dm_ima_reset_data() argument
172 memset(&(md->ima), 0, sizeof(md->ima)); in dm_ima_reset_data()
173 md->ima.dm_version_str_len = strlen(DM_IMA_VERSION_STR); in dm_ima_reset_data()
213 if (dm_ima_alloc_and_copy_device_data(table->md, &device_data_buf, num_targets, noio)) in dm_ima_measure_on_table_load()
230 memcpy(ima_buf + l, DM_IMA_VERSION_STR, table->md->ima.dm_version_str_len); in dm_ima_measure_on_table_load()
231 l += table->md->ima.dm_version_str_len; in dm_ima_measure_on_table_load()
287 memcpy(ima_buf + l, DM_IMA_VERSION_STR, table->md->ima.dm_version_str_len); in dm_ima_measure_on_table_load()
288 l += table->md->ima.dm_version_str_len; in dm_ima_measure_on_table_load()
322 * Finalize the table hash, and store it in table->md->ima.inactive_table.hash, in dm_ima_measure_on_table_load()
340 if (table->md->ima.active_table.hash != table->md->ima.inactive_table.hash) in dm_ima_measure_on_table_load()
341 kfree(table->md->ima.inactive_table.hash); in dm_ima_measure_on_table_load()
343 table->md->ima.inactive_table.hash = digest_buf; in dm_ima_measure_on_table_load()
344 table->md->ima.inactive_table.hash_len = strlen(digest_buf); in dm_ima_measure_on_table_load()
345 table->md->ima.inactive_table.num_targets = num_targets; in dm_ima_measure_on_table_load()
347 if (table->md->ima.active_table.device_metadata != in dm_ima_measure_on_table_load()
348 table->md->ima.inactive_table.device_metadata) in dm_ima_measure_on_table_load()
349 kfree(table->md->ima.inactive_table.device_metadata); in dm_ima_measure_on_table_load()
351 table->md->ima.inactive_table.device_metadata = device_data_buf; in dm_ima_measure_on_table_load()
352 table->md->ima.inactive_table.device_metadata_len = device_data_buf_len; in dm_ima_measure_on_table_load()
370 void dm_ima_measure_on_device_resume(struct mapped_device *md, bool swap) in dm_ima_measure_on_device_resume() argument
384 r = dm_ima_alloc_and_copy_capacity_str(md, &capacity_str, noio); in dm_ima_measure_on_device_resume()
388 memcpy(device_table_data + l, DM_IMA_VERSION_STR, md->ima.dm_version_str_len); in dm_ima_measure_on_device_resume()
389 l += md->ima.dm_version_str_len; in dm_ima_measure_on_device_resume()
392 if (md->ima.active_table.hash != md->ima.inactive_table.hash) in dm_ima_measure_on_device_resume()
393 kfree(md->ima.active_table.hash); in dm_ima_measure_on_device_resume()
395 md->ima.active_table.hash = NULL; in dm_ima_measure_on_device_resume()
396 md->ima.active_table.hash_len = 0; in dm_ima_measure_on_device_resume()
398 if (md->ima.active_table.device_metadata != in dm_ima_measure_on_device_resume()
399 md->ima.inactive_table.device_metadata) in dm_ima_measure_on_device_resume()
400 kfree(md->ima.active_table.device_metadata); in dm_ima_measure_on_device_resume()
402 md->ima.active_table.device_metadata = NULL; in dm_ima_measure_on_device_resume()
403 md->ima.active_table.device_metadata_len = 0; in dm_ima_measure_on_device_resume()
404 md->ima.active_table.num_targets = 0; in dm_ima_measure_on_device_resume()
406 if (md->ima.inactive_table.hash) { in dm_ima_measure_on_device_resume()
407 md->ima.active_table.hash = md->ima.inactive_table.hash; in dm_ima_measure_on_device_resume()
408 md->ima.active_table.hash_len = md->ima.inactive_table.hash_len; in dm_ima_measure_on_device_resume()
409 md->ima.inactive_table.hash = NULL; in dm_ima_measure_on_device_resume()
410 md->ima.inactive_table.hash_len = 0; in dm_ima_measure_on_device_resume()
413 if (md->ima.inactive_table.device_metadata) { in dm_ima_measure_on_device_resume()
414 md->ima.active_table.device_metadata = in dm_ima_measure_on_device_resume()
415 md->ima.inactive_table.device_metadata; in dm_ima_measure_on_device_resume()
416 md->ima.active_table.device_metadata_len = in dm_ima_measure_on_device_resume()
417 md->ima.inactive_table.device_metadata_len; in dm_ima_measure_on_device_resume()
418 md->ima.active_table.num_targets = md->ima.inactive_table.num_targets; in dm_ima_measure_on_device_resume()
419 md->ima.inactive_table.device_metadata = NULL; in dm_ima_measure_on_device_resume()
420 md->ima.inactive_table.device_metadata_len = 0; in dm_ima_measure_on_device_resume()
421 md->ima.inactive_table.num_targets = 0; in dm_ima_measure_on_device_resume()
425 if (md->ima.active_table.device_metadata) { in dm_ima_measure_on_device_resume()
426 memcpy(device_table_data + l, md->ima.active_table.device_metadata, in dm_ima_measure_on_device_resume()
427 md->ima.active_table.device_metadata_len); in dm_ima_measure_on_device_resume()
428 l += md->ima.active_table.device_metadata_len; in dm_ima_measure_on_device_resume()
433 if (md->ima.active_table.hash) { in dm_ima_measure_on_device_resume()
437 memcpy(device_table_data + l, md->ima.active_table.hash, in dm_ima_measure_on_device_resume()
438 md->ima.active_table.hash_len); in dm_ima_measure_on_device_resume()
439 l += md->ima.active_table.hash_len; in dm_ima_measure_on_device_resume()
448 r = dm_ima_alloc_and_copy_name_uuid(md, &dev_name, &dev_uuid, noio); in dm_ima_measure_on_device_resume()
475 void dm_ima_measure_on_device_remove(struct mapped_device *md, bool remove_all) in dm_ima_measure_on_device_remove() argument
498 r = dm_ima_alloc_and_copy_capacity_str(md, &capacity_str, noio); in dm_ima_measure_on_device_remove()
504 memcpy(device_table_data + l, DM_IMA_VERSION_STR, md->ima.dm_version_str_len); in dm_ima_measure_on_device_remove()
505 l += md->ima.dm_version_str_len; in dm_ima_measure_on_device_remove()
507 if (md->ima.active_table.device_metadata) { in dm_ima_measure_on_device_remove()
511 memcpy(device_table_data + l, md->ima.active_table.device_metadata, in dm_ima_measure_on_device_remove()
512 md->ima.active_table.device_metadata_len); in dm_ima_measure_on_device_remove()
513 l += md->ima.active_table.device_metadata_len; in dm_ima_measure_on_device_remove()
518 if (md->ima.inactive_table.device_metadata) { in dm_ima_measure_on_device_remove()
522 memcpy(device_table_data + l, md->ima.inactive_table.device_metadata, in dm_ima_measure_on_device_remove()
523 md->ima.inactive_table.device_metadata_len); in dm_ima_measure_on_device_remove()
524 l += md->ima.inactive_table.device_metadata_len; in dm_ima_measure_on_device_remove()
529 if (md->ima.active_table.hash) { in dm_ima_measure_on_device_remove()
533 memcpy(device_table_data + l, md->ima.active_table.hash, in dm_ima_measure_on_device_remove()
534 md->ima.active_table.hash_len); in dm_ima_measure_on_device_remove()
535 l += md->ima.active_table.hash_len; in dm_ima_measure_on_device_remove()
543 if (md->ima.inactive_table.hash) { in dm_ima_measure_on_device_remove()
547 memcpy(device_table_data + l, md->ima.inactive_table.hash, in dm_ima_measure_on_device_remove()
548 md->ima.inactive_table.hash_len); in dm_ima_measure_on_device_remove()
549 l += md->ima.inactive_table.hash_len; in dm_ima_measure_on_device_remove()
562 if (dm_ima_alloc_and_copy_name_uuid(md, &dev_name, &dev_uuid, noio)) in dm_ima_measure_on_device_remove()
586 kfree(md->ima.active_table.device_metadata); in dm_ima_measure_on_device_remove()
588 if (md->ima.active_table.device_metadata != in dm_ima_measure_on_device_remove()
589 md->ima.inactive_table.device_metadata) in dm_ima_measure_on_device_remove()
590 kfree(md->ima.inactive_table.device_metadata); in dm_ima_measure_on_device_remove()
592 kfree(md->ima.active_table.hash); in dm_ima_measure_on_device_remove()
594 if (md->ima.active_table.hash != md->ima.inactive_table.hash) in dm_ima_measure_on_device_remove()
595 kfree(md->ima.inactive_table.hash); in dm_ima_measure_on_device_remove()
597 dm_ima_reset_data(md); in dm_ima_measure_on_device_remove()
606 void dm_ima_measure_on_table_clear(struct mapped_device *md, bool new_map) in dm_ima_measure_on_table_clear() argument
620 r = dm_ima_alloc_and_copy_capacity_str(md, &capacity_str, noio); in dm_ima_measure_on_table_clear()
624 memcpy(device_table_data + l, DM_IMA_VERSION_STR, md->ima.dm_version_str_len); in dm_ima_measure_on_table_clear()
625 l += md->ima.dm_version_str_len; in dm_ima_measure_on_table_clear()
627 if (md->ima.inactive_table.device_metadata_len && in dm_ima_measure_on_table_clear()
628 md->ima.inactive_table.hash_len) { in dm_ima_measure_on_table_clear()
629 memcpy(device_table_data + l, md->ima.inactive_table.device_metadata, in dm_ima_measure_on_table_clear()
630 md->ima.inactive_table.device_metadata_len); in dm_ima_measure_on_table_clear()
631 l += md->ima.inactive_table.device_metadata_len; in dm_ima_measure_on_table_clear()
636 memcpy(device_table_data + l, md->ima.inactive_table.hash, in dm_ima_measure_on_table_clear()
637 md->ima.inactive_table.hash_len); in dm_ima_measure_on_table_clear()
639 l += md->ima.inactive_table.hash_len; in dm_ima_measure_on_table_clear()
648 if (dm_ima_alloc_and_copy_name_uuid(md, &dev_name, &dev_uuid, noio)) in dm_ima_measure_on_table_clear()
664 if (md->ima.inactive_table.hash && in dm_ima_measure_on_table_clear()
665 md->ima.inactive_table.hash != md->ima.active_table.hash) in dm_ima_measure_on_table_clear()
666 kfree(md->ima.inactive_table.hash); in dm_ima_measure_on_table_clear()
668 md->ima.inactive_table.hash = NULL; in dm_ima_measure_on_table_clear()
669 md->ima.inactive_table.hash_len = 0; in dm_ima_measure_on_table_clear()
671 if (md->ima.inactive_table.device_metadata && in dm_ima_measure_on_table_clear()
672 md->ima.inactive_table.device_metadata != md->ima.active_table.device_metadata) in dm_ima_measure_on_table_clear()
673 kfree(md->ima.inactive_table.device_metadata); in dm_ima_measure_on_table_clear()
675 md->ima.inactive_table.device_metadata = NULL; in dm_ima_measure_on_table_clear()
676 md->ima.inactive_table.device_metadata_len = 0; in dm_ima_measure_on_table_clear()
677 md->ima.inactive_table.num_targets = 0; in dm_ima_measure_on_table_clear()
679 if (md->ima.active_table.hash) { in dm_ima_measure_on_table_clear()
680 md->ima.inactive_table.hash = md->ima.active_table.hash; in dm_ima_measure_on_table_clear()
681 md->ima.inactive_table.hash_len = md->ima.active_table.hash_len; in dm_ima_measure_on_table_clear()
684 if (md->ima.active_table.device_metadata) { in dm_ima_measure_on_table_clear()
685 md->ima.inactive_table.device_metadata = in dm_ima_measure_on_table_clear()
686 md->ima.active_table.device_metadata; in dm_ima_measure_on_table_clear()
687 md->ima.inactive_table.device_metadata_len = in dm_ima_measure_on_table_clear()
688 md->ima.active_table.device_metadata_len; in dm_ima_measure_on_table_clear()
689 md->ima.inactive_table.num_targets = in dm_ima_measure_on_table_clear()
690 md->ima.active_table.num_targets; in dm_ima_measure_on_table_clear()
705 void dm_ima_measure_on_device_rename(struct mapped_device *md) in dm_ima_measure_on_device_rename() argument
712 if (dm_ima_alloc_and_copy_device_data(md, &new_device_data, in dm_ima_measure_on_device_rename()
713 md->ima.active_table.num_targets, noio)) in dm_ima_measure_on_device_rename()
716 if (dm_ima_alloc_and_copy_name_uuid(md, &new_dev_name, &new_dev_uuid, noio)) in dm_ima_measure_on_device_rename()
723 r = dm_ima_alloc_and_copy_capacity_str(md, &capacity_str, noio); in dm_ima_measure_on_device_rename()
727 old_device_data = md->ima.active_table.device_metadata; in dm_ima_measure_on_device_rename()
729 md->ima.active_table.device_metadata = new_device_data; in dm_ima_measure_on_device_rename()
730 md->ima.active_table.device_metadata_len = strlen(new_device_data); in dm_ima_measure_on_device_rename()