Skip to contentSkip to conversation

ima: fix violation measurement list record

PATCH In review Mimi Zohar 2 participants 2 messages Jul 5, 2022

Subsystems (4)
lore
Share & tools
lore

Mimi Zohar

author maintainer
#0 lore raw

PATCH v2 1/1 ima: fix violation measurement list record

Although the violation digest in the IMA measurement list is always zeroes, the size of the digest should be based on the hash algorithm. Until recently the hash algorithm was hard coded to sha1. Fix the violation digest size included in the IMA measurement list.

This is just a cosmetic change which should not affect attestation.

Fixes 09091c44cb73 ("ima: use IMA default hash algorithm for integrity violations")
---
 security/integrity/ima/ima_template_lib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/integrity/ima/ima_template_lib.c +2 -2
index c877f01a5471..34a8cabe09b1 100644
@@ -324,9 +324,9 @@ static int ima_eventdigest_init_common(const u8 *digest, u32 digestsize,
 		/*
 		 * If digest is NULL, the event being recorded is a violation.
 		 * Make room for the digest by increasing the offset of
-		 * IMA_DIGEST_SIZE.
+		 * hash algorithm digest size.
 		 */
-		offset += IMA_DIGEST_SIZE;
+		offset += hash_digest_size[hash_algo];
 
 	return ima_write_template_field_data(buffer, offset + digestsize,
 					     fmt, field_data);
Signature · 1 line
2.27.0
Tested-by on v2 1/1
#1 lore raw
Quoted 10 lines · Mimi Zohar

Although the violation digest in the IMA measurement list is always zeroes, the size of the digest should be based on the hash algorithm. Until recently the hash algorithm was hard coded to sha1. Fix the violation digest size included in the IMA measurement list.

This is just a cosmetic change which should not affect attestation.

Fixes 09091c44cb73 ("ima: use IMA default hash algorithm for integrity violations")
Quoted 20 lines
---
  security/integrity/ima/ima_template_lib.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
security/integrity/ima/ima_template_lib.c +2 -2
index c877f01a5471..34a8cabe09b1 100644
@@ -324,9 +324,9 @@ static int ima_eventdigest_init_common(const u8 *digest, u32 digestsize,
  		/*
  		 * If digest is NULL, the event being recorded is a violation.
  		 * Make room for the digest by increasing the offset of
-		 * IMA_DIGEST_SIZE.
+		 * hash algorithm digest size.
  		 */
-		offset += IMA_DIGEST_SIZE;
+		offset += hash_digest_size[hash_algo];
 
  	return ima_write_template_field_data(buffer, offset + digestsize,
  					     fmt, field_data);