Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 1 | .\" Hey, Emacs! This is an -*- nroff -*- source file. |
| 2 | .\" Copyright (c) 2005 Manoj Srivastava <srivasta@debian.org> |
Daniel J Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 3 | .\" Copyright (c) 2010 Dan Walsh <dwalsh@redhat.com> |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 4 | .\" |
| 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 Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 26 | .TH AUDIT2ALLOW "1" "October 2010" "Security Enhanced Linux" NSA |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 27 | .SH NAME |
| 28 | .BR audit2allow |
Daniel J Walsh | f509e1e | 2010-03-08 14:33:03 -0500 | [diff] [blame] | 29 | \- generate SELinux policy allow/dontaudit rules from logs of denied operations |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 30 | |
| 31 | .BR audit2why |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 32 | \- translates SELinux audit messages into a description of why the access was denied (audit2allow \-w) |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 33 | |
| 34 | .SH SYNOPSIS |
| 35 | .B audit2allow |
| 36 | .RI [ options "] " |
| 37 | .SH OPTIONS |
| 38 | .TP |
| 39 | .B "\-a" | "\-\-all" |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 40 | Read input from audit and message log, conflicts with \-i |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 41 | .TP |
Daniel J Walsh | 03cd8c2 | 2010-03-12 12:58:02 -0500 | [diff] [blame] | 42 | .B "\-b" | "\-\-boot" |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 43 | Read input from audit messages since last boot conflicts with \-i |
Daniel J Walsh | 03cd8c2 | 2010-03-12 12:58:02 -0500 | [diff] [blame] | 44 | .TP |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 45 | .B "\-d" | "\-\-dmesg" |
| 46 | Read input from output of |
| 47 | .I /bin/dmesg. |
| 48 | Note that all audit messages are not available via dmesg when |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 49 | auditd is running; use "ausearch \-m avc | audit2allow" or "\-a" instead. |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 50 | .TP |
Daniel J Walsh | f509e1e | 2010-03-08 14:33:03 -0500 | [diff] [blame] | 51 | .B "\-D" | "\-\-dontaudit" |
| 52 | Generate dontaudit rules (Default: allow) |
| 53 | .TP |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 54 | .B "\-h" | "\-\-help" |
| 55 | Print a short usage message |
| 56 | .TP |
| 57 | .B "\-i <inputfile>" | "\-\-input <inputfile>" |
| 58 | read input from |
| 59 | .I <inputfile> |
| 60 | .TP |
| 61 | .B "\-l" | "\-\-lastreload" |
| 62 | read input only after last policy reload |
| 63 | .TP |
| 64 | .B "\-m <modulename>" | "\-\-module <modulename>" |
| 65 | Generate module/require output <modulename> |
| 66 | .TP |
| 67 | .B "\-M <modulename>" |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 68 | Generate loadable module package, conflicts with \-o |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 69 | .TP |
Eric Paris | f4ecef5 | 2011-09-08 17:25:22 -0400 | [diff] [blame] | 70 | .B "\-p <policyfile>" | "\-\-policy <policyfile>" |
| 71 | Policy file to use for analysis |
| 72 | .TP |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 73 | .B "\-o <outputfile>" | "\-\-output <outputfile>" |
| 74 | append output to |
| 75 | .I <outputfile> |
| 76 | .TP |
| 77 | .B "\-r" | "\-\-requires" |
| 78 | Generate require output syntax for loadable modules. |
| 79 | .TP |
| 80 | .B "\-N" | "\-\-noreference" |
| 81 | Do not generate reference policy, traditional style allow rules. |
| 82 | This is the default behavior. |
| 83 | .TP |
| 84 | .B "\-R" | "\-\-reference" |
| 85 | Generate reference policy using installed macros. |
| 86 | This attempts to match denials against interfaces and may be inaccurate. |
| 87 | .TP |
Jan Zarsky | 42b4a44 | 2018-06-12 11:06:59 +0200 | [diff] [blame] | 88 | .B "\-x" | "\-\-xperms" |
| 89 | Generate extended permission access vector rules |
| 90 | .TP |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 91 | .B "\-w" | "\-\-why" |
Joshua Brindle | cb69455 | 2008-11-07 16:50:34 -0500 | [diff] [blame] | 92 | Translates SELinux audit messages into a description of why the access was denied |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 93 | |
| 94 | .TP |
| 95 | .B "\-v" | "\-\-verbose" |
| 96 | Turn on verbose output |
| 97 | |
| 98 | .SH DESCRIPTION |
| 99 | .PP |
| 100 | This utility scans the logs for messages logged when the system denied |
| 101 | permission for operations, and generates a snippet of policy rules |
| 102 | which, if loaded into policy, might have allowed those operations to |
| 103 | succeed. However, this utility only generates Type Enforcement (TE) allow |
| 104 | rules. Certain permission denials may require other kinds of policy changes, |
| 105 | e.g. adding an attribute to a type declaration to satisfy an existing |
| 106 | constraint, adding a role allow rule, or modifying a constraint. The |
| 107 | .BR audit2why (8) |
| 108 | utility may be used to diagnose the reason when it is unclear. |
| 109 | .PP |
| 110 | Care must be exercised while acting on the output of this utility to |
| 111 | ensure that the operations being permitted do not pose a security |
| 112 | threat. Often it is better to define new domains and/or types, or make other |
| 113 | structural changes to narrowly allow an optimal set of operations to |
| 114 | succeed, as opposed to blindly implementing the sometimes broad |
| 115 | changes recommended by this utility. Certain permission denials are |
| 116 | not fatal to the application, in which case it may be preferable to |
| 117 | simply suppress logging of the denial via a 'dontaudit' rule rather than |
| 118 | an '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 Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 127 | .B Using audit2allow to generate module policy |
| 128 | |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 129 | $ cat /var/log/audit/audit.log | audit2allow \-m local > local.te |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 130 | $ cat local.te |
| 131 | module local 1.0; |
| 132 | |
| 133 | require { |
Daniel J Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 134 | class file { getattr open read }; |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 135 | |
| 136 | |
Daniel J Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 137 | type myapp_t; |
| 138 | type etc_t; |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | |
Daniel J Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 142 | allow myapp_t etc_t:file { getattr open read }; |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 143 | <review local.te and customize as desired> |
| 144 | |
Daniel J Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 145 | .B Using audit2allow to generate module policy using reference policy |
| 146 | |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 147 | $ cat /var/log/audit/audit.log | audit2allow \-R \-m local > local.te |
Daniel J Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 148 | $ cat local.te |
| 149 | policy_module(local, 1.0) |
| 150 | |
| 151 | gen_require(` |
| 152 | type myapp_t; |
| 153 | type etc_t; |
| 154 | }; |
| 155 | |
| 156 | files_read_etc_files(myapp_t) |
| 157 | <review local.te and customize as desired> |
| 158 | |
| 159 | .B Building module policy using Makefile |
| 160 | |
Dan Walsh | 2540b20 | 2013-10-09 14:37:31 -0400 | [diff] [blame] | 161 | # SELinux provides a policy devel environment under |
| 162 | # /usr/share/selinux/devel including all of the shipped |
| 163 | # interface files. |
Daniel J Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 164 | # You can create a te file and compile it by executing |
Dan Walsh | 2540b20 | 2013-10-09 14:37:31 -0400 | [diff] [blame] | 165 | |
Laurent Bigonville | 2e93833 | 2013-11-06 13:24:01 +0100 | [diff] [blame] | 166 | $ make \-f /usr/share/selinux/devel/Makefile local.pp |
Dan Walsh | 2540b20 | 2013-10-09 14:37:31 -0400 | [diff] [blame] | 167 | |
| 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 Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 175 | $ semodule \-i local.pp |
Daniel J Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 176 | |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 177 | .B Building module policy manually |
| 178 | |
| 179 | # Compile the module |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 180 | $ checkmodule \-M \-m \-o local.mod local.te |
Dan Walsh | 2540b20 | 2013-10-09 14:37:31 -0400 | [diff] [blame] | 181 | |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 182 | # Create the package |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 183 | $ semodule_package \-o local.pp \-m local.mod |
Dan Walsh | 2540b20 | 2013-10-09 14:37:31 -0400 | [diff] [blame] | 184 | |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 185 | # Load the module into the kernel |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 186 | $ semodule \-i local.pp |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 187 | |
| 188 | .B Using audit2allow to generate and build module policy |
Dan Walsh | 2540b20 | 2013-10-09 14:37:31 -0400 | [diff] [blame] | 189 | |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 190 | $ cat /var/log/audit/audit.log | audit2allow \-M local |
Dan Walsh | 2540b20 | 2013-10-09 14:37:31 -0400 | [diff] [blame] | 191 | Generating type enforcement file: local.te |
Stephen Smalley | f458b76 | 2013-10-24 15:24:17 -0400 | [diff] [blame] | 192 | |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 193 | Compiling policy: checkmodule \-M \-m \-o local.mod local.te |
| 194 | Building package: semodule_package \-o local.pp \-m local.mod |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 195 | |
| 196 | ******************** IMPORTANT *********************** |
| 197 | |
| 198 | In order to load this newly created policy package into the kernel, |
| 199 | you are required to execute |
| 200 | |
Laurent Bigonville | 84e0858 | 2013-05-10 14:45:21 +0200 | [diff] [blame] | 201 | semodule \-i local.pp |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 202 | |
Dan Walsh | 2540b20 | 2013-10-09 14:37:31 -0400 | [diff] [blame] | 203 | .B Using audit2allow to generate monolithic (non\-module) policy |
| 204 | |
Daniel J Walsh | 71b51fd | 2010-12-22 15:08:33 -0500 | [diff] [blame] | 205 | $ cd /etc/selinux/$SELINUXTYPE/src/policy |
| 206 | $ cat /var/log/audit/audit.log | audit2allow >> domains/misc/local.te |
| 207 | $ cat domains/misc/local.te |
| 208 | allow cupsd_config_t unconfined_t:fifo_file { getattr ioctl }; |
| 209 | <review domains/misc/local.te and customize as desired> |
| 210 | $ make load |
| 211 | |
Joshua Brindle | 13cd4c8 | 2008-08-19 15:30:36 -0400 | [diff] [blame] | 212 | .fi |
| 213 | .PP |
| 214 | .SH AUTHOR |
| 215 | This manual page was written by |
| 216 | .I Manoj Srivastava <srivasta@debian.org>, |
| 217 | for the Debian GNU/Linux system. It was updated by Dan Walsh <dwalsh@redhat.com> |
| 218 | .PP |
| 219 | The |
| 220 | .B audit2allow |
| 221 | utility has contributions from several people, including |
| 222 | .I Justin R. Smith |
| 223 | and |
| 224 | .I Yuichi Nakamura. |
| 225 | and |
| 226 | .I Dan Walsh |