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 configure kernel options related to
13       auditing, to see status of the configuration, and to load discretionary
14       audit rules.
15

CONFIGURATION OPTIONS

17       -b backlog
18              Set  max  number  of  outstanding  audit buffers allowed (Kernel
19              Default=64) If all buffers are full, the failure  flag  is  con‐
20              sulted by the kernel for action.
21
22       -c     Continue loading rules in spite of an error. This summarizes the
23              results of loading the rules. The exit code will not be  success
24              if any rule fails to load.
25
26       -D     Delete  all  rules and watches. This can take a key option (-k),
27              too.
28
29       -e [0..2]
30              Set enabled flag. When 0 is passed, this can be used  to  tempo‐
31              rarily  disable  auditing.  When  1 is passed as an argument, it
32              will enable auditing. To lock the audit configuration so that it
33              can't be changed, pass a 2 as the argument. Locking the configu‐
34              ration is intended to be the last  command  in  audit.rules  for
35              anyone  wishing this feature to be active. Any attempt to change
36              the configuration in this mode will be audited and  denied.  The
37              configuration can only be changed by rebooting the machine.
38
39       -f [0..2]
40              Set failure mode 0=silent 1=printk 2=panic. This option lets you
41              determine how you want the kernel  to  handle  critical  errors.
42              Example  conditions where this mode may have an effect includes:
43              transmission errors to userspace  audit  daemon,  backlog  limit
44              exceeded,  out  of  kernel  memory, and rate limit exceeded. The
45              default value is 1. Secure environments will  probably  want  to
46              set this to 2.
47
48       -h     Help
49
50       -i     Ignore  errors  when  reading  rules  from  a  file. This causes
51              auditctl to always return a success exit code.
52
53       -q mount-point,subtree
54              If you have an existing directory watch and bind or  move  mount
55              another  subtree  in  the  watched subtree, you need to tell the
56              kernel to make the  subtree  being  mounted  equivalent  to  the
57              directory  being  watched.  If the subtree is already mounted at
58              the time the directory watch is issued, the subtree is automati‐
59              cally  tagged for watching. Please note the comma separating the
60              two values. Omitting it will cause errors.
61
62       -r rate
63              Set limit in messages/sec (0=none). If this rate is non-zero and
64              is  exceeded,  the  failure  flag is consulted by the kernel for
65              action. The default value is 0.
66
67       -R file
68              Read rules from a file. The rules must be 1 per line and in  the
69              order  that  they  are  to be executed in. The rule file must be
70              owned by root and not readable by other  users  or  it  will  be
71              rejected.  The  rule file may have comments embedded by starting
72              the line with a '#' character. Rules that are read from  a  file
73              are  identical  to  what you would type on a command line except
74              they are not preceded by auditctl (since  auditctl  is  the  one
75              executing  the  file) and you would not use shell escaping since
76              auditctl is reading the file instead of bash.
77
78       -t     Trim the subtrees after a mount command.
79

STATUS OPTIONS

81       -l     List all rules 1 per line. Two more options may be given to this
82              command.  You  can  give  either a key option (-k) to list rules
83              that match a key or a (-i) to have a0 through a3 interpretted to
84              help determine the syscall argument values are correct .
85
86       -m text
87              Send  a  user space message into the audit system. This can only
88              be done if you have  CAP_AUDIT_WRITE  capability  (normally  the
89              root user has this). The resulting event will be the USER type.
90
91       -s     Report the kernel's audit subsystem status. It will tell you the
92              in-kernel values that can be set by -e, -f, -r, and -b  options.
93              The  pid  value  is the process number of the audit daemon. Note
94              that a pid of 0 indicates that the audit daemon is not  running.
95              The  lost  entry  will tell you how many event records that have
96              been discarded due to the kernel audit  queue  overflowing.  The
97              backlog  field tells how many event records are currently queued
98              waiting for auditd to read them. This option can be followed  by
99              the -i to get a couple fields interpreted.
100
101       -v     Print the version of auditctl.
102
103

RULE OPTIONS

