summaryrefslogtreecommitdiffstats
path: root/security/integrity
diff options
context:
space:
mode:
authorEric Richter <erichte@linux.vnet.ibm.com>2016-06-01 14:14:03 -0400
committerMimi Zohar <zohar@linux.vnet.ibm.com>2016-06-30 01:14:21 -0400
commit14b1da85bbe9a59c5e01123a06dea4c4758a6db9 (patch)
tree1a61fea1cd6101588305467af50337d414420b4f /security/integrity
parent725de7fabb9fe4ca388c780ad4644352f2f06ccc (diff)
ima: include pcr for each measurement log entry
The IMA measurement list entries include the Kconfig defined PCR value. This patch defines a new ima_template_entry field for including the PCR as specified in the policy rule. Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Diffstat (limited to 'security/integrity')
-rw-r--r--security/integrity/ima/ima.h6
-rw-r--r--security/integrity/ima/ima_api.c10
-rw-r--r--security/integrity/ima/ima_init.c3
-rw-r--r--security/integrity/ima/ima_main.c2
4 files changed, 13 insertions, 8 deletions
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index 3c8e71e9e049..db25f54a04fe 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -88,6 +88,7 @@ struct ima_template_desc {
88}; 88};
89 89
90struct ima_template_entry { 90struct ima_template_entry {
91 int pcr;
91 u8 digest[TPM_DIGEST_SIZE]; /* sha1 or md5 measurement hash */ 92 u8 digest[TPM_DIGEST_SIZE]; /* sha1 or md5 measurement hash */
92 struct ima_template_desc *template_desc; /* template descriptor */ 93 struct ima_template_desc *template_desc; /* template descriptor */
93 u32 template_data_len; 94 u32 template_data_len;
@@ -163,13 +164,14 @@ int ima_collect_measurement(struct integrity_iint_cache *iint,
163void ima_store_measurement(struct integrity_iint_cache *iint, struct file *file, 164void ima_store_measurement(struct integrity_iint_cache *iint, struct file *file,
164 const unsigned char *filename, 165 const unsigned char *filename,
165 struct evm_ima_xattr_data *xattr_value, 166 struct evm_ima_xattr_data *xattr_value,
166 int xattr_len); 167 int xattr_len, int pcr);
167void ima_audit_measurement(struct integrity_iint_cache *iint, 168void ima_audit_measurement(struct integrity_iint_cache *iint,
168 const unsigned char *filename); 169 const unsigned char *filename);
169int ima_alloc_init_template(struct ima_event_data *event_data, 170int ima_alloc_init_template(struct ima_event_data *event_data,
170 struct ima_template_entry **entry); 171 struct ima_template_entry **entry);
171int ima_store_template(struct ima_template_entry *entry, int violation, 172int ima_store_template(struct ima_template_entry *entry, int violation,
172 struct inode *inode, const unsigned char *filename); 173 struct inode *inode,
174 const unsigned char *filename, int pcr);
173void ima_free_template_entry(struct ima_template_entry *entry); 175void ima_free_template_entry(struct ima_template_entry *entry);
174const char *ima_d_path(const struct path *path, char **pathbuf); 176const char *ima_d_path(const struct path *path, char **pathbuf);
175 177
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index 225b9cede300..8363ba384992 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -87,7 +87,7 @@ out:
87 */ 87 */
88int ima_store_template(struct ima_template_entry *entry, 88int ima_store_template(struct ima_template_entry *entry,
89 int violation, struct inode *inode, 89 int violation, struct inode *inode,
90 const unsigned char *filename) 90 const unsigned char *filename, int pcr)
91{ 91{
92 static const char op[] = "add_template_measure"; 92 static const char op[] = "add_template_measure";
93 static const char audit_cause[] = "hashing_error"; 93 static const char audit_cause[] = "hashing_error";
@@ -114,6 +114,7 @@ int ima_store_template(struct ima_template_entry *entry,
114 } 114 }
115 memcpy(entry->digest, hash.hdr.digest, hash.hdr.length); 115 memcpy(entry->digest, hash.hdr.digest, hash.hdr.length);
116 } 116 }
117 entry->pcr = pcr;
117 result = ima_add_template_entry(entry, violation, op, inode, filename); 118 result = ima_add_template_entry(entry, violation, op, inode, filename);
118 return result; 119 return result;
119} 120}
@@ -144,7 +145,8 @@ void ima_add_violation(struct file *file, const unsigned char *filename,
144 result = -ENOMEM; 145 result = -ENOMEM;
145 goto err_out; 146 goto err_out;
146 } 147 }
147 result = ima_store_template(entry, violation, inode, filename); 148 result = ima_store_template(entry, violation, inode,
149 filename, CONFIG_IMA_MEASURE_PCR_IDX);
148 if (result < 0) 150 if (result < 0)
149 ima_free_template_entry(entry); 151 ima_free_template_entry(entry);
150err_out: 152err_out:
@@ -253,7 +255,7 @@ out:
253void ima_store_measurement(struct integrity_iint_cache *iint, 255void ima_store_measurement(struct integrity_iint_cache *iint,
254 struct file *file, const unsigned char *filename, 256 struct file *file, const unsigned char *filename,
255 struct evm_ima_xattr_data *xattr_value, 257 struct evm_ima_xattr_data *xattr_value,
256 int xattr_len) 258 int xattr_len, int pcr)
257{ 259{
258 static const char op[] = "add_template_measure"; 260 static const char op[] = "add_template_measure";
259 static const char audit_cause[] = "ENOMEM"; 261 static const char audit_cause[] = "ENOMEM";
@@ -274,7 +276,7 @@ void ima_store_measurement(struct integrity_iint_cache *iint,
274 return; 276 return;
275 } 277 }
276 278
277 result = ima_store_template(entry, violation, inode, filename); 279 result = ima_store_template(entry, violation, inode, filename, pcr);
278 if (!result || result == -EEXIST) 280 if (!result || result == -EEXIST)
279 iint->flags |= IMA_MEASURED; 281 iint->flags |= IMA_MEASURED;
280 if (result < 0) 282 if (result < 0)
diff --git a/security/integrity/ima/ima_init.c b/security/integrity/ima/ima_init.c
index 5d679a685616..32912bd54ead 100644
--- a/security/integrity/ima/ima_init.c
+++ b/security/integrity/ima/ima_init.c
@@ -79,7 +79,8 @@ static int __init ima_add_boot_aggregate(void)
79 } 79 }
80 80
81 result = ima_store_template(entry, violation, NULL, 81 result = ima_store_template(entry, violation, NULL,
82 boot_aggregate_name); 82 boot_aggregate_name,
83 CONFIG_IMA_MEASURE_PCR_IDX);
83 if (result < 0) { 84 if (result < 0) {
84 ima_free_template_entry(entry); 85 ima_free_template_entry(entry);
85 audit_cause = "store_entry"; 86 audit_cause = "store_entry";
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 58b08b25437a..3627afdc932e 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -239,7 +239,7 @@ static int process_measurement(struct file *file, char *buf, loff_t size,
239 239
240 if (action & IMA_MEASURE) 240 if (action & IMA_MEASURE)
241 ima_store_measurement(iint, file, pathname, 241 ima_store_measurement(iint, file, pathname,
242 xattr_value, xattr_len); 242 xattr_value, xattr_len, pcr);
243 if (action & IMA_APPRAISE_SUBMASK) 243 if (action & IMA_APPRAISE_SUBMASK)
244 rc = ima_appraise_measurement(func, iint, file, pathname, 244 rc = ima_appraise_measurement(func, iint, file, pathname,
245 xattr_value, xattr_len, opened); 245 xattr_value, xattr_len, opened);