1AUDITCTL:(8)            System Administration Utilities           AUDITCTL:(8)
2
3
4

NAME

6       auditctl - a utility to assist controlling the kernel's audit system
7

SYNOPSIS

9       auditctl [options]
10

DESCRIPTION

12       The  auditctl  program is used to control the behavior, get status, and
13       add or delete rules into the 2.6 kernel's audit system.
14

OPTIONS

16       -b backlog
17              Set max number of  outstanding  audit  buffers  allowed  (Kernel
18              Default=64)  If  all  buffers are full, the failure flag is con‐
19              sulted by the kernel for action.
20
21       -e [0..2]
22              Set enabled flag. When 0 is passed, this can be used  to  tempo‐
23              rarily  disable  auditing.  When  1 is passed as an argument, it
24              will enable auditing. To lock the audit configuration so that it
25              can't be changed, pass a 2 as the argument. Locking the configu‐
26              ration is intended to be the last  command  in  audit.rules  for
27              anyone  wishing this feature to be active. Any attempt to change
28              the configuration in this mode will be audited and  denied.  The
29              configuration can only be changed by rebooting the machine.
30
31       -f [0..2]
32              Set failure flag 0=silent 1=printk 2=panic. This option lets you
33              determine how you want the kernel  to  handle  critical  errors.
34              Example conditions where this flag is consulted includes: trans‐
35              mission  errors  to  userspace  audit  daemon,   backlog   limit
36              exceeded,  out  of  kernel  memory, and rate limit exceeded. The
37              default value is 1. Secure environments will  probably  want  to
38              set this to 2.
39
40       -h     Help
41
42       -i     Ignore errors when reading rules from a file
43
44       -l     List all rules 1 per line. This can take a key option (-k), too.
45
46       -k key Set  a  filter  key on an audit rule. The filter key is an arbi‐
47              trary string of text that can be up to 31  bytes  long.  It  can
48              uniquely  identify the audit records produced by a rule. Typical
49              use is for when you have several rules that together  satisfy  a
50              security  requirement.  The  key  value  can be searched on with
51              ausearch so that no matter which rule triggered the  event,  you
52              can  find  its  results.  The key can also be used on delete all
53              (-D) and list rules (-l) to select rules with  a  specific  key.
54              You  may have more than one key on a rule if you want to be able
55              to search logged events in multiple ways or if you have an  aud‐
56              ispd plugin that uses a key to aid its analysis.
57
58       -m text
59              Send  a  user space message into the audit system. This can only
60              be done if you have  CAP_AUDIT_WRITE  capability  (normally  the
61              root user has this). The resulting event will be the USER type.
62
63       -p [r|w|x|a]
64              Describe  the  permission  access  type that a file system watch
65              will trigger on. r=read, w=write, x=execute, a=attribute change.
66              These  permissions  are  not  the standard file permissions, but
67              rather the kind of syscall that would do this kind of thing. The
68              read & write syscalls are omitted from this set since they would
69              overwhelm the logs. But rather for reads  or  writes,  the  open
70              flags are looked at to see what permission was requested.
71
72       -q mount-point,subtree
73              If  you  have an existing directory watch and bind or move mount
74              another subtree in the watched subtree, you  need  to  tell  the
75              kernel  to  make  the  subtree  being  mounted equivalent to the
76              directory being watched. If the subtree is  already  mounted  at
77              the time the directory watch is issued, the subtree is automati‐
78              cally tagged for watching. Please note the comma separating  the
79              two values. Omitting it will cause errors.
80
81       -r rate
82              Set limit in messages/sec (0=none). If this rate is non-zero and
83              is exceeded, the failure flag is consulted  by  the  kernel  for
84              action. The default value is 0.
85
86       -R file
87              Read  rules from a file. The rules must be 1 per line and in the
88              order that they are to be executed in. The  rule  file  must  be
89              owned  by  root  and  not  readable by other users or it will be
90              rejected. The rule file may have comments embedded  by  starting
91              the  line  with a '#' character. Rules that are read from a file
92              are identical to what you would type on a  command  line  except
93              they  are  not  preceded  by auditctl (since auditctl is the one
94              executing the file).
95
96       -s     Report the kernel's audit subsystem status. It will tell you the
97              in-kernel  values that can be set by -e, -f, -r, and -b options.
98              The pid value is the process number of the  audit  daemon.  Note
99              that  a pid of 0 indicates that the audit daemon is not running.
100              The lost entry will tell you how many event  records  that  have
101              been  discarded  due  to the kernel audit queue overflowing. The
102              backlog field tells how many event records are currently  queued
103              waiting for auditd to read them.
104
105       -t     Trim the subtrees after a mount command.
106
107       -a [list,action|action,list]
108              Append  rule  to  the  end  of list with action. Please note the
109              comma separating the two values. Omitting it will cause  errors.
110              The  fields  may  be in either order. It could be list,action or
111              action,list. The following describes the valid list names:
112
113              task        Add a rule to the per task list. This rule  list  is
114                          used  only  at  the  time  a task is created -- when
115                          fork() or clone() are called  by  the  parent  task.
116                          When  using  this  list,  you should only use fields
117                          that are known at task creation time,  such  as  the
118                          uid, gid, etc.
119
120              exit        Add  a  rule  to the syscall exit list. This list is
121                          used upon exit from a system call to determine if an
122                          audit event should be created.
123
124              user        Add  a  rule  to  the user message filter list. This
125                          list is used by the kernel to filter  events  origi‐
126                          nating  in  user  space  before relaying them to the
127                          audit daemon. It  should  be  noted  that  the  only
128                          fields  that  are  valid  are:  uid, auid, gid, pid,
129                          subj_user,  subj_role,  subj_type,   subj_sen,   and
130                          subj_clr.  All  other fields will be treated as non-
131                          matching.
132
133              exclude     Add a rule to the event type exclusion filter  list.
134                          This  list  is used to filter events that you do not
135                          want to see. For example, if you do not want to  see
136                          any  avc  messages,  you  would  using  this list to
137                          record that. The message type that you do  not  wish
138                          to see is given with the msgtype field.
139
140       The following describes the valid actions for the rule:
141
142              never       No audit records will be generated. This can be used
143                          to suppress event generation. In general,  you  want
144                          suppressions  at  the top of the list instead of the
145                          bottom. This is because the event  triggers  on  the
146                          first matching rule.
147
148              always      Allocate  an  audit  context,  always  fill it in at
149                          syscall entry time, and always write out a record at
150                          syscall exit time.
151
152       -A list,action
153              Add rule to the beginning list with action.
154
155       -d list,action
156              Delete  rule  from list with action. The rule is deleted only if
157              it exactly matches syscall name(s)  and  every  field  name  and
158              value.
159
160       -D     Delete  all  rules and watches. This can take a key option (-k),
161              too.
162
163       -S [Syscall name or number|all]
164              Any syscall name or number may be used. The word 'all' may  also
165              be  used.  If the given syscall is made by a program, then start
166              an audit record. If a field rule is  given  and  no  syscall  is
167              specified, it will default to all syscalls. You may also specify
168              multiple syscalls in the same rule by using multiple -S  options
169              in  the  same  rule.  Doing  so improves performance since fewer
170              rules need to be evaluated. If you are on a bi-arch system, like
171              x86_64, you should be aware that auditctl simply takes the text,
172              looks it up for the native arch (in this  case  b64)  and  sends
173              that  rule to the kernel. If there are no additional arch direc‐
174              tives, IT WILL APPLY TO BOTH 32 & 64 BIT SYSCALLS. This can have
175              undesirable  effects since there is no guarantee that, for exam‐
176              ple, the open syscall has the same number on both 32 and 64  bit
177              interfaces.  You  will  likely  want to control this and write 2
178              rules, one with arch equal to b32 and one with b64 to make  sure
179              the  kernel finds the events that you intend. See the arch field
180              discussion for more info.
181
182       -F [n=v | n!=v | n<v | n>v | n<=v | n>=v | n&v | n&=v]
183              Build a rule field: name, operation, value. You may have  up  to
184              64  fields  passed on a single command line. Each one must start
185              with -F. Each field equation is anded with each other to trigger
186              an  audit  record.  There are 8 operators supported - equal, not
187              equal, less than, greater than, less than or equal, and  greater
188              than  or  equal,  bit  mask, and bit test respectively. Bit test
189              will "and" the values and check that they are  equal,  bit  mask
190              just  "ands"  the values. Fields that take a user ID may instead
191              have the user's name; the program will convert the name to  user
192              ID. The same is true of group names. Valid fields are:
193
194              a0, a1, a2, a3
195                          Respectively,  the  first  4 arguments to a syscall.
196                          Note that string arguments are not  supported.  This
197                          is  because  the  kernel  is passed a pointer to the
198                          string. Triggering on a pointer address value is not
199                          likely to work. So, when using this, you should only
200                          use on numeric values. This is  most  likely  to  be
201                          used on platforms that multiplex socket or IPC oper‐
202                          ations.
203
204              arch        The CPU architecture of the syscall. The arch can be
205                          found  doing 'uname -m'. If you do not know the arch
206                          of your machine but you  want  to  use  the  32  bit
207                          syscall  table and your machine supports 32 bit, you
208                          can also use b32 for the arch. The same  applies  to
209                          the  64 bit syscall table, you can use b64.  In this
210                          way, you can write  rules  that  are  somewhat  arch
211                          independent  because  the  family  type will be auto
212                          detected. However, syscalls can be arch specific and
213                          what is available on x86_64, may not be available on
214                          ppc. The arch directive should precede the -S option
215                          so  that  auditctl knows which internal table to use
216                          to look up the syscall numbers.
217
218              auid        The original ID the user  logged  in  with.  Its  an
219                          abbreviation of audit uid. Sometimes its referred to
220                          as loginuid. Either the user account text or  number
221                          may be used.
222
223              devmajor    Device Major Number
224
225              devminor    Device Minor Number
226
227              dir         Full  Path  of Directory to watch. This will place a
228                          recursive watch on the directory and its whole  sub‐
229                          tree. It can only be used on exit list. See "-w".
230
231              egid        Effective  Group  ID.  May  be numeric or the groups
232                          name.
233
234              euid        Effective User  ID.  May  be  numeric  or  the  user
235                          account name.
236
237              exit        Exit  value  from  a syscall. If the exit code is an
238                          errno, you may use the text representation, too.
239
240              fsgid       Filesystem Group ID. May be numeric  or  the  groups
241                          name.
242
243              fsuid       Filesystem  User  ID.  May  be  numeric  or the user
244                          account name.
245
246              filetype    The target file's type. Can  be  either  file,  dir,
247                          socket, symlink, char, block, or fifo.
248
249              gid         Group ID. May be numeric or the groups name.
250
251              inode       Inode Number
252
253              key         This  is  another  way  of setting a filter key. See
254                          discussion above for -k option.
255
256              msgtype     This is used to match the event's  record  type.  It
257                          should only be used on the exclude filter list.
258
259              obj_user    Resource's SE Linux User
260
261              obj_role    Resource's SE Linux Role
262
263              obj_type    Resource's SE Linux Type
264
265              obj_lev_low Resource's SE Linux Low Level
266
267              obj_lev_high
268                          Resource's SE Linux High Level
269
270              path        Full  Path  of File to watch. It can only be used on
271                          exit list.
272
273              perm        Permission filter for file operations. See "-p".  It
274                          can  only  be  used  on  exit list. You can use this
275                          without specifying a syscall  and  the  kernel  will
276                          select  the  syscalls  that  satisfy the permissions
277                          being requested.
278
279              pers        OS Personality Number
280
281              pid         Process ID
282
283              ppid        Parent's Process ID
284
285              subj_user   Program's SE Linux User
286
287              subj_role   Program's SE Linux Role
288
289              subj_type   Program's SE Linux Type
290
291              subj_sen    Program's SE Linux Sensitivity
292
293              subj_clr    Program's SE Linux Clearance
294
295              sgid        Saved Group ID. See getresgid(2) man page.
296
297              success     If the exit value is >= 0 this is true/yes otherwise
298                          its  false/no.  When  writing  a  rule,  use a 1 for
299                          true/yes and a 0 for false/no
300
301              suid        Saved User ID. See getresuid(2) man page.
302
303              uid         User ID. May be numeric or the user account name.
304
305       -w path
306              Insert a watch for the file system object at  path.  You  cannot
307              insert a watch to the top level directory. This is prohibited by
308              the kernel. Wildcards are not supported either and will generate
309              a  warning.  The  way that watches work is by tracking the inode
310              internally. If you place a watch on a  file,  its  the  same  as
311              using the -F path option on a syscall rule. If you place a watch
312              on a directory, its the same as using the -F  dir  option  on  a
313              syscall  rule.  The  -w form of writing watches is for backwards
314              compatibility and the syscall based  form  is  more  expressive.
315              Unlike  most  syscall auditing rules, watches do not impact per‐
316              formance based on the number of rules sent to  the  kernel.  The
317              only  valid options when using a watch are the -p and -k. If you
318              need to anything fancy like audit a specific  user  accessing  a
319              file,  then  use  the syscall auditing form with the path or dir
320              fields. See the EXAMPLES section for an  example  of  converting
321              one form to another.
322
323       -W path
324              Remove a watch for the file system object at path. The rule must
325              match exactly. See -d discussion for more info.
326

