dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Tushar Sugandhi <tusharsu@linux.microsoft.com>
To: dm-devel@redhat.com, agk@redhat.com, snitzer@redhat.com
Cc: sfr@canb.auug.org.au, zohar@linux.ibm.com,
	nramas@linux.microsoft.com, public@thson.de,
	tusharsu@linux.microsoft.com, linux-integrity@vger.kernel.org
Subject: [dm-devel] [PATCH 5/6] dm ima: update dm target attributes for ima measurements
Date: Fri, 13 Aug 2021 14:38:00 -0700	[thread overview]
Message-ID: <20210813213801.297051-6-tusharsu@linux.microsoft.com> (raw)
In-Reply-To: <20210813213801.297051-1-tusharsu@linux.microsoft.com>

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 <tusharsu@linux.microsoft.com>
Suggested-by: Thore Sommer <public@thson.de>
---
 drivers/md/dm-integrity.c     |  1 -
 drivers/md/dm-mpath.c         | 26 ++++++++++++++++++--------
 drivers/md/dm-verity-target.c |  2 ++
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 40f8116c8e44..6e0b2f2f5911 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -3328,7 +3328,6 @@ static void dm_integrity_status(struct dm_target *ti, status_type_t type,
 		DMEMIT(",journal_sectors=%u", ic->initial_sectors - SB_SECTORS);
 		DMEMIT(",interleave_sectors=%u", 1U << ic->sb->log2_interleave_sectors);
 		DMEMIT(",buffer_sectors=%u", 1U << ic->log2_buffer_sectors);
-		DMEMIT(",mode=%c", ic->mode);
 		DMEMIT(";");
 		break;
 	}
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index c3c514a9edbb..694aaca4eea2 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1790,7 +1790,7 @@ static void multipath_resume(struct dm_target *ti)
 static void multipath_status(struct dm_target *ti, status_type_t type,
 			     unsigned status_flags, char *result, unsigned maxlen)
 {
-	int sz = 0;
+	int sz = 0, pg_counter, pgpath_counter;
 	unsigned long flags;
 	struct multipath *m = ti->private;
 	struct priority_group *pg;
@@ -1906,7 +1906,12 @@ static void multipath_status(struct dm_target *ti, status_type_t type,
 		break;
 
 	case STATUSTYPE_IMA:
+		sz = 0; /*reset the result pointer*/
+
 		DMEMIT_TARGET_NAME_VERSION(ti->type);
+		DMEMIT(",nr_priority_groups=%u", m->nr_priority_groups);
+
+		pg_counter = 0;
 		list_for_each_entry(pg, &m->priority_groups, list) {
 			if (pg->bypassed)
 				state = 'D';	/* Disabled */
@@ -1914,21 +1919,26 @@ static void multipath_status(struct dm_target *ti, status_type_t type,
 				state = 'A';	/* Currently Active */
 			else
 				state = 'E';	/* Enabled */
-			DMEMIT(",pg_state=%c", state);
-			DMEMIT(",nr_pgpaths=%u", pg->nr_pgpaths);
-			DMEMIT(",path_selector_name=%s", pg->ps.type->name);
+			DMEMIT(",pg_state_%d=%c", pg_counter, state);
+			DMEMIT(",nr_pgpaths_%d=%u", pg_counter, pg->nr_pgpaths);
+			DMEMIT(",path_selector_name_%d=%s", pg_counter, pg->ps.type->name);
 
+			pgpath_counter = 0;
 			list_for_each_entry(p, &pg->pgpaths, list) {
-				DMEMIT(",path_name=%s,is_active=%c,fail_count=%u",
-				       p->path.dev->name, p->is_active ? 'A' : 'F',
-				       p->fail_count);
+				DMEMIT(",path_name_%d_%d=%s,is_active_%d_%d=%c,fail_count_%d_%d=%u",
+				       pg_counter, pgpath_counter, p->path.dev->name,
+				       pg_counter, pgpath_counter, p->is_active ? 'A' : 'F',
+				       pg_counter, pgpath_counter, p->fail_count);
 				if (pg->ps.type->status) {
-					DMEMIT(",path_selector_status=");
+					DMEMIT(",path_selector_status_%d_%d=",
+					       pg_counter, pgpath_counter);
 					sz += pg->ps.type->status(&pg->ps, &p->path,
 								  type, result + sz,
 								  maxlen - sz);
 				}
+				pgpath_counter++;
 			}
+			pg_counter++;
 		}
 		DMEMIT(";");
 		break;
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index bfefa100c265..22a5ac82446a 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -794,6 +794,8 @@ static void verity_status(struct dm_target *ti, status_type_t type,
 
 		DMEMIT(",ignore_zero_blocks=%c", v->zero_digest ? 'y' : 'n');
 		DMEMIT(",check_at_most_once=%c", v->validated_blocks ? 'y' : 'n');
+		if (v->signature_key_desc)
+			DMEMIT(",root_hash_sig_key_desc=%s", v->signature_key_desc);
 
 		if (v->mode != DM_VERITY_MODE_EIO) {
 			DMEMIT(",verity_mode=");
-- 
2.32.0


--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  parent reply	other threads:[~2021-08-13 21:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 21:37 [dm-devel] [PATCH 0/6] updates to device mapper target measurement using ima Tushar Sugandhi
2021-08-13 21:37 ` [dm-devel] [PATCH 1/6] dm ima: prefix dm table hashes in ima log with hash algorithm Tushar Sugandhi
2021-08-13 21:37 ` [dm-devel] [PATCH 2/6] dm ima: add version info to dm related events in ima log Tushar Sugandhi
2021-08-13 21:37 ` [dm-devel] [PATCH 3/6] dm ima: prefix ima event name related to device mapper with dm_ Tushar Sugandhi
2021-08-13 21:37 ` [dm-devel] [PATCH 4/6] dm ima: add a warning in dm_init if duplicate ima events are not measured Tushar Sugandhi
2021-08-13 21:38 ` Tushar Sugandhi [this message]
2021-08-13 21:38 ` [dm-devel] [PATCH 6/6] dm ima: update dm documentation for ima measurement support Tushar Sugandhi
2021-08-20 20:19 ` [dm-devel] [PATCH 0/6] updates to device mapper target measurement using ima Mike Snitzer
2021-08-23 17:18   ` Tushar Sugandhi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210813213801.297051-6-tusharsu@linux.microsoft.com \
    --to=tusharsu@linux.microsoft.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=nramas@linux.microsoft.com \
    --cc=public@thson.de \
    --cc=sfr@canb.auug.org.au \
    --cc=snitzer@redhat.com \
    --cc=zohar@linux.ibm.com \
    --subject='Re: [dm-devel] [PATCH 5/6] dm ima: update dm target attributes for ima measurements' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).