FreeBSD/sys/security/audit/audit.c
/*
 * XXXAUDIT: There are a number of races present in the code below due to
 * release and re-grab of the mutex.  The code should be revised to become
 * slightly less racy.
 *
 * XXXAUDIT: Shouldn't there be logic here to sleep waiting on available
 * pre_q space, suspending the system call until there is room?
 */
There are a number of races present in the code below due to
release and re-grab of the mutex.  The code should be revised to become
slightly less racy.


There are a number of races present in the code below due to release and re - grab of the mutex . The code should be revised to become slightly less racy .
struct kaudit_record *
audit_new(int event, struct thread *td)
{
	struct kaudit_record *ar;
	int no_record;
	mtx_lock(&audit_mtx);
	no_record = (audit_suspended || !audit_enabled);
	mtx_unlock(&audit_mtx);
	if (no_record)
		return (NULL);
	ar = uma_zalloc_arg(audit_record_zone, td, M_WAITOK);
	ar->k_ar.ar_event = event;
	mtx_lock(&audit_mtx);
	audit_pre_q_len++;
	mtx_unlock(&audit_mtx);
	return (ar);
}
struct kaudit_record * audit_new ( int event , struct thread * td ) { struct kaudit_record * ar ; int no_record ; mtx_lock ( & audit_mtx ) ; no_record = ( audit_suspended || ! audit_enabled ) ; mtx_unlock ( & audit_mtx ) ; if ( no_record ) return ( NULL ) ; ar = uma_zalloc_arg ( audit_record_zone , td , M_WAITOK ) ; ar -> k_ar . ar_event = event ; mtx_lock ( & audit_mtx ) ; audit_pre_q_len ++ ; mtx_unlock ( & audit_mtx ) ; return ( ar ) ; }
XXXAUDIT: There are a number of races present in the code below due to
 release and re-grab of the mutex.
XXXAUDIT : There are a number of races present in the code below due to release and re - grab of the mutex .
/*
	 * Note: the number of outstanding uncommitted audit records is
	 * limited to the number of concurrent threads servicing system calls
	 * in the kernel.
	 */