PERFORMANCE TIPS

328       Syscall rules get evaluated for each syscall for every program. If  you
329       have 10 syscall rules, every program on your system will delay during a
330       syscall while the audit system evaluates each rule.  Too  many  syscall
331       rules will hurt performance. Try to combine as many as you can whenever
332       the filter, action, key, and fields are identical. For example:
333
334       auditctl -a exit,always -S open -F success=0
335       auditctl -a exit,always -S truncate -F success=0
336
337       could be re-written as one rule:
338
339       auditctl -a exit,always -S open -S truncate -F success=0
340
341       Also, try to use file system auditing wherever practical. This improves
342       performance.  For  example,  if  you were wanting to capture all failed
343       opens & truncates like above, but were only concerned  about  files  in
344       /etc  and  didn't  care  about  /usr or /sbin, its possible to use this
345       rule:
346
347       auditctl -a exit,always -S open -S truncate -F dir=/etc -F success=0
348
349       This will be higher performance since the kernel will not  evaluate  it
350       each  and  every syscall. It will be handled by the filesystem auditing
351       code and only checked on filesystem related syscalls.
352

EXAMPLES

354       To see all syscalls made by a specific program:
355
356       auditctl -a exit,always -S all -F pid=1005
357
358       To see files opened by a specific user:
359
360       auditctl -a exit,always -S open -F auid=510
361
362       To see unsuccessful open calls:
363
364       auditctl -a exit,always -S open -F success=0
365
366       To watch a file for changes (2 ways to express):
367
368       auditctl -w /etc/shadow -p wa
369       auditctl -a exit,always -F path=/etc/shadow -F perm=wa
370
371       To recursively watch a directory for changes (2 ways to express):
372
373       auditctl -w /etc/ -p wa
374       auditctl -a exit,always -F dir=/etc/ -F perm=wa
375
376

FILES

378       /etc/audit/audit.rules
379
380

SEE ALSO

382       audit.rules(7), auditd(8).
383
384

AUTHOR

386       Steve Grubb
387
388
389
390Red Hat                            Feb 2011                       AUDITCTL:(8)
Impressum