summaryrefslogtreecommitdiffstats
path: root/sys/security/audit/audit.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-03-09 10:45:58 +0000
committerrwatson <rwatson@FreeBSD.org>2009-03-09 10:45:58 +0000
commite0bfbf5350d05c348bb549bbeb5082e7c6bf3f99 (patch)
tree160ca28e5f12868ee88d93869a6d7e17bc229456 /sys/security/audit/audit.c
parent4e908eaace9a5119393137b8b37a08bd44de36b4 (diff)
downloadFreeBSD-src-e0bfbf5350d05c348bb549bbeb5082e7c6bf3f99.zip
FreeBSD-src-e0bfbf5350d05c348bb549bbeb5082e7c6bf3f99.tar.gz
Add a new thread-private flag, TDP_AUDITREC, to indicate whether or
not there is an audit record hung off of td_ar on the current thread. Test this flag instead of td_ar when auditing syscall arguments or checking for an audit record to commit on syscall return. Under these circumstances, td_pflags is much more likely to be in the cache (especially if there is no auditing of the current system call), so this should help reduce cache misses in the system call return path. MFC after: 1 week Reported by: kris Obtained from: TrustedBSD Project
Diffstat (limited to 'sys/security/audit/audit.c')
-rw-r--r--sys/security/audit/audit.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/security/audit/audit.c b/sys/security/audit/audit.c
index 4ea76c6..b46c02c 100644
--- a/sys/security/audit/audit.c
+++ b/sys/security/audit/audit.c
@@ -492,6 +492,8 @@ audit_syscall_enter(unsigned short code, struct thread *td)
au_id_t auid;
KASSERT(td->td_ar == NULL, ("audit_syscall_enter: td->td_ar != NULL"));
+ KASSERT((td->td_pflags & TDP_AUDITREC) == 0,
+ ("audit_syscall_enter: TDP_AUDITREC set"));
/*
* In FreeBSD, each ABI has its own system call table, and hence
@@ -542,9 +544,13 @@ audit_syscall_enter(unsigned short code, struct thread *td)
panic("audit_failing_stop: thread continued");
}
td->td_ar = audit_new(event, td);
- } else if (audit_pipe_preselect(auid, event, class, AU_PRS_BOTH, 0))
+ if (td->td_ar != NULL)
+ td->td_pflags |= TDP_AUDITREC;
+ } else if (audit_pipe_preselect(auid, event, class, AU_PRS_BOTH, 0)) {
td->td_ar = audit_new(event, td);
- else
+ if (td->td_ar != NULL)
+ td->td_pflags |= TDP_AUDITREC;
+ } else
td->td_ar = NULL;
}
@@ -572,6 +578,7 @@ audit_syscall_exit(int error, struct thread *td)
audit_commit(td->td_ar, error, retval);
td->td_ar = NULL;
+ td->td_pflags &= ~TDP_AUDITREC;
}
void
@@ -626,6 +633,8 @@ audit_thread_free(struct thread *td)
{
KASSERT(td->td_ar == NULL, ("audit_thread_free: td_ar != NULL"));
+ KASSERT((td->td_pflags & TDP_AUDITREC) == 0,
+ ("audit_thread_free: TDP_AUDITREC set"));
}
void
OpenPOWER on IntegriCloud