aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasha Levin <sasha.levin@oracle.com>2015-12-22 08:51:23 -0500
committerMimi Zohar <zohar@linux.vnet.ibm.com>2015-12-24 18:56:45 -0500
commit0112721df4edbdd07b800813300d76811572f080 (patch)
tree9ad07cfcfdd6aedb1c0764187b95646d05b83b1a
parent92cc916638a48f285736cd5541536e2e1b73ecf8 (diff)
IMA: policy can be updated zero times
Commit "IMA: policy can now be updated multiple times" assumed that the policy would be updated at least once. If there are zero updates, the temporary list head object will get added to the policy list, and later dereferenced as an IMA policy object, which means that invalid memory will be accessed. Changelog: - Move list_empty() test to ima_release_policy(), before audit msg - Mimi Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
-rw-r--r--security/integrity/ima/ima.h1
-rw-r--r--security/integrity/ima/ima_fs.c5
-rw-r--r--security/integrity/ima/ima_policy.c8
3 files changed, 14 insertions, 0 deletions
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index 917407fb7e94..585af61ed399 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -166,6 +166,7 @@ void ima_update_policy(void);
166void ima_update_policy_flag(void); 166void ima_update_policy_flag(void);
167ssize_t ima_parse_add_rule(char *); 167ssize_t ima_parse_add_rule(char *);
168void ima_delete_rules(void); 168void ima_delete_rules(void);
169int ima_check_policy(void);
169void *ima_policy_start(struct seq_file *m, loff_t *pos); 170void *ima_policy_start(struct seq_file *m, loff_t *pos);
170void *ima_policy_next(struct seq_file *m, void *v, loff_t *pos); 171void *ima_policy_next(struct seq_file *m, void *v, loff_t *pos);
171void ima_policy_stop(struct seq_file *m, void *v); 172void ima_policy_stop(struct seq_file *m, void *v);
diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
index eebb985fd083..3caed6de610c 100644
--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -355,6 +355,11 @@ static int ima_release_policy(struct inode *inode, struct file *file)
355 if ((file->f_flags & O_ACCMODE) == O_RDONLY) 355 if ((file->f_flags & O_ACCMODE) == O_RDONLY)
356 return 0; 356 return 0;
357 357
358 if (valid_policy && ima_check_policy() < 0) {
359 cause = "failed";
360 valid_policy = 0;
361 }
362
358 pr_info("IMA: policy update %s\n", cause); 363 pr_info("IMA: policy update %s\n", cause);
359 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, NULL, 364 integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, NULL,
360 "policy_update", cause, !valid_policy, 0); 365 "policy_update", cause, !valid_policy, 0);
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index ba5d2fc61394..0a3b781f18e5 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -416,6 +416,14 @@ void __init ima_init_policy(void)
416 ima_rules = &ima_default_rules; 416 ima_rules = &ima_default_rules;
417} 417}
418 418
419/* Make sure we have a valid policy, at least containing some rules. */
420int ima_check_policy()
421{
422 if (list_empty(&ima_temp_rules))
423 return -EINVAL;
424 return 0;
425}
426
419/** 427/**
420 * ima_update_policy - update default_rules with new measure rules 428 * ima_update_policy - update default_rules with new measure rules
421 * 429 *