From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: linux-audit@redhat.com
Cc: David Safford <safford@watson.ibm.com>,
James Morris <jmorris@namei.org>, Mimi Zohar <zohar@us.ibm.com>
Subject: [PATCH 5/8] integrity: IMA policy open
Date: Fri, 6 Feb 2009 14:52:10 -0500 [thread overview]
Message-ID: <f4bd857bc8ed997c25ec06b56ef8064aafa6d4f3.1233946566.git.zohar@linux.vnet.ibm.com> (raw)
In-Reply-To: <cover.1233946566.git.zohar@linux.vnet.ibm.com>
In-Reply-To: <cover.1233946566.git.zohar@linux.vnet.ibm.com>
Sequentialize access to the policy file
- permit multiple attempts to replace default policy with a valid policy
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
---
diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
index 95ef1ca..573780c 100644
--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -277,16 +277,30 @@ static struct dentry *runtime_measurements_count;
static struct dentry *violations;
static struct dentry *ima_policy;
+static atomic_t policy_opencount = ATOMIC_INIT(1);
+/*
+ * ima_open_policy: sequentialize access to the policy file
+ */
+int ima_open_policy(struct inode * inode, struct file * filp)
+{
+ if (atomic_dec_and_test(&policy_opencount))
+ return 0;
+ return -EBUSY;
+}
+
/*
* ima_release_policy - start using the new measure policy rules.
*
* Initially, ima_measure points to the default policy rules, now
- * point to the new policy rules, and remove the securityfs policy file.
+ * point to the new policy rules, and remove the securityfs policy file,
+ * assuming a valid policy.
*/
static int ima_release_policy(struct inode *inode, struct file *file)
{
if (!valid_policy) {
ima_delete_rules();
+ valid_policy = 1;
+ atomic_set(&policy_opencount, 1);
return 0;
}
ima_update_policy();
@@ -296,6 +310,7 @@ static int ima_release_policy(struct inode *inode, struct file *file)
}
static struct file_operations ima_measure_policy_ops = {
+ .open = ima_open_policy,
.write = ima_write_policy,
.release = ima_release_policy
};
--
1.5.6.6
next prev parent reply other threads:[~2009-02-06 19:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-06 19:52 [PATCH 0/8] integrity Mimi Zohar
2009-02-06 19:52 ` [PATCH 1/8] integrity: IMA hooks Mimi Zohar
2009-02-06 19:52 ` [PATCH 2/8] integrity: IMA as an integrity service provider Mimi Zohar
2009-02-06 22:04 ` Steve Grubb
2009-02-09 2:42 ` Mimi Zohar
2009-02-09 14:51 ` Steve Grubb
2009-02-09 23:20 ` Mimi Zohar
2009-03-06 22:07 ` Eric Paris
2009-03-09 11:07 ` Mimi Zohar
2009-02-06 19:52 ` [PATCH 3/8] integrity: IMA display Mimi Zohar
2009-02-06 19:52 ` [PATCH 4/8] integrity: IMA policy Mimi Zohar
2009-02-06 19:52 ` Mimi Zohar [this message]
2009-02-06 19:52 ` [PATCH 6/8] Integrity: IMA file free imbalance Mimi Zohar
2009-02-06 19:52 ` [PATCH 7/8] Integrity: IMA update maintainers Mimi Zohar
2009-02-06 19:52 ` [PATCH 8/8] IMA: fix ima_delete_rules() definition Mimi Zohar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f4bd857bc8ed997c25ec06b56ef8064aafa6d4f3.1233946566.git.zohar@linux.vnet.ibm.com \
--to=zohar@linux.vnet.ibm.com \
--cc=jmorris@namei.org \
--cc=linux-audit@redhat.com \
--cc=safford@watson.ibm.com \
--cc=zohar@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox