From: Michael Neuling <mikey@neuling.org>
To: linux-audit@redhat.com, linux-kernel@vger.kernel.org,
Eric Paris <eparis@redhat.com>, Al Viro <viro@zeniv.linux.org.uk>
Cc: anton@samba.org
Subject: [PATCH] audit: speedup for syscalls when auditing is disabled
Date: Fri, 20 Aug 2010 12:13:13 +1000 [thread overview]
Message-ID: <29151.1282270393@neuling.org> (raw)
We found that when auditing is disabled using "auditctl -D", that
there's still a significant overhead when doing syscalls. This overhead
is not present when a single never rule is inserted using "auditctl -a
task,never".
Using Anton's null syscall microbenchmark from
http://ozlabs.org/~anton/junkcode/null_syscall.c we currently have on a
powerpc machine:
# auditctl -D
No rules
# ./null_syscall
null_syscall: 739.03 cycles 100.00%
# auditctl -a task,never
# ./null_syscall
null_syscall: 204.63 cycles 100.00%
This doesn't seem right, as we'd hope that auditing would have the same
minimal impact when disabled via -D as when we have a single never rule.
The patch below creates a fast path when initialising a task. If the
rules list for tasks is empty (the disabled -D option), we mark auditing
as disabled for this task.
When this is applied, our null syscall benchmark improves in the
disabled case to match the single never rule case.
# auditctl -D
No rules
# ./null_syscall
null_syscall: 204.62 cycles 100.00%
# auditctl -a task,never
# ./null_syscall
null_syscall: 204.63 cycles 100.00%
Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
I'm not familiar with the auditing code/infrastructure so I may have
misunderstood something here
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 1b31c13..1cd6ec7 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -666,6 +666,11 @@ static enum audit_state audit_filter_task(struct task_struct *tsk, char **key)
enum audit_state state;
rcu_read_lock();
+ /* Fast path. If the list is empty, disable auditing */
+ if (list_empty(&audit_filter_list[AUDIT_FILTER_TASK])) {
+ rcu_read_unlock();
+ return AUDIT_DISABLED;
+ }
list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TASK], list) {
if (audit_filter_rules(tsk, &e->rule, NULL, NULL, &state)) {
if (state == AUDIT_RECORD_CONTEXT)
next reply other threads:[~2010-08-20 2:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-20 2:13 Michael Neuling [this message]
2010-08-23 17:56 ` [PATCH] audit: speedup for syscalls when auditing is disabled Eric Paris
2010-08-24 2:11 ` Michael Neuling
2010-08-24 3:43 ` Eric Paris
2010-08-24 5:56 ` Michael Neuling
2010-08-24 5:56 ` Michael Neuling
2010-08-24 20:06 ` Eric Paris
2010-08-24 15:14 ` Miloslav Trmac
2010-08-24 15:17 ` Eric Paris
2010-08-25 3:11 ` Michael Neuling
2010-08-25 11:59 ` Eric Paris
2010-08-26 3:34 ` Anton Blanchard
2010-08-27 17:49 ` Eric Paris
2010-08-24 2:16 ` Anton Blanchard
2010-08-24 3:51 ` Eric Paris
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=29151.1282270393@neuling.org \
--to=mikey@neuling.org \
--cc=anton@samba.org \
--cc=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).