[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <512bd4902270ae50b7cfaa1467e12817130290b4.1398259638.git.d.kasatkin@samsung.com>
Date: Wed, 23 Apr 2014 16:30:32 +0300
From: Dmitry Kasatkin <d.kasatkin@...sung.com>
To: zohar@...ux.vnet.ibm.com, dhowells@...hat.com, jmorris@...ei.org
Cc: roberto.sassu@...ito.it, linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org,
Dmitry Kasatkin <d.kasatkin@...sung.com>
Subject: [PATCH 14/20] ima: check if policy was set at open
IMA default behavior is to forbid more than one policy update.
It easier to check at open phase if policy was already set,
so it would not be necessary to perform useless policy parsing
and removing of sysfs entry.
Signed-off-by: Dmitry Kasatkin <d.kasatkin@...sung.com>
---
security/integrity/ima/ima.h | 1 +
security/integrity/ima/ima_fs.c | 7 +++++--
security/integrity/ima/ima_policy.c | 16 +++++++++-------
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index a5d5ccb..3b90b60 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -166,6 +166,7 @@ int ima_match_policy(struct dentry *dentry, enum ima_hooks func, int mask,
int flags);
void ima_init_policy(void);
void ima_update_policy(void);
+bool ima_default_policy(void);
ssize_t ima_parse_add_rule(char *);
void ima_delete_rules(void);
diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
index 71f0d8f..34ae5f2 100644
--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -304,6 +304,11 @@ static int ima_open_policy(struct inode *inode, struct file *filp)
return -EACCES;
if (test_and_set_bit(IMA_FS_BUSY, &ima_fs_flags))
return -EBUSY;
+ if (!ima_default_policy()) {
+ /* policy was already set*/
+ clear_bit(IMA_FS_BUSY, &ima_fs_flags);
+ return -EACCES;
+ }
return 0;
}
@@ -321,8 +326,6 @@ static int ima_release_policy(struct inode *inode, struct file *file)
valid_policy = 1;
} else {
ima_update_policy();
- securityfs_remove(ima_policy);
- ima_policy = NULL;
}
clear_bit(IMA_FS_BUSY, &ima_fs_flags);
return 0;
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index 9b8121b..b24e7d1 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -345,6 +345,11 @@ void __init ima_init_policy(void)
ima_rules = &ima_default_rules;
}
+bool ima_default_policy(void)
+{
+ return ima_rules == &ima_default_rules;
+}
+
/**
* ima_update_policy - update default_rules with new measure rules
*
@@ -355,15 +360,12 @@ void __init ima_init_policy(void)
void ima_update_policy(void)
{
static const char op[] = "policy_update";
- const char *cause = "already exists";
- int result = 1;
+ const char *cause = "complete";
+ int result = 0;
int audit_info = 0;
- if (ima_rules == &ima_default_rules) {
- ima_rules = &ima_policy_rules;
- cause = "complete";
- result = 0;
- }
+ ima_rules = &ima_policy_rules;
+
integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
NULL, op, cause, result, audit_info);
}
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists