xref: /freebsd/share/man/man4/dtrace_audit.4 (revision 03eb6e580f3c3c7144b3f66f42666de871375183)
1*03eb6e58SRobert Watson.\"-
2*03eb6e58SRobert Watson.\" SPDX-License-Identifier: BSD-2-Clause
3*03eb6e58SRobert Watson.\"
4*03eb6e58SRobert Watson.\" Copyright (c) 2019 Robert N. M. Watson
5*03eb6e58SRobert Watson.\"
6*03eb6e58SRobert Watson.\" This software was developed by BAE Systems, the University of Cambridge
7*03eb6e58SRobert Watson.\" Computer Laboratory, and Memorial University under DARPA/AFRL contract
8*03eb6e58SRobert Watson.\" FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent Computing
9*03eb6e58SRobert Watson.\" (TC) research program.
10*03eb6e58SRobert Watson.\"
11*03eb6e58SRobert Watson.\" Redistribution and use in source and binary forms, with or without
12*03eb6e58SRobert Watson.\" modification, are permitted provided that the following conditions
13*03eb6e58SRobert Watson.\" are met:
14*03eb6e58SRobert Watson.\" 1. Redistributions of source code must retain the above copyright
15*03eb6e58SRobert Watson.\"    notice, this list of conditions and the following disclaimer.
16*03eb6e58SRobert Watson.\" 2. Redistributions in binary form must reproduce the above copyright
17*03eb6e58SRobert Watson.\"    notice, this list of conditions and the following disclaimer in the
18*03eb6e58SRobert Watson.\"    documentation and/or other materials provided with the distribution.
19*03eb6e58SRobert Watson.\"
20*03eb6e58SRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21*03eb6e58SRobert Watson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*03eb6e58SRobert Watson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*03eb6e58SRobert Watson.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24*03eb6e58SRobert Watson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*03eb6e58SRobert Watson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*03eb6e58SRobert Watson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*03eb6e58SRobert Watson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*03eb6e58SRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*03eb6e58SRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*03eb6e58SRobert Watson.\" SUCH DAMAGE.
31*03eb6e58SRobert Watson.\"
32*03eb6e58SRobert Watson.\" $FreeBSD$
33*03eb6e58SRobert Watson.\"
34*03eb6e58SRobert Watson.Dd April 28, 2019
35*03eb6e58SRobert Watson.Dt DTRACE_AUDIT 4
36*03eb6e58SRobert Watson.Os
37*03eb6e58SRobert Watson.Sh NAME
38*03eb6e58SRobert Watson.Nm dtrace_audit
39*03eb6e58SRobert Watson.Nd A DTrace provider for tracing
40*03eb6e58SRobert Watson.Xr audit 4
41*03eb6e58SRobert Watsonevents
42*03eb6e58SRobert Watson.Sh SYNOPSIS
43*03eb6e58SRobert Watson.Pp
44*03eb6e58SRobert Watson.Fn audit:event:aue_*:commit "char *eventname" "struct audit_record *ar"
45*03eb6e58SRobert Watson.Fn audit:event:aue_*:bsm "char *eventname" "struct audit_record *ar" "const void *" "size_t"
46*03eb6e58SRobert Watson.Pp
47*03eb6e58SRobert WatsonTo compile this module into the kernel, place the following in your kernel
48*03eb6e58SRobert Watsonconfiguration file:
49*03eb6e58SRobert Watson.Pp
50*03eb6e58SRobert Watson.Bd -literal -offset indent
51*03eb6e58SRobert Watson.Cd "options DTAUDIT"
52*03eb6e58SRobert Watson.Ed
53*03eb6e58SRobert Watson.Pp
54*03eb6e58SRobert WatsonAlternatively, to load the module at boot time, place the following line in
55*03eb6e58SRobert Watson.Xr loader.conf 5 :
56*03eb6e58SRobert Watson.Bd -literal -offset indent
57*03eb6e58SRobert Watsondtaudit_load="YES"
58*03eb6e58SRobert Watson.Ed
59*03eb6e58SRobert Watson.Sh DESCRIPTION
60*03eb6e58SRobert WatsonThe DTrace
61*03eb6e58SRobert Watson.Nm dtaudit
62*03eb6e58SRobert Watsonprovider allows users to trace events in the kernel security auditing
63*03eb6e58SRobert Watsonsubsystem,
64*03eb6e58SRobert Watson.Xr audit 4 .
65*03eb6e58SRobert Watson.Xr audit 4
66*03eb6e58SRobert Watsonprovides detailed logging of a configurable set of security-relevant system
67*03eb6e58SRobert Watsoncalls, including key arguments (such as file paths) and return values that are
68*03eb6e58SRobert Watsoncopied race-free as the system call proceeds.
69*03eb6e58SRobert WatsonThe
70*03eb6e58SRobert Watson.Nm dtaudit
71*03eb6e58SRobert Watsonprovider allows DTrace scripts to selectively enable in-kernel audit-record
72*03eb6e58SRobert Watsoncapture for system calls, and then access those records in either the
73*03eb6e58SRobert Watsonin-kernel format or BSM format (\c
74*03eb6e58SRobert Watson.Xr audit.log 5 )
75*03eb6e58SRobert Watsonwhen the system call completes.
76*03eb6e58SRobert WatsonWhile the in-kernel audit record data structure is subject to change as the
77*03eb6e58SRobert Watsonkernel changes over time, it is a much more friendly interface for use in D
78*03eb6e58SRobert Watsonscripts than either those available via the DTrace system-call provider or the
79*03eb6e58SRobert WatsonBSM trail itself.
80*03eb6e58SRobert Watson.Ss Configuration
81*03eb6e58SRobert WatsonThe
82*03eb6e58SRobert Watson.Nm dtaudit
83*03eb6e58SRobert Watsonprovider relies on
84*03eb6e58SRobert Watson.Xr audit 4
85*03eb6e58SRobert Watsonbeing compiled into the kernel.
86*03eb6e58SRobert Watson.Nm dtaudit
87*03eb6e58SRobert Watsonprobes become available only once there is an event-to-name mapping installed
88*03eb6e58SRobert Watsonin the kernel, normally done by
89*03eb6e58SRobert Watson.Xr auditd 8
90*03eb6e58SRobert Watsonduring the boot process, if audit is enabled in
91*03eb6e58SRobert Watson.Xr rc.conf 5 :
92*03eb6e58SRobert Watson.Bd -literal -offset indent
93*03eb6e58SRobert Watsonauditd_enable="YES"
94*03eb6e58SRobert Watson.Ed
95*03eb6e58SRobert Watson.Pp
96*03eb6e58SRobert WatsonIf
97*03eb6e58SRobert Watson.Nm dtaudit
98*03eb6e58SRobert Watsonprobes are required earlier in boot -- for example, in single-user mode -- or
99*03eb6e58SRobert Watsonwithout enabling
100*03eb6e58SRobert Watson.Xr audit 4 ,
101*03eb6e58SRobert Watsonthey can be preloaded in the boot loader by adding this line to
102*03eb6e58SRobert Watson.Xr loader.conf 5 .
103*03eb6e58SRobert Watson.Bd -literal -offset indent
104*03eb6e58SRobert Watsonaudit_event_load="YES"
105*03eb6e58SRobert Watson.Ed
106*03eb6e58SRobert Watson.Ss Probes
107*03eb6e58SRobert WatsonThe
108*03eb6e58SRobert Watson.Fn audit:event:aue_*:commit
109*03eb6e58SRobert Watsonprobes fire synchronously during system-call return, giving access to two
110*03eb6e58SRobert Watsonarguments: a
111*03eb6e58SRobert Watson.Vt char *
112*03eb6e58SRobert Watsonaudit event name, and
113*03eb6e58SRobert Watsonthe
114*03eb6e58SRobert Watson.Vt struct audit_record *
115*03eb6e58SRobert Watsonin-kernel audit record.
116*03eb6e58SRobert WatsonBecause the probe fires in system-call return, the user thread has not yet
117*03eb6e58SRobert Watsonregained control, and additional information from the thread and process
118*03eb6e58SRobert Watsonremains available for capture by the script.
119*03eb6e58SRobert Watson.Pp
120*03eb6e58SRobert WatsonThe
121*03eb6e58SRobert Watson.Fn audit:event:aue_*:bsm
122*03eb6e58SRobert Watsonprobes fire asynchonously from system-call return, following BSM conversion
123*03eb6e58SRobert Watsonand just prior to being written to disk, giving access to four arguments: a
124*03eb6e58SRobert Watson.Vt char *
125*03eb6e58SRobert Watsonaudit event name, the
126*03eb6e58SRobert Watson.Vt struct audit_record *
127*03eb6e58SRobert Watsonin-kernel audit record, a
128*03eb6e58SRobert Watson.Vt const void *
129*03eb6e58SRobert Watsonpointer to the converted BSM record, and a
130*03eb6e58SRobert Watson.Vt size_t
131*03eb6e58SRobert Watsonfor the length of the BSM record.
132*03eb6e58SRobert Watson.Sh IMPLEMENTATION NOTES
133*03eb6e58SRobert WatsonWhen a set of
134*03eb6e58SRobert Watson.Nm dtaudit
135*03eb6e58SRobert Watsonprobes are registered, corresponding in-kernel audit records will be captured
136*03eb6e58SRobert Watsonand their probes will fire regardless of whether the
137*03eb6e58SRobert Watson.Xr audit 4
138*03eb6e58SRobert Watsonsubsystem itself would have captured the record for the purposes of writing it
139*03eb6e58SRobert Watsonto the audit trail, or for delivery to a
140*03eb6e58SRobert Watson.Xr auditpipe 4 .
141*03eb6e58SRobert WatsonIn-kernel audit records allocated only because of enabled
142*03eb6e58SRobert Watson.Xr dtaudit 4
143*03eb6e58SRobert Watsonprobes will not be unnecessarily written to the audit trail or enabled pipes.
144*03eb6e58SRobert Watson.Sh SEE ALSO
145*03eb6e58SRobert Watson.Xr dtrace 1 ,
146*03eb6e58SRobert Watson.Xr audit 4 ,
147*03eb6e58SRobert Watson.Xr audit.log 5 ,
148*03eb6e58SRobert Watson.Xr loader.conf 5 ,
149*03eb6e58SRobert Watson.Xr rc.conf 5 ,
150*03eb6e58SRobert Watson.Xr auditd 8
151*03eb6e58SRobert Watson.Sh HISTORY
152*03eb6e58SRobert WatsonThe
153*03eb6e58SRobert Watson.Nm dtaudit
154*03eb6e58SRobert Watsonprovider first appeared in
155*03eb6e58SRobert Watson.Fx 12.0 .
156*03eb6e58SRobert Watson.Sh AUTHORS
157*03eb6e58SRobert WatsonThis software and this manual page were developed by BAE Systems, the
158*03eb6e58SRobert WatsonUniversity of Cambridge Computer Laboratory, and Memorial University under
159*03eb6e58SRobert WatsonDARPA/AFRL contract
160*03eb6e58SRobert Watson.Pq FA8650-15-C-7558
161*03eb6e58SRobert Watson.Pq Do CADETS Dc ,
162*03eb6e58SRobert Watsonas part of the DARPA Transparent Computing (TC) research program.
163*03eb6e58SRobert WatsonThe
164*03eb6e58SRobert Watson.Nm dtaudit
165*03eb6e58SRobert Watsonprovider and this manual page were written by
166*03eb6e58SRobert Watson.An Robert Watson Aq Mt rwatson@FreeBSD.org .
167*03eb6e58SRobert Watson.Sh BUGS
168*03eb6e58SRobert WatsonBecause
169*03eb6e58SRobert Watson.Xr audit 4
170*03eb6e58SRobert Watsonmaintains its primary event-to-name mapping database in userspace, that
171*03eb6e58SRobert Watsondatabase must be loaded into the kernel before
172*03eb6e58SRobert Watson.Nm dtaudit
173*03eb6e58SRobert Watsonprobes become available.
174*03eb6e58SRobert Watson.Pp
175*03eb6e58SRobert Watson.Nm dtaudit
176*03eb6e58SRobert Watsonis only able to provide access to system-call audit events, not the full
177*03eb6e58SRobert Watsonscope of userspace events, such as those relating to login, password change,
178*03eb6e58SRobert Watsonand so on.
179