From: Richard Guy Briggs <rgb@redhat.com>
To: linux-audit@redhat.com, linux-kernel@vger.kernel.org
Cc: Richard Guy Briggs <rgb@redhat.com>,
sgrubb@redhat.com, pmoore@redhat.com, eparis@redhat.com
Subject: [PATCH] audit: add fields to exclude filter by reusing user filter
Date: Wed, 1 Jun 2016 18:50:26 -0400 [thread overview]
Message-ID: <3ff3a1c2837c8045bb54058effd11edd897b6412.1464810610.git.rgb@redhat.com> (raw)
RFE: add additional fields for use in audit filter exclude rules
https://github.com/linux-audit/audit-kernel/issues/5
Re-factor audit_filter_type() to use audit_filter_user_rules() to enable
exclude filter to additionally filter on PID, UID, GID, AUID,
LOGINUID_SET, SUBJ_*.
Add check in audit_filter_user() to quit early if list is empty.
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
---
kernel/auditfilter.c | 22 +++++++++-------------
1 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 96c9a1b..515c752 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1358,6 +1358,9 @@ int audit_filter_user(int type)
ret = 1; /* Audit by default */
rcu_read_lock();
+ if (list_empty(&audit_filter_list[AUDIT_FILTER_USER]))
+ goto unlock_and_return;
+
list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_USER], list) {
rc = audit_filter_user_rules(&e->rule, type, &state);
if (rc) {
@@ -1366,13 +1369,14 @@ int audit_filter_user(int type)
break;
}
}
+unlock_and_return:
rcu_read_unlock();
-
return ret;
}
int audit_filter_type(int type)
{
+ enum audit_state state = AUDIT_DISABLED;
struct audit_entry *e;
int result = 0;
@@ -1380,19 +1384,11 @@ int audit_filter_type(int type)
if (list_empty(&audit_filter_list[AUDIT_FILTER_TYPE]))
goto unlock_and_return;
- list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TYPE],
- list) {
- int i;
- for (i = 0; i < e->rule.field_count; i++) {
- struct audit_field *f = &e->rule.fields[i];
- if (f->type == AUDIT_MSGTYPE) {
- result = audit_comparator(type, f->op, f->val);
- if (!result)
- break;
- }
+ list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TYPE], list) {
+ if (audit_filter_user_rules(&e->rule, type, &state) == 1) {
+ result = 1;
+ break;
}
- if (result)
- goto unlock_and_return;
}
unlock_and_return:
rcu_read_unlock();
--
1.7.1
next reply other threads:[~2016-06-01 22:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 22:50 Richard Guy Briggs [this message]
2016-06-03 19:32 ` Paul Moore
2016-06-03 20:24 ` Richard Guy Briggs
2016-06-03 20:31 ` Paul Moore
2016-06-15 2:09 ` Richard Guy Briggs
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=3ff3a1c2837c8045bb54058effd11edd897b6412.1464810610.git.rgb@redhat.com \
--to=rgb@redhat.com \
--cc=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmoore@redhat.com \
--cc=sgrubb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®