xref: /freebsd/share/man/man4/auditpipe.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1673937acSRobert Watson.\" Copyright (c) 2006 Robert N. M. Watson
2673937acSRobert Watson.\" All rights reserved.
3673937acSRobert Watson.\"
4673937acSRobert Watson.\" Redistribution and use in source and binary forms, with or without
5673937acSRobert Watson.\" modification, are permitted provided that the following conditions
6673937acSRobert Watson.\" are met:
7673937acSRobert Watson.\" 1. Redistributions of source code must retain the above copyright
8673937acSRobert Watson.\"    notice, this list of conditions and the following disclaimer.
9673937acSRobert Watson.\" 2. Redistributions in binary form must reproduce the above copyright
10673937acSRobert Watson.\"    notice, this list of conditions and the following disclaimer in the
11673937acSRobert Watson.\"    documentation and/or other materials provided with the distribution.
12673937acSRobert Watson.\"
13673937acSRobert Watson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14673937acSRobert Watson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15673937acSRobert Watson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16673937acSRobert Watson.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17673937acSRobert Watson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18673937acSRobert Watson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19673937acSRobert Watson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20673937acSRobert Watson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21673937acSRobert Watson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22673937acSRobert Watson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23673937acSRobert Watson.\" SUCH DAMAGE.
24673937acSRobert Watson.\"
25*b6357224SRobert Watson.Dd April 28, 2019
26673937acSRobert Watson.Dt AUDITPIPE 4
27aa12cea2SUlrich Spörlein.Os
28673937acSRobert Watson.Sh NAME
29673937acSRobert Watson.Nm auditpipe
30ae91966bSRuslan Ermilov.Nd "pseudo-device for live audit event tracking"
31673937acSRobert Watson.Sh SYNOPSIS
32673937acSRobert Watson.Cd "options AUDIT"
33673937acSRobert Watson.Sh DESCRIPTION
34673937acSRobert WatsonWhile audit trail files
35673937acSRobert Watsongenerated with
36673937acSRobert Watson.Xr audit 4
37673937acSRobert Watsonand maintained by
38673937acSRobert Watson.Xr auditd 8
39673937acSRobert Watsonprovide a reliable long-term store for audit log information, current log
40673937acSRobert Watsonfiles are owned by the audit daemon until terminated making them somewhat
411735925eSJoel Dahlunwieldy for live monitoring applications such as host-based intrusion
42673937acSRobert Watsondetection.
43673937acSRobert WatsonFor example, the log may be cycled and new records written to a new file
44673937acSRobert Watsonwithout notice to applications that may be accessing the file.
45673937acSRobert Watson.Pp
46673937acSRobert WatsonThe audit facility provides an audit pipe facility for applications requiring
47673937acSRobert Watsondirect access to live BSM audit data for the purposes of real-time
48673937acSRobert Watsonmonitoring.
49673937acSRobert WatsonAudit pipes are available via a clonable special device,
50673937acSRobert Watson.Pa /dev/auditpipe ,
51673937acSRobert Watsonsubject to the permissions on the device node, and provide a
52673937acSRobert Watson.Qq tee
53673937acSRobert Watsonof the audit event stream.
54673937acSRobert WatsonAs the device is clonable, more than one instance of the device may be opened
55673937acSRobert Watsonat a time; each device instance will provide independent access to all
56673937acSRobert Watsonrecords.
57673937acSRobert Watson.Pp
58673937acSRobert WatsonThe audit pipe device provides discrete BSM audit records; if the read buffer
59673937acSRobert Watsonpassed by the application is too small to hold the next record in the
60673937acSRobert Watsonsequence, it will be dropped.
61673937acSRobert WatsonUnlike audit data written to the audit trail, the reliability of record
62673937acSRobert Watsondelivery is not guaranteed.
63673937acSRobert WatsonIn particular, when an audit pipe queue fills, records will be dropped.
64673937acSRobert WatsonAudit pipe devices are blocking by default, but support non-blocking I/O,
65ae91966bSRuslan Ermilovasynchronous I/O using
66ae91966bSRuslan Ermilov.Dv SIGIO ,
67ae91966bSRuslan Ermilovand polled operation via
68673937acSRobert Watson.Xr select 2
69673937acSRobert Watsonand
70673937acSRobert Watson.Xr poll 2 .
71673937acSRobert Watson.Pp
72673937acSRobert WatsonApplications may choose to track the global audit trail, or configure local
73673937acSRobert Watsonpreselection parameters independent of the global audit trail parameters.
74673937acSRobert Watson.Ss Audit Pipe Queue Ioctls
75673937acSRobert WatsonThe following ioctls retrieve and set various audit pipe record queue
76673937acSRobert Watsonproperties:
77ae91966bSRuslan Ermilov.Bl -tag -width ".Dv AUDITPIPE_GET_MAXAUDITDATA"
78ae91966bSRuslan Ermilov.It Dv AUDITPIPE_GET_QLEN
79673937acSRobert WatsonQuery the current number of records available for reading on the pipe.
80ae91966bSRuslan Ermilov.It Dv AUDITPIPE_GET_QLIMIT
81673937acSRobert WatsonRetrieve the current maximum number of records that may be queued for reading
82673937acSRobert Watsonon the pipe.
83ae91966bSRuslan Ermilov.It Dv AUDITPIPE_SET_QLIMIT
84673937acSRobert WatsonSet the current maximum number of records that may be queued for reading on
85673937acSRobert Watsonthe pipe.
86673937acSRobert WatsonThe new limit must fall between the queue limit minimum and queue limit
87673937acSRobert Watsonmaximum queryable using the following two ioctls.
88ae91966bSRuslan Ermilov.It Dv AUDITPIPE_GET_QLIMIT_MIN
89673937acSRobert WatsonQuery the lowest possible maximum number of records that may be queued for
90673937acSRobert Watsonreading on the pipe.
91ae91966bSRuslan Ermilov.It Dv AUDITPIPE_GET_QLIMIT_MAX
92673937acSRobert WatsonQuery the highest possible maximum number of records that may be queued for
93673937acSRobert Watsonreading on the pipe.
94ae91966bSRuslan Ermilov.It Dv AUDITPIPE_FLUSH
95673937acSRobert WatsonFlush all outstanding records on the audit pipe; useful after setting initial
96673937acSRobert Watsonpreselection properties to delete records queued during the configuration
97673937acSRobert Watsonprocess which may not match the interests of the user process.
98ae91966bSRuslan Ermilov.It Dv AUDITPIPE_GET_MAXAUDITDATA
999fe741b8SRobert WatsonQuery the maximum size of an audit record, which is a useful minimum size for
1009fe741b8SRobert Watsona user space buffer intended to hold audit records read from the audit pipe.
101673937acSRobert Watson.El
102673937acSRobert Watson.Ss Audit Pipe Preselection Mode Ioctls
103673937acSRobert WatsonBy default, the audit pipe facility configures pipes to present records
104673937acSRobert Watsonmatched by the system-wide audit trail, configured by
105673937acSRobert Watson.Xr auditd 8 .
106673937acSRobert WatsonHowever, the preselection mechanism for audit pipes can be configured using
107673937acSRobert Watsonalternative criteria, including pipe-local flags and naflags settings, as
108673937acSRobert Watsonwell as auid-specific selection masks.
109673937acSRobert WatsonThis allows applications to track events not captured in the global audit
110673937acSRobert Watsontrail, as well as limit records presented to those of specific interest to
111673937acSRobert Watsonthe application.
112673937acSRobert Watson.Pp
113673937acSRobert WatsonThe following ioctls configure the preselection mode on an audit pipe:
114ae91966bSRuslan Ermilov.Bl -tag -width ".Dv AUDITPIPE_GET_PRESELECT_MODE"
115ae91966bSRuslan Ermilov.It Dv AUDITPIPE_GET_PRESELECT_MODE
116673937acSRobert WatsonReturn the current preselect mode on the audit pipe.
117673937acSRobert WatsonThe ioctl argument should be of type
118673937acSRobert Watson.Vt int .
119ae91966bSRuslan Ermilov.It Dv AUDITPIPE_SET_PRESELECT_MODE
120673937acSRobert WatsonSet the current preselection mode on the audit pipe.
121673937acSRobert WatsonThe ioctl argument should be of type
122673937acSRobert Watson.Vt int .
123673937acSRobert Watson.El
124673937acSRobert Watson.Pp
125673937acSRobert WatsonPossible preselection mode values are:
126ae91966bSRuslan Ermilov.Bl -tag -width ".Dv AUDITPIPE_PRESELECT_MODE_TRAIL"
127ae91966bSRuslan Ermilov.It Dv AUDITPIPE_PRESELECT_MODE_TRAIL
128673937acSRobert WatsonUse the global audit trail preselection parameters to select records for the
129673937acSRobert Watsonaudit pipe.
130ae91966bSRuslan Ermilov.It Dv AUDITPIPE_PRESELECT_MODE_LOCAL
131673937acSRobert WatsonUse local audit pipe preselection; this model is similar to the global audit
1321735925eSJoel Dahltrail configuration model, consisting of global flags and naflags parameters,
133673937acSRobert Watsonas well as a set of per-auid masks.
134673937acSRobert WatsonThese parameters are configured using further ioctls.
135673937acSRobert Watson.El
136673937acSRobert Watson.Pp
137673937acSRobert WatsonAfter changing the audit pipe preselection mode, records selected under
138673937acSRobert Watsonearlier preselection configuration may still be in the audit pipe queue.
139673937acSRobert WatsonThe application may flush the current record queue after changing the
140673937acSRobert Watsonconfiguration to remove possibly undesired records.
141673937acSRobert Watson.Ss Audit Pipe Local Preselection Mode Ioctls
1421735925eSJoel DahlThe following ioctls configure the preselection parameters used when an audit
143673937acSRobert Watsonpipe is configured for the
144673937acSRobert Watson.Dv AUDITPIPE_PRESELECT_MODE_LOCAL
145673937acSRobert Watsonpreselection mode.
146ae91966bSRuslan Ermilov.Bl -tag -width ".Dv AUDITPIPE_GET_PRESELECT_NAFLAGS"
147ae91966bSRuslan Ermilov.It Dv AUDITPIPE_GET_PRESELECT_FLAGS
148673937acSRobert WatsonRetrieve the current default preselection flags for attributable events on
149673937acSRobert Watsonthe pipe.
150673937acSRobert WatsonThese flags correspond to the
151ae91966bSRuslan Ermilov.Va flags
152673937acSRobert Watsonfield in
153673937acSRobert Watson.Xr audit_control 5 .
154673937acSRobert WatsonThe ioctl argument should be of type
155d91dccb1SAlan Somers.Vt au_mask_t .
156ae91966bSRuslan Ermilov.It Dv AUDITPIPE_SET_PRESELECT_FLAGS
157673937acSRobert WatsonSet the current default preselection flags for attributable events on the
158673937acSRobert Watsonpipe.
159673937acSRobert WatsonThese flags correspond to the
160ae91966bSRuslan Ermilov.Va flags
161673937acSRobert Watsonfield in
162673937acSRobert Watson.Xr audit_control 5 .
163673937acSRobert WatsonThe ioctl argument should be of type
164d91dccb1SAlan Somers.Vt au_mask_t .
165ae91966bSRuslan Ermilov.It Dv AUDITPIPE_GET_PRESELECT_NAFLAGS
166673937acSRobert WatsonRetrieve the current default preselection flags for non-attributable events
167673937acSRobert Watsonon the pipe.
168673937acSRobert WatsonThese flags correspond to the
169ae91966bSRuslan Ermilov.Va naflags
170673937acSRobert Watsonfield in
171673937acSRobert Watson.Xr audit_control 5 .
172673937acSRobert WatsonThe ioctl argument should be of type
173d91dccb1SAlan Somers.Vt au_mask_t .
174ae91966bSRuslan Ermilov.It Dv AUDITPIPE_SET_PRESELECT_NAFLAGS
175673937acSRobert WatsonSet the current default preselection flags for non-attributable events on the
176673937acSRobert Watsonpipe.
177673937acSRobert WatsonThese flags correspond to the
178ae91966bSRuslan Ermilov.Va naflags
179673937acSRobert Watsonfield in
180673937acSRobert Watson.Xr audit_control 5 .
181673937acSRobert WatsonThe ioctl argument should be of type
182d91dccb1SAlan Somers.Vt au_mask_t .
183ae91966bSRuslan Ermilov.It Dv AUDITPIPE_GET_PRESELECT_AUID
184673937acSRobert WatsonQuery the current preselection masks for a specific auid on the pipe.
185673937acSRobert WatsonThe ioctl argument should be of type
186b9540a02SRobert Watson.Vt "struct auditpipe_ioctl_preselect" .
187673937acSRobert WatsonThe auid to query is specified via the
188673937acSRobert Watson.Va ap_auid
189673937acSRobert Watsonfield of type
190673937acSRobert Watson.Vt au_id_t ;
191673937acSRobert Watsonthe mask will be returned via
192673937acSRobert Watson.Va ap_mask
193673937acSRobert Watsonof type
194673937acSRobert Watson.Vt au_mask_t .
195ae91966bSRuslan Ermilov.It Dv AUDITPIPE_SET_PRESELECT_AUID
196673937acSRobert WatsonSet the current preselection masks for a specific auid on the pipe.
197673937acSRobert WatsonArguments are identical to
198673937acSRobert Watson.Dv AUDITPIPE_GET_PRESELECT_AUID ,
199673937acSRobert Watsonexcept that the caller should properly initialize the
200673937acSRobert Watson.Va ap_mask
201673937acSRobert Watsonfield to hold the desired preselection mask.
202ae91966bSRuslan Ermilov.It Dv AUDITPIPE_DELETE_PRESELECT_AUID
203673937acSRobert WatsonDelete the current preselection mask for a specific auid on the pipe.
204673937acSRobert WatsonOnce called, events associated with the specified auid will use the default
205673937acSRobert Watsonflags mask.
206673937acSRobert WatsonThe ioctl argument should be of type
207673937acSRobert Watson.Vt au_id_t .
208ae91966bSRuslan Ermilov.It Dv AUDITPIPE_FLUSH_PRESELECT_AUID
209673937acSRobert WatsonDelete all auid specific preselection specifications.
210673937acSRobert Watson.El
211673937acSRobert Watson.Sh EXAMPLES
212ae91966bSRuslan ErmilovThe
213673937acSRobert Watson.Xr praudit 1
214ae91966bSRuslan Ermilovutility
215673937acSRobert Watsonmay be directly executed on
216673937acSRobert Watson.Pa /dev/auditpipe
217673937acSRobert Watsonto review the default audit trail.
218673937acSRobert Watson.Sh SEE ALSO
219673937acSRobert Watson.Xr poll 2 ,
220673937acSRobert Watson.Xr select 2 ,
221673937acSRobert Watson.Xr audit 4 ,
222*b6357224SRobert Watson.Xr dtaudit 4 ,
223673937acSRobert Watson.Xr audit_control 5 ,
224673937acSRobert Watson.Xr audit 8 ,
225673937acSRobert Watson.Xr auditd 8
226ae91966bSRuslan Ermilov.Sh HISTORY
227ae91966bSRuslan ErmilovThe OpenBSM implementation was created by McAfee Research, the security
228ae91966bSRuslan Ermilovdivision of McAfee Inc., under contract to Apple Computer Inc.\& in 2004.
229ae91966bSRuslan ErmilovIt was subsequently adopted by the TrustedBSD Project as the foundation for
230ae91966bSRuslan Ermilovthe OpenBSM distribution.
231ae91966bSRuslan Ermilov.Pp
232ae91966bSRuslan ErmilovSupport for kernel audit first appeared in
233ae91966bSRuslan Ermilov.Fx 6.2 .
234673937acSRobert Watson.Sh AUTHORS
235673937acSRobert WatsonThe audit pipe facility was designed and implemented by
2366c899950SBaptiste Daroussin.An Robert Watson Aq Mt rwatson@FreeBSD.org .
237673937acSRobert Watson.Pp
238673937acSRobert WatsonThe Basic Security Module (BSM) interface to audit records and audit event
239673937acSRobert Watsonstream format were defined by Sun Microsystems.
240673937acSRobert Watson.Sh BUGS
241673937acSRobert WatsonSee the
242673937acSRobert Watson.Xr audit 4
243673937acSRobert Watsonmanual page for information on audit-related bugs and limitations.
244673937acSRobert Watson.Pp
245673937acSRobert WatsonThe configurable preselection mechanism mirrors the selection model present
246673937acSRobert Watsonfor the global audit trail.
247d91dccb1SAlan SomersIt might be desirable to provide a more flexible selection model.
248673937acSRobert Watson.Pp
2490af22117SMike PritchardThe per-pipe audit event queue is fifo, with drops occurring if either the
250673937acSRobert Watsonuser thread provides in sufficient for the record on the queue head, or on
251673937acSRobert Watsonenqueue if there is insufficient room.
252673937acSRobert WatsonIt might be desirable to support partial reads of records, which would be
253673937acSRobert Watsonmore compatible with buffered I/O as implemented in system libraries, and to
254673937acSRobert Watsonallow applications to select which records are dropped, possibly in the style
255673937acSRobert Watsonof preselection.
256