aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/security/integrity/ima/ima_api.c
diff options
context:
space:
mode:
authorRoberto Sassu <roberto.sassu@huawei.com>2020-03-25 11:47:08 +0100
committerMimi Zohar <zohar@linux.ibm.com>2020-04-19 22:03:39 -0400
commit7ca79645a1f8837c3850b881a2c0b43cfba5dc36 (patch)
tree77ea4f7f46f5c34fe1beb238f6f66a14f5deb20f /security/integrity/ima/ima_api.c
parentima: Evaluate error in init_ima() (diff)
downloadwireguard-linux-7ca79645a1f8837c3850b881a2c0b43cfba5dc36.tar.xz
wireguard-linux-7ca79645a1f8837c3850b881a2c0b43cfba5dc36.zip
ima: Store template digest directly in ima_template_entry
In preparation for the patch that calculates a digest for each allocated PCR bank, this patch passes to ima_calc_field_array_hash() the ima_template_entry structure, so that digests can be directly stored in that structure instead of ima_digest_data. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Diffstat (limited to 'security/integrity/ima/ima_api.c')
-rw-r--r--security/integrity/ima/ima_api.c12
1 files changed, 1 insertions, 11 deletions
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index f6bc00914aa5..2ef5a40c7ca5 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -96,26 +96,16 @@ int ima_store_template(struct ima_template_entry *entry,
static const char audit_cause[] = "hashing_error";
char *template_name = entry->template_desc->name;
int result;
- struct {
- struct ima_digest_data hdr;
- char digest[TPM_DIGEST_SIZE];
- } hash;
if (!violation) {
- int num_fields = entry->template_desc->num_fields;
-
- /* this function uses default algo */
- hash.hdr.algo = HASH_ALGO_SHA1;
result = ima_calc_field_array_hash(&entry->template_data[0],
- entry->template_desc,
- num_fields, &hash.hdr);
+ entry);
if (result < 0) {
integrity_audit_msg(AUDIT_INTEGRITY_PCR, inode,
template_name, op,
audit_cause, result, 0);
return result;
}
- memcpy(entry->digest, hash.hdr.digest, hash.hdr.length);
}
entry->pcr = pcr;
result = ima_add_template_entry(entry, violation, op, inode, filename);