|
@@ -288,7 +288,12 @@ static struct dentry *runtime_measurements_count;
|
|
|
static struct dentry *violations;
|
|
|
static struct dentry *ima_policy;
|
|
|
|
|
|
-static atomic_t policy_opencount = ATOMIC_INIT(1);
|
|
|
+enum ima_fs_flags {
|
|
|
+ IMA_FS_BUSY,
|
|
|
+};
|
|
|
+
|
|
|
+static unsigned long ima_fs_flags;
|
|
|
+
|
|
|
/*
|
|
|
* ima_open_policy: sequentialize access to the policy file
|
|
|
*/
|
|
@@ -297,9 +302,9 @@ static int ima_open_policy(struct inode *inode, struct file *filp)
|
|
|
/* No point in being allowed to open it if you aren't going to write */
|
|
|
if (!(filp->f_flags & O_WRONLY))
|
|
|
return -EACCES;
|
|
|
- if (atomic_dec_and_test(&policy_opencount))
|
|
|
- return 0;
|
|
|
- return -EBUSY;
|
|
|
+ if (test_and_set_bit(IMA_FS_BUSY, &ima_fs_flags))
|
|
|
+ return -EBUSY;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -311,12 +316,16 @@ static int ima_open_policy(struct inode *inode, struct file *filp)
|
|
|
*/
|
|
|
static int ima_release_policy(struct inode *inode, struct file *file)
|
|
|
{
|
|
|
- pr_info("IMA: policy update %s\n",
|
|
|
- valid_policy ? "completed" : "failed");
|
|
|
+ const char *cause = valid_policy ? "completed" : "failed";
|
|
|
+
|
|
|
+ pr_info("IMA: policy update %s\n", cause);
|
|
|
+ integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, NULL,
|
|
|
+ "policy_update", cause, !valid_policy, 0);
|
|
|
+
|
|
|
if (!valid_policy) {
|
|
|
ima_delete_rules();
|
|
|
valid_policy = 1;
|
|
|
- atomic_set(&policy_opencount, 1);
|
|
|
+ clear_bit(IMA_FS_BUSY, &ima_fs_flags);
|
|
|
return 0;
|
|
|
}
|
|
|
ima_update_policy();
|