From: Anton Blanchard <anton@samba.org>
To: Eric Paris <eparis@redhat.com>
Cc: Michael Neuling <mikey@neuling.org>,
linux-audit@redhat.com, linux-kernel@vger.kernel.org,
Al Viro <viro@zeniv.linux.org.uk>,
sgrubb@redhat.com
Subject: Re: [PATCH] audit: speedup for syscalls when auditing is disabled
Date: Thu, 26 Aug 2010 13:34:56 +1000 [thread overview]
Message-ID: <20100826033456.GB17882@kryten> (raw)
In-Reply-To: <1282737584.13142.153.camel@localhost.localdomain>
Hi Eric,
Here's another approach Mikey and I were discussing. We allocate the
tsk->audit_context as before, but we avoid setting the TIF_SYSCALL_AUDIT until
the first rule gets added.
We could look at clearing the flag when the rules go back to zero, but this
simple patch covers the most common case I think.
Anton
---
Index: powerpc.git/kernel/auditfilter.c
===================================================================
--- powerpc.git.orig/kernel/auditfilter.c 2010-08-26 08:04:19.998892577 +1000
+++ powerpc.git/kernel/auditfilter.c 2010-08-26 08:04:30.290374256 +1000
@@ -859,6 +859,21 @@ out:
static u64 prio_low = ~0ULL/2;
static u64 prio_high = ~0ULL/2 - 1;
+#ifdef CONFIG_AUDITSYSCALL
+static void enable_syscall_auditing(void)
+{
+ unsigned long flags;
+ struct task_struct *g, *t;
+
+ read_lock_irqsave(&tasklist_lock, flags);
+ do_each_thread(g, t) {
+ if (t->audit_context)
+ set_tsk_thread_flag(t, TIF_SYSCALL_AUDIT);
+ } while_each_thread(g, t);
+ read_unlock_irqrestore(&tasklist_lock, flags);
+}
+#endif
+
/* Add rule to given filterlist if not a duplicate. */
static inline int audit_add_rule(struct audit_entry *entry)
{
@@ -922,9 +937,14 @@ static inline int audit_add_rule(struct
list_add_tail_rcu(&entry->list, list);
}
#ifdef CONFIG_AUDITSYSCALL
- if (!dont_count)
+ if (!dont_count) {
audit_n_rules++;
+ /* Did we add our first rule? */
+ if (audit_n_rules == 1)
+ enable_syscall_auditing();
+ }
+
if (!audit_match_signal(entry))
audit_signals++;
#endif
Index: powerpc.git/kernel/auditsc.c
===================================================================
--- powerpc.git.orig/kernel/auditsc.c 2010-08-26 08:04:19.998892577 +1000
+++ powerpc.git/kernel/auditsc.c 2010-08-26 08:04:30.390388654 +1000
@@ -886,7 +886,10 @@ int audit_alloc(struct task_struct *tsk)
context->filterkey = key;
tsk->audit_context = context;
- set_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT);
+
+ /* We postpone setting the thread flag until we add the first rule */
+ if (audit_n_rules != 0)
+ set_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT);
return 0;
}
next prev parent reply other threads:[~2010-08-26 3:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-20 2:13 [PATCH] audit: speedup for syscalls when auditing is disabled Michael Neuling
2010-08-23 17:56 ` 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 [this message]
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=20100826033456.GB17882@kryten \
--to=anton@samba.org \
--cc=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mikey@neuling.org \
--cc=sgrubb@redhat.com \
--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