Skip to contentSkip to conversation

ima: fix violation measurement list record

PATCH Superseded Mimi Zohar 2 participants 3 messages Jul 1, 2022

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Mimi Zohar

author maintainer
#0 lore raw

PATCH 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 which should not affect attestation.

Fixes 09091c44cb73 ("ima: use IMA default hash algorithm for integrity violations")
---
 security/integrity/ima/ima_template_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_template_lib.c +1 -1
index c877f01a5471..67359845c975 100644
@@ -326,7 +326,7 @@ static int ima_eventdigest_init_common(const u8 *digest, u32 digestsize,
 		 * Make room for the digest by increasing the offset of
 		 * IMA_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
author maintainer
#2 lore raw
In reply to Jonathan McDowell
Quoted 15 lines · Jonathan McDowell
Quoted 14 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 which should not affect attestation.

Fixes 09091c44cb73 ("ima: use IMA default hash algorithm for integrity violations")
---
 security/integrity/ima/ima_template_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

security/integrity/ima/ima_template_lib.c static int ima_eventdigest_init_common(const u8 *digest, u32 digestsize, · line 329

Quoted 10 lines
security/integrity/ima/ima_template_lib.c +1 -1
index c877f01a5471..67359845c975 100644
@@ -326,7 +326,7 @@ static int ima_eventdigest_init_common(const u8 *digest, u32 digestsize,
 		 * Make room for the digest by increasing the offset of
 		 * IMA_DIGEST_SIZE.
 		 */
-		offset += IMA_DIGEST_SIZE;
+		offset += hash_digest_size[hash_algo];

Update the comment as well?

Yes, of course. Thank you for catching it!

Mimi

Quoted 9 lines
Quoted 6 lines
security/integrity/ima/ima_template_lib.c +0 -0
 	return ima_write_template_field_data(buffer, offset + digestsize,
 					     fmt, field_data);
Signature · 1 line
2.27.0

J.

#1 lore raw
In reply to Mimi Zohar
Quoted 19 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 which should not affect attestation.

Fixes 09091c44cb73 ("ima: use IMA default hash algorithm for integrity violations")
---
 security/integrity/ima/ima_template_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_template_lib.c +0 -0
index c877f01a5471..67359845c975 100644

security/integrity/ima/ima_template_lib.c static int ima_eventdigest_init_common(const u8 *digest, u32 digestsize, · line 329

Quoted 5 lines
security/integrity/ima/ima_template_lib.c +1 -1
@@ -326,7 +326,7 @@ static int ima_eventdigest_init_common(const u8 *digest, u32 digestsize,
 		 * Make room for the digest by increasing the offset of
 		 * IMA_DIGEST_SIZE.
 		 */
-		offset += IMA_DIGEST_SIZE;
+		offset += hash_digest_size[hash_algo];

Update the comment as well?

Quoted 5 lines
security/integrity/ima/ima_template_lib.c +0 -0
 	return ima_write_template_field_data(buffer, offset + digestsize,
 					     fmt, field_data);
Signature · 1 line
2.27.0

J.

Signature · 1 line
This isn't an office. It's Hell with fluorescent lighting.