summaryrefslogtreecommitdiffstats
path: root/sys/security/audit/audit_trigger.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-06-13 21:17:23 +0000
committerrwatson <rwatson@FreeBSD.org>2007-06-13 21:17:23 +0000
commitaa3031101074421132a23b647420723fcc15833f (patch)
tree02aa35acfdc038f55fee2070afa3b78cd4bb73b0 /sys/security/audit/audit_trigger.c
parentc111e1c379bf2f4692316a389f93104f785555ae (diff)
downloadFreeBSD-src-aa3031101074421132a23b647420723fcc15833f.zip
FreeBSD-src-aa3031101074421132a23b647420723fcc15833f.tar.gz
Close a very narrow race that might cause a trigger allocation to be
leaked if a trigger is delivered as the trigger device is closed. Obtained from: TrustedBSD Project
Diffstat (limited to 'sys/security/audit/audit_trigger.c')
-rw-r--r--sys/security/audit/audit_trigger.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/security/audit/audit_trigger.c b/sys/security/audit/audit_trigger.c
index c3f47b7..08cacb0 100644
--- a/sys/security/audit/audit_trigger.c
+++ b/sys/security/audit/audit_trigger.c
@@ -132,15 +132,14 @@ send_trigger(unsigned int trigger)
{
struct trigger_info *ti;
- /* If nobody's listening, we ain't talking. */
- if (!audit_isopen)
- return (ENODEV);
-
- /*
- * Note: Use a condition variable instead of msleep/wakeup?
- */
ti = malloc(sizeof *ti, M_AUDITTRIGGER, M_WAITOK);
mtx_lock(&audit_trigger_mtx);
+ if (!audit_isopen) {
+ /* If nobody's listening, we ain't talking. */
+ mtx_unlock(&audit_trigger_mtx);
+ free(ti, M_AUDITTRIGGER);
+ return (ENODEV);
+ }
ti->trigger = trigger;
TAILQ_INSERT_TAIL(&trigger_list, ti, list);
wakeup(&trigger_list);
OpenPOWER on IntegriCloud