From: Amy Griffis <amy.griffis@hp.com>
To: linux-audit@redhat.com
Subject: Re: [PATCH git 3/3] make audit_del_rule() use audit_find_rule()
Date: Mon, 5 Jun 2006 13:46:45 -0400 [thread overview]
Message-ID: <20060605174645.GD24778@zk3.dec.com> (raw)
In-Reply-To: <20060605174105.GA24778@zk3.dec.com>
Now that we've added audit_find_rule(), make audit_del_rule() use it
too.
Signed-off-by: Amy Griffis <amy.griffis@hp.com>
---
kernel/auditfilter.c | 101 +++++++++++++++++++-------------------------------
1 files changed, 39 insertions(+), 62 deletions(-)
49331df422d7d3f7b1d387c4373bb3113f45f04d
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 3cedc73..461f404 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1102,83 +1102,60 @@ error:
return err;
}
-/* Rule removal helper.
- * Caller must hold audit_filter_mutex. */
-static inline int audit_do_del_rule(struct audit_entry *entry,
- struct list_head *list,
- struct list_head *inotify_list)
+/* Remove an existing rule from filterlist. */
+static inline int audit_del_rule(struct audit_entry *entry,
+ struct list_head *list)
{
struct audit_entry *e;
+ struct audit_field *inode_f = entry->rule.inode_f;
+ struct audit_watch *watch, *tmp_watch = entry->rule.watch;
+ LIST_HEAD(inotify_list);
+ int h, ret = 0;
- list_for_each_entry(e, list, list) {
- struct audit_watch *watch = e->rule.watch;
+ if (inode_f) {
+ h = audit_hash_ino(inode_f->val);
+ list = &audit_inode_hash[h];
+ }
- if (audit_compare_rule(&entry->rule, &e->rule))
- continue;
+ mutex_lock(&audit_filter_mutex);
+ e = audit_find_rule(entry, list);
+ if (!e) {
+ mutex_unlock(&audit_filter_mutex);
+ ret = -ENOENT;
+ goto out;
+ }
- if (watch) {
- struct audit_parent *parent = watch->parent;
+ watch = e->rule.watch;
+ if (watch) {
+ struct audit_parent *parent = watch->parent;
- list_del(&e->rule.rlist);
+ list_del(&e->rule.rlist);
- if (list_empty(&watch->rules)) {
- audit_remove_watch(watch);
+ if (list_empty(&watch->rules)) {
+ audit_remove_watch(watch);
- if (list_empty(&parent->watches)) {
- /* Put parent on the inotify
- * un-registration list. Grab
- * a reference before releasing
- * audit_filter_mutex, to be released in
- * audit_inotify_unregister(). */
- list_add(&parent->ilist, inotify_list);
- get_inotify_watch(&parent->wdata);
- }
+ if (list_empty(&parent->watches)) {
+ /* Put parent on the inotify un-registration
+ * list. Grab a reference before releasing
+ * audit_filter_mutex, to be released in
+ * audit_inotify_unregister(). */
+ list_add(&parent->ilist, &inotify_list);
+ get_inotify_watch(&parent->wdata);
}
}
-
- list_del_rcu(&e->list);
- call_rcu(&e->rcu, audit_free_rule_rcu);
-
- return 0;
}
- return -ENOENT; /* No matching rule */
-}
-/* Remove an existing rule from filterlist. */
-static inline int audit_del_rule(struct audit_entry *entry,
- struct list_head *list)
-{
- int h, ret;
- struct audit_field *inode_f = entry->rule.inode_f;
- struct audit_watch *watch = entry->rule.watch;
- LIST_HEAD(inotify_list);
+ list_del_rcu(&e->list);
+ call_rcu(&e->rcu, audit_free_rule_rcu);
- if (watch) {
- mutex_lock(&audit_filter_mutex);
- /* we don't know the inode number, so must walk entire hash */
- for (h = 0; h < AUDIT_INODE_BUCKETS; h++) {
- list = &audit_inode_hash[h];
- ret = audit_do_del_rule(entry, list, &inotify_list);
- if (!ret)
- break;
- }
- mutex_unlock(&audit_filter_mutex);
-
- if (!list_empty(&inotify_list))
- audit_inotify_unregister(&inotify_list);
+ mutex_unlock(&audit_filter_mutex);
- /* match initial get for tmp watch */
- audit_put_watch(watch);
+ if (!list_empty(&inotify_list))
+ audit_inotify_unregister(&inotify_list);
- } else {
- if (inode_f) {
- h = audit_hash_ino(inode_f->val);
- list = &audit_inode_hash[h];
- }
- mutex_lock(&audit_filter_mutex);
- ret = audit_do_del_rule(entry, list, &inotify_list);
- mutex_unlock(&audit_filter_mutex);
- }
+out:
+ if (tmp_watch)
+ audit_put_watch(tmp_watch); /* match initial get */
return ret;
}
--
1.3.0
prev parent reply other threads:[~2006-06-05 17:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-05 17:41 [PATCH git 0/3] audit inode hash bug fix, cleanup Amy Griffis
2006-06-05 17:42 ` [PATCH git 1/3] fix inode rules not added to inode hash Amy Griffis
2006-06-05 17:45 ` [PATCH git 2/3] don't allow duplicate inode or watch rules Amy Griffis
2006-06-05 17:46 ` Amy Griffis [this message]
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=20060605174645.GD24778@zk3.dec.com \
--to=amy.griffis@hp.com \
--cc=linux-audit@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.