blob: c61067b336888c437ecafc7801eb54ab0cc7ba83 [file] [log] [blame]
Joshua Brindle13cd4c82008-08-19 15:30:36 -04001.\" Hey, Emacs! This is an -*- nroff -*- source file.
2.\" Copyright (c) 2005 Manoj Srivastava <srivasta@debian.org>
Daniel J Walsh71b51fd2010-12-22 15:08:33 -05003.\" Copyright (c) 2010 Dan Walsh <dwalsh@redhat.com>
Joshua Brindle13cd4c82008-08-19 15:30:36 -04004.\"
5.\" This is free documentation; you can redistribute it and/or
6.\" modify it under the terms of the GNU General Public License as
7.\" published by the Free Software Foundation; either version 2 of
8.\" the License, or (at your option) any later version.
9.\"
10.\" The GNU General Public License's references to "object code"
11.\" and "executables" are to be interpreted as the output of any
12.\" document formatting or typesetting system, including
13.\" intermediate and printed output.
14.\"
15.\" This manual is distributed in the hope that it will be useful,
16.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18.\" GNU General Public License for more details.
19.\"
20.\" You should have received a copy of the GNU General Public
21.\" License along with this manual; if not, write to the Free
22.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
23.\" USA.
24.\"
25.\"
Daniel J Walsh71b51fd2010-12-22 15:08:33 -050026.TH AUDIT2ALLOW "1" "October 2010" "Security Enhanced Linux" NSA
Joshua Brindle13cd4c82008-08-19 15:30:36 -040027.SH NAME
28.BR audit2allow
Daniel J Walshf509e1e2010-03-08 14:33:03 -050029\- generate SELinux policy allow/dontaudit rules from logs of denied operations
Joshua Brindle13cd4c82008-08-19 15:30:36 -040030
31.BR audit2why
Laurent Bigonville84e08582013-05-10 14:45:21 +020032\- translates SELinux audit messages into a description of why the access was denied (audit2allow \-w)
Joshua Brindle13cd4c82008-08-19 15:30:36 -040033
34.SH SYNOPSIS
35.B audit2allow
36.RI [ options "] "
37.SH OPTIONS
38.TP
39.B "\-a" | "\-\-all"
Laurent Bigonville84e08582013-05-10 14:45:21 +020040Read input from audit and message log, conflicts with \-i
Joshua Brindle13cd4c82008-08-19 15:30:36 -040041.TP
Daniel J Walsh03cd8c22010-03-12 12:58:02 -050042.B "\-b" | "\-\-boot"
Laurent Bigonville84e08582013-05-10 14:45:21 +020043Read input from audit messages since last boot conflicts with \-i
Daniel J Walsh03cd8c22010-03-12 12:58:02 -050044.TP
Joshua Brindle13cd4c82008-08-19 15:30:36 -040045.B "\-d" | "\-\-dmesg"
46Read input from output of
47.I /bin/dmesg.
48Note that all audit messages are not available via dmesg when
Laurent Bigonville84e08582013-05-10 14:45:21 +020049auditd is running; use "ausearch \-m avc | audit2allow" or "\-a" instead.
Joshua Brindle13cd4c82008-08-19 15:30:36 -040050.TP
Daniel J Walshf509e1e2010-03-08 14:33:03 -050051.B "\-D" | "\-\-dontaudit"
52Generate dontaudit rules (Default: allow)
53.TP
Joshua Brindle13cd4c82008-08-19 15:30:36 -040054.B "\-h" | "\-\-help"
55Print a short usage message
56.TP
57.B "\-i <inputfile>" | "\-\-input <inputfile>"
58read input from
59.I <inputfile>
60.TP
61.B "\-l" | "\-\-lastreload"
62read input only after last policy reload
63.TP
64.B "\-m <modulename>" | "\-\-module <modulename>"
65Generate module/require output <modulename>
66.TP
67.B "\-M <modulename>"
Laurent Bigonville84e08582013-05-10 14:45:21 +020068Generate loadable module package, conflicts with \-o
Joshua Brindle13cd4c82008-08-19 15:30:36 -040069.TP
Eric Parisf4ecef52011-09-08 17:25:22 -040070.B "\-p <policyfile>" | "\-\-policy <policyfile>"
71Policy file to use for analysis
72.TP
Joshua Brindle13cd4c82008-08-19 15:30:36 -040073.B "\-o <outputfile>" | "\-\-output <outputfile>"
74append output to
75.I <outputfile>
76.TP
77.B "\-r" | "\-\-requires"
78Generate require output syntax for loadable modules.
79.TP
80.B "\-N" | "\-\-noreference"
81Do not generate reference policy, traditional style allow rules.
82This is the default behavior.
83.TP
84.B "\-R" | "\-\-reference"
85Generate reference policy using installed macros.
86This attempts to match denials against interfaces and may be inaccurate.
87.TP
Jan Zarsky42b4a442018-06-12 11:06:59 +020088.B "\-x" | "\-\-xperms"
89Generate extended permission access vector rules
90.TP
Joshua Brindle13cd4c82008-08-19 15:30:36 -040091.B "\-w" | "\-\-why"
Joshua Brindlecb694552008-11-07 16:50:34 -050092Translates SELinux audit messages into a description of why the access was denied
Joshua Brindle13cd4c82008-08-19 15:30:36 -040093
94.TP
95.B "\-v" | "\-\-verbose"
96Turn on verbose output
97
98.SH DESCRIPTION
99.PP
100This utility scans the logs for messages logged when the system denied
101permission for operations, and generates a snippet of policy rules
102which, if loaded into policy, might have allowed those operations to
103succeed. However, this utility only generates Type Enforcement (TE) allow
104rules. Certain permission denials may require other kinds of policy changes,
105e.g. adding an attribute to a type declaration to satisfy an existing
106constraint, adding a role allow rule, or modifying a constraint. The
107.BR audit2why (8)
108utility may be used to diagnose the reason when it is unclear.
109.PP
110Care must be exercised while acting on the output of this utility to
111ensure that the operations being permitted do not pose a security
112threat. Often it is better to define new domains and/or types, or make other
113structural changes to narrowly allow an optimal set of operations to
114succeed, as opposed to blindly implementing the sometimes broad
115changes recommended by this utility. Certain permission denials are
116not fatal to the application, in which case it may be preferable to
117simply suppress logging of the denial via a 'dontaudit' rule rather than
118an 'allow' rule.
119.PP
120.SH EXAMPLE
121.nf
122.B NOTE: These examples are for systems using the audit package. If you do
123.B not use the audit package, the AVC messages will be in /var/log/messages.
124.B Please substitute /var/log/messages for /var/log/audit/audit.log in the
125.B examples.
126.PP
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400127.B Using audit2allow to generate module policy
128
Laurent Bigonville84e08582013-05-10 14:45:21 +0200129$ cat /var/log/audit/audit.log | audit2allow \-m local > local.te
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400130$ cat local.te
131module local 1.0;
132
133require {
Daniel J Walsh71b51fd2010-12-22 15:08:33 -0500134 class file { getattr open read };
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400135
136
Daniel J Walsh71b51fd2010-12-22 15:08:33 -0500137 type myapp_t;
138 type etc_t;
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400139 };
140
141
Daniel J Walsh71b51fd2010-12-22 15:08:33 -0500142allow myapp_t etc_t:file { getattr open read };
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400143<review local.te and customize as desired>
144
Daniel J Walsh71b51fd2010-12-22 15:08:33 -0500145.B Using audit2allow to generate module policy using reference policy
146
Laurent Bigonville84e08582013-05-10 14:45:21 +0200147$ cat /var/log/audit/audit.log | audit2allow \-R \-m local > local.te
Daniel J Walsh71b51fd2010-12-22 15:08:33 -0500148$ cat local.te
149policy_module(local, 1.0)
150
151gen_require(`
152 type myapp_t;
153 type etc_t;
154 };
155
156files_read_etc_files(myapp_t)
157<review local.te and customize as desired>
158
159.B Building module policy using Makefile
160
Dan Walsh2540b202013-10-09 14:37:31 -0400161# SELinux provides a policy devel environment under
162# /usr/share/selinux/devel including all of the shipped
163# interface files.
Daniel J Walsh71b51fd2010-12-22 15:08:33 -0500164# You can create a te file and compile it by executing
Dan Walsh2540b202013-10-09 14:37:31 -0400165
Laurent Bigonville2e938332013-11-06 13:24:01 +0100166$ make \-f /usr/share/selinux/devel/Makefile local.pp
Dan Walsh2540b202013-10-09 14:37:31 -0400167
168
169# This make command will compile a local.te file in the current
170# directory. If you did not specify a "pp" file, the make file
171# will compile all "te" files in the current directory. After
172# you compile your te file into a "pp" file, you need to install
173# it using the semodule command.
174
Laurent Bigonville84e08582013-05-10 14:45:21 +0200175$ semodule \-i local.pp
Daniel J Walsh71b51fd2010-12-22 15:08:33 -0500176
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400177.B Building module policy manually
178
179# Compile the module
Laurent Bigonville84e08582013-05-10 14:45:21 +0200180$ checkmodule \-M \-m \-o local.mod local.te
Dan Walsh2540b202013-10-09 14:37:31 -0400181
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400182# Create the package
Laurent Bigonville84e08582013-05-10 14:45:21 +0200183$ semodule_package \-o local.pp \-m local.mod
Dan Walsh2540b202013-10-09 14:37:31 -0400184
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400185# Load the module into the kernel
Laurent Bigonville84e08582013-05-10 14:45:21 +0200186$ semodule \-i local.pp
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400187
188.B Using audit2allow to generate and build module policy
Dan Walsh2540b202013-10-09 14:37:31 -0400189
Laurent Bigonville84e08582013-05-10 14:45:21 +0200190$ cat /var/log/audit/audit.log | audit2allow \-M local
Dan Walsh2540b202013-10-09 14:37:31 -0400191Generating type enforcement file: local.te
Stephen Smalleyf458b762013-10-24 15:24:17 -0400192
Laurent Bigonville84e08582013-05-10 14:45:21 +0200193Compiling policy: checkmodule \-M \-m \-o local.mod local.te
194Building package: semodule_package \-o local.pp \-m local.mod
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400195
196******************** IMPORTANT ***********************
197
198In order to load this newly created policy package into the kernel,
199you are required to execute
200
Laurent Bigonville84e08582013-05-10 14:45:21 +0200201semodule \-i local.pp
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400202
Dan Walsh2540b202013-10-09 14:37:31 -0400203.B Using audit2allow to generate monolithic (non\-module) policy
204
Daniel J Walsh71b51fd2010-12-22 15:08:33 -0500205$ cd /etc/selinux/$SELINUXTYPE/src/policy
206$ cat /var/log/audit/audit.log | audit2allow >> domains/misc/local.te
207$ cat domains/misc/local.te
208allow cupsd_config_t unconfined_t:fifo_file { getattr ioctl };
209<review domains/misc/local.te and customize as desired>
210$ make load
211
Joshua Brindle13cd4c82008-08-19 15:30:36 -0400212.fi
213.PP
214.SH AUTHOR
215This manual page was written by
216.I Manoj Srivastava <srivasta@debian.org>,
217for the Debian GNU/Linux system. It was updated by Dan Walsh <dwalsh@redhat.com>
218.PP
219The
220.B audit2allow
221utility has contributions from several people, including
222.I Justin R. Smith
223and
224.I Yuichi Nakamura.
225and
226.I Dan Walsh