Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 125745
b: refs/heads/master
c: 1a9d079
h: refs/heads/master
i:
  125743: 4b0d7d9
v: v3
  • Loading branch information
Al Viro committed Jan 4, 2009
1 parent 26ed122 commit 15b2a0a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 57f71a0af4244d9ba3c0bce74b1d2e66e8d520bd
refs/heads/master: 1a9d0797b8977d413435277bf9661efbbd584693
77 changes: 47 additions & 30 deletions trunk/kernel/auditfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1778,49 +1778,66 @@ int audit_filter_type(int type)
return result;
}

static int update_lsm_rule(struct audit_entry *entry)
{
struct audit_entry *nentry;
struct audit_watch *watch;
struct audit_tree *tree;
int err = 0;

if (!security_audit_rule_known(&entry->rule))
return 0;

watch = entry->rule.watch;
tree = entry->rule.tree;
nentry = audit_dupe_rule(&entry->rule, watch);
if (IS_ERR(nentry)) {
/* save the first error encountered for the
* return value */
err = PTR_ERR(nentry);
audit_panic("error updating LSM filters");
if (watch)
list_del(&entry->rule.rlist);
list_del_rcu(&entry->list);
} else {
if (watch) {
list_add(&nentry->rule.rlist, &watch->rules);
list_del(&entry->rule.rlist);
} else if (tree)
list_replace_init(&entry->rule.rlist,
&nentry->rule.rlist);
list_replace_rcu(&entry->list, &nentry->list);
}
call_rcu(&entry->rcu, audit_free_rule_rcu);

return err;
}

/* This function will re-initialize the lsm_rule field of all applicable rules.
* It will traverse the filter lists serarching for rules that contain LSM
* specific filter fields. When such a rule is found, it is copied, the
* LSM field is re-initialized, and the old rule is replaced with the
* updated rule. */
int audit_update_lsm_rules(void)
{
struct audit_entry *entry, *n, *nentry;
struct audit_watch *watch;
struct audit_tree *tree;
struct audit_entry *e, *n;
int i, err = 0;

/* audit_filter_mutex synchronizes the writers */
mutex_lock(&audit_filter_mutex);

for (i = 0; i < AUDIT_NR_FILTERS; i++) {
list_for_each_entry_safe(entry, n, &audit_filter_list[i], list) {
if (!security_audit_rule_known(&entry->rule))
continue;

watch = entry->rule.watch;
tree = entry->rule.tree;
nentry = audit_dupe_rule(&entry->rule, watch);
if (IS_ERR(nentry)) {
/* save the first error encountered for the
* return value */
if (!err)
err = PTR_ERR(nentry);
audit_panic("error updating LSM filters");
if (watch)
list_del(&entry->rule.rlist);
list_del_rcu(&entry->list);
} else {
if (watch) {
list_add(&nentry->rule.rlist,
&watch->rules);
list_del(&entry->rule.rlist);
} else if (tree)
list_replace_init(&entry->rule.rlist,
&nentry->rule.rlist);
list_replace_rcu(&entry->list, &nentry->list);
}
call_rcu(&entry->rcu, audit_free_rule_rcu);
list_for_each_entry_safe(e, n, &audit_filter_list[i], list) {
int res = update_lsm_rule(e);
if (!err)
err = res;
}
}
for (i=0; i< AUDIT_INODE_BUCKETS; i++) {
list_for_each_entry_safe(e, n, &audit_inode_hash[i], list) {
int res = update_lsm_rule(e);
if (!err)
err = res;
}
}

Expand Down

0 comments on commit 15b2a0a

Please sign in to comment.