105       -a [list,action|action,list]
106              Append  rule  to  the  end  of list with action. Please note the
107              comma separating the two values. Omitting it will cause  errors.
108              The  fields  may  be in either order. It could be list,action or
109              action,list. The following describes the valid list names:
110
111              task        Add a rule to the per task list. This rule  list  is
112                          used  only  at  the  time  a task is created -- when
113                          fork() or clone() are called  by  the  parent  task.
114                          When  using  this  list,  you should only use fields
115                          that are known at task creation time,  such  as  the
116                          uid, gid, etc.
117
118              exit        Add  a  rule  to the syscall exit list. This list is
119                          used upon exit from a system call to determine if an
120                          audit event should be created.
121
122              user        Add  a  rule  to  the user message filter list. This
123                          list is used by the kernel to filter  events  origi‐
124                          nating  in  user  space  before relaying them to the
125                          audit daemon. It  should  be  noted  that  the  only
126                          fields  that  are  valid  are:  uid, auid, gid, pid,
127                          subj_user, subj_role, subj_type, subj_sen, subj_clr,
128                          and  msgtype.  All  other  fields will be treated as
129                          non-matching. It should be understood that any event
130                          originating  from user space from a process that has
131                          CAP_AUDIT_WRITE will  be  recorded  into  the  audit
132                          trail.  This means that the most likely use for this
133                          filter is with rules that have an  action  of  never
134                          since  nothing  has to be done to allow events to be
135                          recorded.
136
137              exclude     Add a rule to the event type exclusion filter  list.
138                          This  list  is used to filter events that you do not
139                          want to see. For example, if you do not want to  see
140                          any  avc  messages,  you  would  using  this list to
141                          record that. The message type that you do  not  wish
142                          to see is given with the msgtype field.
143
144       The following describes the valid actions for the rule:
145
146              never       No audit records will be generated. This can be used
147                          to suppress event generation. In general,  you  want
148                          suppressions  at  the top of the list instead of the
149                          bottom. This is because the event  triggers  on  the
150                          first matching rule.
151
152              always      Allocate  an  audit  context,  always  fill it in at
153                          syscall entry time, and always write out a record at
154                          syscall exit time.
155
156       -A list,action
157              Add rule to the beginning list with action.
158
159       -C [f=f | f!=f]
160              Build  an  inter-field comparison rule: field, operation, field.
161              You may pass multiple comparisons on a single command line. Each
162              one  must start with -C. Each inter-field equation is anded with
163              each other as well as equations starting with -F to  trigger  an
164              audit  record.  There are 2 operators supported - equal, and not
165              equal. Valid fields are:
166
167              auid, uid, euid, suid, fsuid,  obj_uid;  and  gid,  egid,  sgid,
168              fsgid, obj_gid
169
170              The  two groups of uid and gid cannot be mixed. But any compari‐
171              son within the group can be made.  The  obj_uid/gid  fields  are
172              collected  from the object of the event such as a file or direc‐
173              tory.
174
175
176       -d list,action
177              Delete rule from list with action. The rule is deleted  only  if
178              it  exactly  matches  syscall  name(s)  and every field name and
179              value.
180
181       -F [n=v | n!=v | n<v | n>v | n<=v | n>=v | n&v | n&=v]
182              Build a rule field: name, operation, value. You may have  up  to
183              64  fields  passed on a single command line. Each one must start
184              with -F. Each field equation is anded with each other  (as  well
185              as equations starting with -C) to trigger an audit record. There
186              are 8 operators supported - equal, not equal, less than, greater
187              than,  less  than or equal, and greater than or equal, bit mask,
188              and bit test respectively. Bit test will "and"  the  values  and
189              check  that  they  are  equal,  bit mask just "ands" the values.
190              Fields that take a user ID may instead have the user's name; the
191              program  will  convert  the name to user ID. The same is true of
192              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, link, character, 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  or  user  filter
258                          lists.
259
260              obj_uid     Object's UID
261
262              obj_gid     Object's GID
263
264              obj_user    Resource's SE Linux User
265
266              obj_role    Resource's SE Linux Role
267
268              obj_type    Resource's SE Linux Type
269
270              obj_lev_low Resource's SE Linux Low Level
271
272              obj_lev_high
273                          Resource's SE Linux High Level
274
275              path        Full  Path  of File to watch. It can only be used on
276                          exit list.
277
278              perm        Permission filter for file operations. See "-p".  It
279                          can  only  be  used  on  exit list. You can use this
280                          without specifying a syscall  and  the  kernel  will
281                          select  the  syscalls  that  satisfy the permissions
282                          being requested.
283
284              pers        OS Personality Number
285
286              pid         Process ID
287
288              ppid        Parent's Process ID
289
290              subj_user   Program's SE Linux User
291
292              subj_role   Program's SE Linux Role
293
294              subj_type   Program's SE Linux Type
295
296              subj_sen    Program's SE Linux Sensitivity
297
298              subj_clr    Program's SE Linux Clearance
299
300              sgid        Saved Group ID. See getresgid(2) man page.
301
302              success     If the exit value is >= 0 this is true/yes otherwise
303                          its  false/no.  When  writing  a  rule,  use a 1 for
304                          true/yes and a 0 for false/no
305
306              suid        Saved User ID. See getresuid(2) man page.
307
308              uid         User ID. May be numeric or the user account name.
309
310       -k key Set a filter key on an audit rule. The filter key  is  an  arbi‐
311              trary  string  of  text  that can be up to 31 bytes long. It can
312              uniquely identify the audit records produced by a rule.  Typical
313              use  is  for when you have several rules that together satisfy a
314              security requirement. The key value  can  be  searched  on  with
315              ausearch  so  that no matter which rule triggered the event, you
316              can find its results. The key can also be  used  on  delete  all
317              (-D)  and  list  rules (-l) to select rules with a specific key.
318              You may have more than one key on a rule if you want to be  able
319              to  search logged events in multiple ways or if you have an aud‐
320              ispd plugin that uses a key to aid its analysis.
321
322       -p [r|w|x|a]
323              Describe the permission access type that  a  file  system  watch
324              will trigger on. r=read, w=write, x=execute, a=attribute change.
325              These permissions are not the  standard  file  permissions,  but
326              rather the kind of syscall that would do this kind of thing. The
327              read & write syscalls are omitted from this set since they would
328              overwhelm  the  logs.  But  rather for reads or writes, the open
329              flags are looked at to see what permission was requested.
330
331       -S [Syscall name or number|all]
332              Any syscall name or number may be used. The word 'all' may  also
333              be  used.  If the given syscall is made by a program, then start
334              an audit record. If a field rule is  given  and  no  syscall  is
335              specified, it will default to all syscalls. You may also specify
336              multiple syscalls in the same rule by using multiple -S  options
337              in  the  same  rule.  Doing  so improves performance since fewer
338              rules need to be evaluated. Alternatively, you may pass a  comma
339              separated list of syscall names. If you are on a bi-arch system,
340              like x86_64, you should be aware that auditctl simply takes  the
341              text,  looks  it  up  for the native arch (in this case b64) and
342              sends that rule to the kernel. If there are no  additional  arch
343              directives, IT WILL APPLY TO BOTH 32 & 64 BIT SYSCALLS. This can
344              have undesirable effects since there is no  guarantee  that  any
345              syscall  has  the  same number on both 32 and 64 bit interfaces.
346              You will likely want to control this and write 2 rules, one with
347              arch equal to b32 and one with b64 to make sure the kernel finds
348              the events that you intend. See the arch  field  discussion  for
349              more info.
350
351       -w path
352              Insert  a  watch  for the file system object at path. You cannot
353              insert a watch to the top level directory. This is prohibited by
354              the kernel. Wildcards are not supported either and will generate
355              a warning. The way that watches work is by  tracking  the  inode
356              internally.  If  you  place  a  watch on a file, its the same as
357              using the -F path option on a syscall rule. If you place a watch
358              on  a  directory,  its  the same as using the -F dir option on a
359              syscall rule. The -w form of writing watches  is  for  backwards
360              compatibility  and  the  syscall  based form is more expressive.
361              Unlike most syscall auditing rules, watches do not  impact  per‐
362              formance  based  on  the number of rules sent to the kernel. The
363              only valid options when using a watch are the -p and -k. If  you
364              need  to  anything  fancy like audit a specific user accessing a
365              file, then use the syscall auditing form with the  path  or  dir
366              fields.  See  the  EXAMPLES section for an example of converting
367              one form to another.
368
369       -W path
370              Remove a watch for the file system object at path. The rule must
371              match exactly. See -d discussion for more info.
372

