Skip to content

Commit 33ace4c

Browse files
Tushar Sugandhisnitm
authored andcommitted
dm ima: update dm target attributes for ima measurements
Certain DM targets ('integrity', 'multipath', 'verity') need to update the way their attributes are recorded in the ima log, so that the attestation servers can interpret the data correctly and decide if the devices meet the attestation requirements. For instance, the "mode=%c" attribute in the 'integrity' target is measured twice, the 'verity' target is missing the attribute "root_hash_sig_key_desc=%s", and the 'multipath' target needs to index the attributes properly. Update 'integrity' target to remove the duplicate measurement of the attribute "mode=%c". Add "root_hash_sig_key_desc=%s" attribute for the 'verity' target. Index various attributes in 'multipath' target. Also, add "nr_priority_groups=%u" attribute to 'multipath' target to record the number of priority groups. Signed-off-by: Tushar Sugandhi <[email protected]> Suggested-by: Thore Sommer <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent f1cd6cb commit 33ace4c

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

drivers/md/dm-integrity.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3328,7 +3328,6 @@ static void dm_integrity_status(struct dm_target *ti, status_type_t type,
33283328
DMEMIT(",journal_sectors=%u", ic->initial_sectors - SB_SECTORS);
33293329
DMEMIT(",interleave_sectors=%u", 1U << ic->sb->log2_interleave_sectors);
33303330
DMEMIT(",buffer_sectors=%u", 1U << ic->log2_buffer_sectors);
3331-
DMEMIT(",mode=%c", ic->mode);
33323331
DMEMIT(";");
33333332
break;
33343333
}

drivers/md/dm-mpath.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ static void multipath_resume(struct dm_target *ti)
17901790
static void multipath_status(struct dm_target *ti, status_type_t type,
17911791
unsigned status_flags, char *result, unsigned maxlen)
17921792
{
1793-
int sz = 0;
1793+
int sz = 0, pg_counter, pgpath_counter;
17941794
unsigned long flags;
17951795
struct multipath *m = ti->private;
17961796
struct priority_group *pg;
@@ -1906,29 +1906,39 @@ static void multipath_status(struct dm_target *ti, status_type_t type,
19061906
break;
19071907

19081908
case STATUSTYPE_IMA:
1909+
sz = 0; /*reset the result pointer*/
1910+
19091911
DMEMIT_TARGET_NAME_VERSION(ti->type);
1912+
DMEMIT(",nr_priority_groups=%u", m->nr_priority_groups);
1913+
1914+
pg_counter = 0;
19101915
list_for_each_entry(pg, &m->priority_groups, list) {
19111916
if (pg->bypassed)
19121917
state = 'D'; /* Disabled */
19131918
else if (pg == m->current_pg)
19141919
state = 'A'; /* Currently Active */
19151920
else
19161921
state = 'E'; /* Enabled */
1917-
DMEMIT(",pg_state=%c", state);
1918-
DMEMIT(",nr_pgpaths=%u", pg->nr_pgpaths);
1919-
DMEMIT(",path_selector_name=%s", pg->ps.type->name);
1922+
DMEMIT(",pg_state_%d=%c", pg_counter, state);
1923+
DMEMIT(",nr_pgpaths_%d=%u", pg_counter, pg->nr_pgpaths);
1924+
DMEMIT(",path_selector_name_%d=%s", pg_counter, pg->ps.type->name);
19201925

1926+
pgpath_counter = 0;
19211927
list_for_each_entry(p, &pg->pgpaths, list) {
1922-
DMEMIT(",path_name=%s,is_active=%c,fail_count=%u",
1923-
p->path.dev->name, p->is_active ? 'A' : 'F',
1924-
p->fail_count);
1928+
DMEMIT(",path_name_%d_%d=%s,is_active_%d_%d=%c,fail_count_%d_%d=%u",
1929+
pg_counter, pgpath_counter, p->path.dev->name,
1930+
pg_counter, pgpath_counter, p->is_active ? 'A' : 'F',
1931+
pg_counter, pgpath_counter, p->fail_count);
19251932
if (pg->ps.type->status) {
1926-
DMEMIT(",path_selector_status=");
1933+
DMEMIT(",path_selector_status_%d_%d=",
1934+
pg_counter, pgpath_counter);
19271935
sz += pg->ps.type->status(&pg->ps, &p->path,
19281936
type, result + sz,
19291937
maxlen - sz);
19301938
}
1939+
pgpath_counter++;
19311940
}
1941+
pg_counter++;
19321942
}
19331943
DMEMIT(";");
19341944
break;

drivers/md/dm-verity-target.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ static void verity_status(struct dm_target *ti, status_type_t type,
794794

795795
DMEMIT(",ignore_zero_blocks=%c", v->zero_digest ? 'y' : 'n');
796796
DMEMIT(",check_at_most_once=%c", v->validated_blocks ? 'y' : 'n');
797+
if (v->signature_key_desc)
798+
DMEMIT(",root_hash_sig_key_desc=%s", v->signature_key_desc);
797799

798800
if (v->mode != DM_VERITY_MODE_EIO) {
799801
DMEMIT(",verity_mode=");

0 commit comments

Comments
 (0)