All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Grubb <sgrubb@redhat.com>
To: Amy Griffis <amy.griffis@hp.com>
Cc: linux-audit@redhat.com
Subject: Re: {PATCH] Audit Filter Performance
Date: Tue, 11 Apr 2006 08:50:56 -0400	[thread overview]
Message-ID: <200604110850.56573.sgrubb@redhat.com> (raw)
In-Reply-To: <20060410234645.GA32612@sage.flatmonk>

On Monday 10 April 2006 19:46, Amy Griffis wrote:
> > While testing the watch performance, I noticed that selinux_task_ctxid()
> > was creeping into the results more than it should. Investigation showed
> > that the function call was being called whether it was needed or not. The
> > below patch fixes this.
>
> You've moved selinux_task_ctxid() inside a for loop.  Now it will be
> called for each selinux field in a rule.  I don't think that's what
> you want.  
>
> A better solution would be to set a rule flag in
> audit_data_to_entry(), then check that flag outside the for loop.

Yes, you are right - Thanks!  New patch below.

Signed-off-by: Steve Grubb <sgrubb@redhat.com>


diff -urp linux-2.6.16.x86_64.orig/kernel/auditsc.c linux-2.6.16.x86_64/kernel/auditsc.c
--- linux-2.6.16.x86_64.orig/kernel/auditsc.c	2006-04-11 08:44:02.000000000 -0400
+++ linux-2.6.16.x86_64/kernel/auditsc.c	2006-04-11 08:43:17.000000000 -0400
@@ -189,11 +189,9 @@ static int audit_filter_rules(struct tas
 			      struct audit_context *ctx,
 			      enum audit_state *state)
 {
-	int i, j;
+	int i, j, need_sid = 1;
 	u32 sid;
 
-	selinux_task_ctxid(tsk, &sid);
-
 	for (i = 0; i < rule->field_count; i++) {
 		struct audit_field *f = &rule->fields[i];
 		int result = 0;
@@ -295,11 +293,16 @@ static int audit_filter_rules(struct tas
 			   match for now to avoid losing information that
 			   may be wanted.   An error message will also be
 			   logged upon error */
-			if (f->se_rule)
+			if (f->se_rule) {
+				if (need_sid) {
+					selinux_task_ctxid(tsk, &sid);
+					need_sid = 0;
+				}
 				result = selinux_audit_rule_match(sid, f->type,
 				                                  f->op,
 				                                  f->se_rule,
 				                                  ctx);
+			}
 			break;
 		case AUDIT_ARG0:
 		case AUDIT_ARG1:

      reply	other threads:[~2006-04-11 12:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-08 20:46 {PATCH] Audit Filter Performance Steve Grubb
2006-04-10 23:46 ` Amy Griffis
2006-04-11 12:50   ` Steve Grubb [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=200604110850.56573.sgrubb@redhat.com \
    --to=sgrubb@redhat.com \
    --cc=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.