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.\" $FreeBSD$ 3303eb6e58SRobert Watson.\" 3403eb6e58SRobert Watson.Dd April 28, 2019 3503eb6e58SRobert Watson.Dt DTRACE_AUDIT 4 3603eb6e58SRobert Watson.Os 3703eb6e58SRobert Watson.Sh NAME 3803eb6e58SRobert Watson.Nm dtrace_audit 3903eb6e58SRobert Watson.Nd A DTrace provider for tracing 4003eb6e58SRobert Watson.Xr audit 4 4103eb6e58SRobert Watsonevents 4203eb6e58SRobert Watson.Sh SYNOPSIS 4303eb6e58SRobert Watson.Pp 4403eb6e58SRobert Watson.Fn audit:event:aue_*:commit "char *eventname" "struct audit_record *ar" 4503eb6e58SRobert Watson.Fn audit:event:aue_*:bsm "char *eventname" "struct audit_record *ar" "const void *" "size_t" 4603eb6e58SRobert Watson.Pp 4703eb6e58SRobert WatsonTo compile this module into the kernel, place the following in your kernel 4803eb6e58SRobert Watsonconfiguration file: 4903eb6e58SRobert Watson.Pp 5003eb6e58SRobert Watson.Bd -literal -offset indent 5103eb6e58SRobert Watson.Cd "options DTAUDIT" 5203eb6e58SRobert Watson.Ed 5303eb6e58SRobert Watson.Pp 5403eb6e58SRobert WatsonAlternatively, to load the module at boot time, place the following line in 5503eb6e58SRobert Watson.Xr loader.conf 5 : 5603eb6e58SRobert Watson.Bd -literal -offset indent 5703eb6e58SRobert Watsondtaudit_load="YES" 5803eb6e58SRobert Watson.Ed 5903eb6e58SRobert Watson.Sh DESCRIPTION 6003eb6e58SRobert WatsonThe DTrace 6103eb6e58SRobert Watson.Nm dtaudit 6203eb6e58SRobert Watsonprovider allows users to trace events in the kernel security auditing 6303eb6e58SRobert Watsonsubsystem, 6403eb6e58SRobert Watson.Xr audit 4 . 6503eb6e58SRobert Watson.Xr audit 4 6603eb6e58SRobert Watsonprovides detailed logging of a configurable set of security-relevant system 6703eb6e58SRobert Watsoncalls, including key arguments (such as file paths) and return values that are 6803eb6e58SRobert Watsoncopied race-free as the system call proceeds. 6903eb6e58SRobert WatsonThe 7003eb6e58SRobert Watson.Nm dtaudit 7103eb6e58SRobert Watsonprovider allows DTrace scripts to selectively enable in-kernel audit-record 7203eb6e58SRobert Watsoncapture for system calls, and then access those records in either the 7303eb6e58SRobert Watsonin-kernel format or BSM format (\c 7403eb6e58SRobert Watson.Xr audit.log 5 ) 7503eb6e58SRobert Watsonwhen the system call completes. 7603eb6e58SRobert WatsonWhile the in-kernel audit record data structure is subject to change as the 7703eb6e58SRobert Watsonkernel changes over time, it is a much more friendly interface for use in D 7803eb6e58SRobert Watsonscripts than either those available via the DTrace system-call provider or the 7903eb6e58SRobert WatsonBSM trail itself. 8003eb6e58SRobert Watson.Ss Configuration 8103eb6e58SRobert WatsonThe 8203eb6e58SRobert Watson.Nm dtaudit 8303eb6e58SRobert Watsonprovider relies on 8403eb6e58SRobert Watson.Xr audit 4 8503eb6e58SRobert Watsonbeing compiled into the kernel. 8603eb6e58SRobert Watson.Nm dtaudit 8703eb6e58SRobert Watsonprobes become available only once there is an event-to-name mapping installed 8803eb6e58SRobert Watsonin the kernel, normally done by 8903eb6e58SRobert Watson.Xr auditd 8 9003eb6e58SRobert Watsonduring the boot process, if audit is enabled in 9103eb6e58SRobert Watson.Xr rc.conf 5 : 9203eb6e58SRobert Watson.Bd -literal -offset indent 9303eb6e58SRobert Watsonauditd_enable="YES" 9403eb6e58SRobert Watson.Ed 9503eb6e58SRobert Watson.Pp 9603eb6e58SRobert WatsonIf 9703eb6e58SRobert Watson.Nm dtaudit 9803eb6e58SRobert Watsonprobes are required earlier in boot -- for example, in single-user mode -- or 9903eb6e58SRobert Watsonwithout enabling 10003eb6e58SRobert Watson.Xr audit 4 , 10103eb6e58SRobert Watsonthey can be preloaded in the boot loader by adding this line to 10203eb6e58SRobert Watson.Xr loader.conf 5 . 10303eb6e58SRobert Watson.Bd -literal -offset indent 10403eb6e58SRobert Watsonaudit_event_load="YES" 10503eb6e58SRobert Watson.Ed 10603eb6e58SRobert Watson.Ss Probes 10703eb6e58SRobert WatsonThe 10803eb6e58SRobert Watson.Fn audit:event:aue_*:commit 10903eb6e58SRobert Watsonprobes fire synchronously during system-call return, giving access to two 11003eb6e58SRobert Watsonarguments: a 11103eb6e58SRobert Watson.Vt char * 11203eb6e58SRobert Watsonaudit event name, and 11303eb6e58SRobert Watsonthe 11403eb6e58SRobert Watson.Vt struct audit_record * 11503eb6e58SRobert Watsonin-kernel audit record. 11603eb6e58SRobert WatsonBecause the probe fires in system-call return, the user thread has not yet 11703eb6e58SRobert Watsonregained control, and additional information from the thread and process 11803eb6e58SRobert Watsonremains available for capture by the script. 11903eb6e58SRobert Watson.Pp 12003eb6e58SRobert WatsonThe 12103eb6e58SRobert Watson.Fn audit:event:aue_*:bsm 122*15a478b3SGordon Berglingprobes fire asynchronously from system-call return, following BSM conversion 12303eb6e58SRobert Watsonand just prior to being written to disk, giving access to four arguments: a 12403eb6e58SRobert Watson.Vt char * 12503eb6e58SRobert Watsonaudit event name, the 12603eb6e58SRobert Watson.Vt struct audit_record * 12703eb6e58SRobert Watsonin-kernel audit record, a 12803eb6e58SRobert Watson.Vt const void * 12903eb6e58SRobert Watsonpointer to the converted BSM record, and a 13003eb6e58SRobert Watson.Vt size_t 13103eb6e58SRobert Watsonfor the length of the BSM record. 13203eb6e58SRobert Watson.Sh IMPLEMENTATION NOTES 13303eb6e58SRobert WatsonWhen a set of 13403eb6e58SRobert Watson.Nm dtaudit 13503eb6e58SRobert Watsonprobes are registered, corresponding in-kernel audit records will be captured 13603eb6e58SRobert Watsonand their probes will fire regardless of whether the 13703eb6e58SRobert Watson.Xr audit 4 13803eb6e58SRobert Watsonsubsystem itself would have captured the record for the purposes of writing it 13903eb6e58SRobert Watsonto the audit trail, or for delivery to a 14003eb6e58SRobert Watson.Xr auditpipe 4 . 14103eb6e58SRobert WatsonIn-kernel audit records allocated only because of enabled 14203eb6e58SRobert Watson.Xr dtaudit 4 14303eb6e58SRobert Watsonprobes will not be unnecessarily written to the audit trail or enabled pipes. 14403eb6e58SRobert Watson.Sh SEE ALSO 14503eb6e58SRobert Watson.Xr dtrace 1 , 14603eb6e58SRobert Watson.Xr audit 4 , 14703eb6e58SRobert Watson.Xr audit.log 5 , 14803eb6e58SRobert Watson.Xr loader.conf 5 , 14903eb6e58SRobert Watson.Xr rc.conf 5 , 15003eb6e58SRobert Watson.Xr auditd 8 15103eb6e58SRobert Watson.Sh HISTORY 15203eb6e58SRobert WatsonThe 15303eb6e58SRobert Watson.Nm dtaudit 15403eb6e58SRobert Watsonprovider first appeared in 15503eb6e58SRobert Watson.Fx 12.0 . 15603eb6e58SRobert Watson.Sh AUTHORS 15703eb6e58SRobert WatsonThis software and this manual page were developed by BAE Systems, the 15803eb6e58SRobert WatsonUniversity of Cambridge Computer Laboratory, and Memorial University under 15903eb6e58SRobert WatsonDARPA/AFRL contract 16003eb6e58SRobert Watson.Pq FA8650-15-C-7558 16103eb6e58SRobert Watson.Pq Do CADETS Dc , 16203eb6e58SRobert Watsonas part of the DARPA Transparent Computing (TC) research program. 16303eb6e58SRobert WatsonThe 16403eb6e58SRobert Watson.Nm dtaudit 16503eb6e58SRobert Watsonprovider and this manual page were written by 16603eb6e58SRobert Watson.An Robert Watson Aq Mt rwatson@FreeBSD.org . 16703eb6e58SRobert Watson.Sh BUGS 16803eb6e58SRobert WatsonBecause 16903eb6e58SRobert Watson.Xr audit 4 17003eb6e58SRobert Watsonmaintains its primary event-to-name mapping database in userspace, that 17103eb6e58SRobert Watsondatabase must be loaded into the kernel before 17203eb6e58SRobert Watson.Nm dtaudit 17303eb6e58SRobert Watsonprobes become available. 17403eb6e58SRobert Watson.Pp 17503eb6e58SRobert Watson.Nm dtaudit 17603eb6e58SRobert Watsonis only able to provide access to system-call audit events, not the full 17703eb6e58SRobert Watsonscope of userspace events, such as those relating to login, password change, 17803eb6e58SRobert Watsonand so on. 179