103eb6e58SRobert Watson.\"- 203eb6e58SRobert Watson.\" SPDX-License-Identifier: BSD-2-Clause 303eb6e58SRobert Watson.\" 403eb6e58SRobert Watson.\" Copyright (c) 2019 Robert N. M. Watson 503eb6e58SRobert Watson.\" 603eb6e58SRobert Watson.\" This software was developed by BAE Systems, the University of Cambridge 703eb6e58SRobert Watson.\" Computer Laboratory, and Memorial University under DARPA/AFRL contract 803eb6e58SRobert Watson.\" FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing 903eb6e58SRobert Watson.\" (TC) research program. 1003eb6e58SRobert Watson.\" 1103eb6e58SRobert Watson.\" Redistribution and use in source and binary forms, with or without 1203eb6e58SRobert Watson.\" modification, are permitted provided that the following conditions 1303eb6e58SRobert Watson.\" are met: 1403eb6e58SRobert Watson.\" 1. Redistributions of source code must retain the above copyright 1503eb6e58SRobert Watson.\" notice, this list of conditions and the following disclaimer. 1603eb6e58SRobert Watson.\" 2. Redistributions in binary form must reproduce the above copyright 1703eb6e58SRobert Watson.\" notice, this list of conditions and the following disclaimer in the 1803eb6e58SRobert Watson.\" documentation and/or other materials provided with the distribution. 1903eb6e58SRobert Watson.\" 2003eb6e58SRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2103eb6e58SRobert Watson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2203eb6e58SRobert Watson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2303eb6e58SRobert Watson.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2403eb6e58SRobert Watson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2503eb6e58SRobert Watson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2603eb6e58SRobert Watson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2703eb6e58SRobert Watson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2803eb6e58SRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2903eb6e58SRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3003eb6e58SRobert Watson.\" SUCH DAMAGE. 3103eb6e58SRobert Watson.\" 3203eb6e58SRobert Watson.Dd April 28, 2019 3303eb6e58SRobert Watson.Dt DTRACE_AUDIT 4 3403eb6e58SRobert Watson.Os 3503eb6e58SRobert Watson.Sh NAME 3603eb6e58SRobert Watson.Nm dtrace_audit 3703eb6e58SRobert Watson.Nd A DTrace provider for tracing 3803eb6e58SRobert Watson.Xr audit 4 3903eb6e58SRobert Watsonevents 4003eb6e58SRobert Watson.Sh SYNOPSIS 4103eb6e58SRobert Watson.Fn audit:event:aue_*:commit "char *eventname" "struct audit_record *ar" 4203eb6e58SRobert Watson.Fn audit:event:aue_*:bsm "char *eventname" "struct audit_record *ar" "const void *" "size_t" 4303eb6e58SRobert Watson.Pp 4403eb6e58SRobert WatsonTo compile this module into the kernel, place the following in your kernel 4503eb6e58SRobert Watsonconfiguration file: 4603eb6e58SRobert Watson.Bd -literal -offset indent 4703eb6e58SRobert Watson.Cd "options DTAUDIT" 4803eb6e58SRobert Watson.Ed 4903eb6e58SRobert Watson.Pp 5003eb6e58SRobert WatsonAlternatively, to load the module at boot time, place the following line in 5103eb6e58SRobert Watson.Xr loader.conf 5 : 5203eb6e58SRobert Watson.Bd -literal -offset indent 5303eb6e58SRobert Watsondtaudit_load="YES" 5403eb6e58SRobert Watson.Ed 5503eb6e58SRobert Watson.Sh DESCRIPTION 5603eb6e58SRobert WatsonThe DTrace 5703eb6e58SRobert Watson.Nm dtaudit 5803eb6e58SRobert Watsonprovider allows users to trace events in the kernel security auditing 5903eb6e58SRobert Watsonsubsystem, 6003eb6e58SRobert Watson.Xr audit 4 . 6103eb6e58SRobert Watson.Xr audit 4 6203eb6e58SRobert Watsonprovides detailed logging of a configurable set of security-relevant system 6303eb6e58SRobert Watsoncalls, including key arguments (such as file paths) and return values that are 6403eb6e58SRobert Watsoncopied race-free as the system call proceeds. 6503eb6e58SRobert WatsonThe 6603eb6e58SRobert Watson.Nm dtaudit 6703eb6e58SRobert Watsonprovider allows DTrace scripts to selectively enable in-kernel audit-record 6803eb6e58SRobert Watsoncapture for system calls, and then access those records in either the 6903eb6e58SRobert Watsonin-kernel format or BSM format (\c 7003eb6e58SRobert Watson.Xr audit.log 5 ) 7103eb6e58SRobert Watsonwhen the system call completes. 7203eb6e58SRobert WatsonWhile the in-kernel audit record data structure is subject to change as the 7303eb6e58SRobert Watsonkernel changes over time, it is a much more friendly interface for use in D 7403eb6e58SRobert Watsonscripts than either those available via the DTrace system-call provider or the 7503eb6e58SRobert WatsonBSM trail itself. 7603eb6e58SRobert Watson.Ss Configuration 7703eb6e58SRobert WatsonThe 7803eb6e58SRobert Watson.Nm dtaudit 7903eb6e58SRobert Watsonprovider relies on 8003eb6e58SRobert Watson.Xr audit 4 8103eb6e58SRobert Watsonbeing compiled into the kernel. 8203eb6e58SRobert Watson.Nm dtaudit 8303eb6e58SRobert Watsonprobes become available only once there is an event-to-name mapping installed 8403eb6e58SRobert Watsonin the kernel, normally done by 8503eb6e58SRobert Watson.Xr auditd 8 8603eb6e58SRobert Watsonduring the boot process, if audit is enabled in 8703eb6e58SRobert Watson.Xr rc.conf 5 : 8803eb6e58SRobert Watson.Bd -literal -offset indent 8903eb6e58SRobert Watsonauditd_enable="YES" 9003eb6e58SRobert Watson.Ed 9103eb6e58SRobert Watson.Pp 9203eb6e58SRobert WatsonIf 9303eb6e58SRobert Watson.Nm dtaudit 9403eb6e58SRobert Watsonprobes are required earlier in boot -- for example, in single-user mode -- or 9503eb6e58SRobert Watsonwithout enabling 9603eb6e58SRobert Watson.Xr audit 4 , 9703eb6e58SRobert Watsonthey can be preloaded in the boot loader by adding this line to 9803eb6e58SRobert Watson.Xr loader.conf 5 . 9903eb6e58SRobert Watson.Bd -literal -offset indent 10003eb6e58SRobert Watsonaudit_event_load="YES" 10103eb6e58SRobert Watson.Ed 10203eb6e58SRobert Watson.Ss Probes 10303eb6e58SRobert WatsonThe 10403eb6e58SRobert Watson.Fn audit:event:aue_*:commit 10503eb6e58SRobert Watsonprobes fire synchronously during system-call return, giving access to two 10603eb6e58SRobert Watsonarguments: a 10703eb6e58SRobert Watson.Vt char * 10803eb6e58SRobert Watsonaudit event name, and 10903eb6e58SRobert Watsonthe 11003eb6e58SRobert Watson.Vt struct audit_record * 11103eb6e58SRobert Watsonin-kernel audit record. 11203eb6e58SRobert WatsonBecause the probe fires in system-call return, the user thread has not yet 11303eb6e58SRobert Watsonregained control, and additional information from the thread and process 11403eb6e58SRobert Watsonremains available for capture by the script. 11503eb6e58SRobert Watson.Pp 11603eb6e58SRobert WatsonThe 11703eb6e58SRobert Watson.Fn audit:event:aue_*:bsm 118*15a478b3SGordon Berglingprobes fire asynchronously from system-call return, following BSM conversion 11903eb6e58SRobert Watsonand just prior to being written to disk, giving access to four arguments: a 12003eb6e58SRobert Watson.Vt char * 12103eb6e58SRobert Watsonaudit event name, the 12203eb6e58SRobert Watson.Vt struct audit_record * 12303eb6e58SRobert Watsonin-kernel audit record, a 12403eb6e58SRobert Watson.Vt const void * 12503eb6e58SRobert Watsonpointer to the converted BSM record, and a 12603eb6e58SRobert Watson.Vt size_t 12703eb6e58SRobert Watsonfor the length of the BSM record. 12803eb6e58SRobert Watson.Sh IMPLEMENTATION NOTES 12903eb6e58SRobert WatsonWhen a set of 13003eb6e58SRobert Watson.Nm dtaudit 13103eb6e58SRobert Watsonprobes are registered, corresponding in-kernel audit records will be captured 13203eb6e58SRobert Watsonand their probes will fire regardless of whether the 13303eb6e58SRobert Watson.Xr audit 4 13403eb6e58SRobert Watsonsubsystem itself would have captured the record for the purposes of writing it 13503eb6e58SRobert Watsonto the audit trail, or for delivery to a 13603eb6e58SRobert Watson.Xr auditpipe 4 . 13703eb6e58SRobert WatsonIn-kernel audit records allocated only because of enabled 13803eb6e58SRobert Watson.Xr dtaudit 4 13903eb6e58SRobert Watsonprobes will not be unnecessarily written to the audit trail or enabled pipes. 14003eb6e58SRobert Watson.Sh SEE ALSO 14103eb6e58SRobert Watson.Xr dtrace 1 , 14203eb6e58SRobert Watson.Xr audit 4 , 14303eb6e58SRobert Watson.Xr audit.log 5 , 14403eb6e58SRobert Watson.Xr loader.conf 5 , 14503eb6e58SRobert Watson.Xr rc.conf 5 , 14603eb6e58SRobert Watson.Xr auditd 8 14703eb6e58SRobert Watson.Sh HISTORY 14803eb6e58SRobert WatsonThe 14903eb6e58SRobert Watson.Nm dtaudit 15003eb6e58SRobert Watsonprovider first appeared in 15103eb6e58SRobert Watson.Fx 12.0 . 15203eb6e58SRobert Watson.Sh AUTHORS 15303eb6e58SRobert WatsonThis software and this manual page were developed by BAE Systems, the 15403eb6e58SRobert WatsonUniversity of Cambridge Computer Laboratory, and Memorial University under 15503eb6e58SRobert WatsonDARPA/AFRL contract 15603eb6e58SRobert Watson.Pq FA8650-15-C-7558 15703eb6e58SRobert Watson.Pq Do CADETS Dc , 15803eb6e58SRobert Watsonas part of the DARPA Transparent Computing (TC) research program. 15903eb6e58SRobert WatsonThe 16003eb6e58SRobert Watson.Nm dtaudit 16103eb6e58SRobert Watsonprovider and this manual page were written by 16203eb6e58SRobert Watson.An Robert Watson Aq Mt rwatson@FreeBSD.org . 16303eb6e58SRobert Watson.Sh BUGS 16403eb6e58SRobert WatsonBecause 16503eb6e58SRobert Watson.Xr audit 4 16603eb6e58SRobert Watsonmaintains its primary event-to-name mapping database in userspace, that 16703eb6e58SRobert Watsondatabase must be loaded into the kernel before 16803eb6e58SRobert Watson.Nm dtaudit 16903eb6e58SRobert Watsonprobes become available. 17003eb6e58SRobert Watson.Pp 17103eb6e58SRobert Watson.Nm dtaudit 17203eb6e58SRobert Watsonis only able to provide access to system-call audit events, not the full 17303eb6e58SRobert Watsonscope of userspace events, such as those relating to login, password change, 17403eb6e58SRobert Watsonand so on. 175