PERFORMANCE TIPS

374       Syscall  rules get evaluated for each syscall for every program. If you
375       have 10 syscall rules, every program on your system will delay during a
376       syscall  while  the  audit system evaluates each rule. Too many syscall
377       rules will hurt performance. Try to combine as many as you can whenever
378       the filter, action, key, and fields are identical. For example:
379
380       auditctl -a always,exit -S openat -F success=0
381       auditctl -a always,exit -S truncate -F success=0
382
383       could be re-written as one rule:
384
385       auditctl -a always,exit -S openat -S truncate -F success=0
386
387       Also, try to use file system auditing wherever practical. This improves
388       performance. For example, if you were wanting  to  capture  all  failed
389       opens  &  truncates  like above, but were only concerned about files in
390       /etc and didn't care about /usr or /sbin,  its  possible  to  use  this
391       rule:
392
393       auditctl -a always,exit -S openat -S truncate -F dir=/etc -F success=0
394
395       This  will  be higher performance since the kernel will not evaluate it
396       each and every syscall. It will be handled by the  filesystem  auditing
397       code and only checked on filesystem related syscalls.
398

EXAMPLES

400       To see all syscalls made by a specific program:
401
402       auditctl -a always,exit -S all -F pid=1005
403
404       To see files opened by a specific user:
405
406       auditctl -a always,exit -S openat -F auid=510
407
408       To see unsuccessful openat calls:
409
410       auditctl -a always,exit -S openat -F success=0
411
412       To watch a file for changes (2 ways to express):
413
414       auditctl -w /etc/shadow -p wa
415       auditctl -a always,exit -F path=/etc/shadow -F perm=wa
416
417       To recursively watch a directory for changes (2 ways to express):
418
419       auditctl -w /etc/ -p wa
420       auditctl -a always,exit -F dir=/etc/ -F perm=wa
421
422       To see if an admin is accessing other user's files:
423
424       auditctl -a always,exit -F dir=/home/ -F uid=0 -C auid!=obj_uid
425
426

FILES

428       /etc/audit/audit.rules
429
430

SEE ALSO

432       audit.rules(7), auditd(8).
433
434

AUTHOR

436       Steve Grubb
437
438
439
440Red Hat                            Aug 2014                       AUDITCTL:(8)
Impressum