Skip to content
Snippets Groups Projects
  1. Jul 21, 2023
  2. May 17, 2023
    • Arnd Bergmann's avatar
      audit: avoid missing-prototype warnings · e455ca40
      Arnd Bergmann authored
      
      Building with 'make W=1' reveals two function definitions without
      a previous prototype in the audit code:
      
      lib/compat_audit.c:32:5: error: no previous prototype for 'audit_classify_compat_syscall' [-Werror=missing-prototypes]
      kernel/audit.c:1813:14: error: no previous prototype for 'audit_serial' [-Werror=missing-prototypes]
      
      The first one needs a declaration from linux/audit.h but cannot
      include that header without causing conflicting (compat) syscall number
      definitions, so move the it into linux/audit_arch.h.
      
      The second one is declared conditionally based on CONFIG_AUDITSYSCALL
      but needed as a local function even when that option is disabled, so
      move the declaration out of the #ifdef block.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      e455ca40
  3. Sep 07, 2022
  4. Aug 26, 2022
  5. Feb 22, 2022
  6. Oct 04, 2021
    • Richard Guy Briggs's avatar
      audit: add OPENAT2 record to list "how" info · 571e5c0e
      Richard Guy Briggs authored
      Since the openat2(2) syscall uses a struct open_how pointer to communicate
      its parameters they are not usefully recorded by the audit SYSCALL record's
      four existing arguments.
      
      Add a new audit record type OPENAT2 that reports the parameters in its
      third argument, struct open_how with fields oflag, mode and resolve.
      
      The new record in the context of an event would look like:
      time->Wed Mar 17 16:28:53 2021
      type=PROCTITLE msg=audit(1616012933.531:184): proctitle=
        73797363616C6C735F66696C652F6F70656E617432002F746D702F61756469742D
        7465737473756974652D737641440066696C652D6F70656E617432
      type=PATH msg=audit(1616012933.531:184): item=1 name="file-openat2"
        inode=29 dev=00:1f mode=0100600 ouid=0 ogid=0 rdev=00:00
        obj=unconfined_u:object_r:user_tmp_t:s0 nametype=CREATE
        cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
      type=PATH msg=audit(1616012933.531:184):
        item=0 name="/root/rgb/git/audit-testsuite/tests"
        inode=25 dev=00:1f mode=040700 ouid=0 ogid=0 rdev=00:00
        obj=unconfined_u:object_r:user_tmp_t:s0 nametype=PARENT
        cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
      type=CWD msg=audit(1616012933.531:184):
        cwd="/root/rgb/git/audit-testsuite/tests"
      type=OPENAT2 msg=audit(1616012933.531:184):
        oflag=0100302 mode=0600 resolve=0xa
      type=SYSCALL msg=audit(1616012933.531:184): arch=c000003e syscall=437
        success=yes exit=4 a0=3 a1=7ffe315f1c53 a2=7ffe315f1550 a3=18
        items=2 ppid=528 pid=540 auid=0 uid=0 gid=0 euid=0 suid=0
        fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS0 ses=1 comm="openat2"
        exe="/root/rgb/git/audit-testsuite/tests/syscalls_file/openat2"
        subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
        key="testsuite-1616012933-bjAUcEPO"
      
      Link: https://lore.kernel.org/r/d23fbb89186754487850367224b060e26f9b7181.1621363275.git.rgb@redhat.com
      
      
      Signed-off-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      [PM: tweak subject, wrap example, move AUDIT_OPENAT2 to 1337]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      571e5c0e
  7. Sep 20, 2021
    • Paul Moore's avatar
      audit,io_uring,io-wq: add some basic audit support to io_uring · 5bd2182d
      Paul Moore authored
      
      This patch adds basic auditing to io_uring operations, regardless of
      their context.  This is accomplished by allocating audit_context
      structures for the io-wq worker and io_uring SQPOLL kernel threads
      as well as explicitly auditing the io_uring operations in
      io_issue_sqe().  Individual io_uring operations can bypass auditing
      through the "audit_skip" field in the struct io_op_def definition for
      the operation; although great care must be taken so that security
      relevant io_uring operations do not bypass auditing; please contact
      the audit mailing list (see the MAINTAINERS file) with any questions.
      
      The io_uring operations are audited using a new AUDIT_URINGOP record,
      an example is shown below:
      
        type=UNKNOWN[1336] msg=audit(1631800225.981:37289):
          uring_op=19 success=yes exit=0 items=0 ppid=15454 pid=15681
          uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0
          subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
          key=(null)
      
      Thanks to Richard Guy Briggs for review and feedback.
      
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      5bd2182d
    • Paul Moore's avatar
      audit: prepare audit_context for use in calling contexts beyond syscalls · 12c5e81d
      Paul Moore authored
      
      This patch cleans up some of our audit_context handling by
      abstracting out the reset and return code fixup handling to dedicated
      functions.  Not only does this help make things easier to read and
      inspect, it allows for easier reuse by future patches.  We also
      convert the simple audit_context->in_syscall flag into an enum which
      can be used to by future patches to indicate a calling context other
      than the syscall context.
      
      Thanks to Richard Guy Briggs for review and feedback.
      
      Acked-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      12c5e81d
  8. Jul 20, 2021
  9. Jun 11, 2021
  10. Jun 09, 2021
  11. Mar 24, 2021
    • Arnd Bergmann's avatar
      audit: avoid -Wempty-body warning · d4ceb1d6
      Arnd Bergmann authored
      
      gcc warns about an empty statement when audit_remove_mark is defined to
      nothing:
      
      kernel/auditfilter.c: In function 'audit_data_to_entry':
      kernel/auditfilter.c:609:51: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
        609 |                 audit_remove_mark(entry->rule.exe); /* that's the template one */
            |                                                   ^
      
      Change the macros to use the usual "do { } while (0)" instead, and change a
      few more that were (void)0, for consistency.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      d4ceb1d6
  12. Aug 18, 2020
  13. Jul 29, 2020
    • Paul Moore's avatar
      revert: 1320a405 ("audit: trigger accompanying records when no rules present") · 8ac68dc4
      Paul Moore authored
      
      Unfortunately the commit listed in the subject line above failed
      to ensure that the task's audit_context was properly initialized/set
      before enabling the "accompanying records".  Depending on the
      situation, the resulting audit_context could have invalid values in
      some of it's fields which could cause a kernel panic/oops when the
      task/syscall exists and the audit records are generated.
      
      We will revisit the original patch, with the necessary fixes, in a
      future kernel but right now we just want to fix the kernel panic
      with the least amount of added risk.
      
      Cc: stable@vger.kernel.org
      Fixes: 1320a405 ("audit: trigger accompanying records when no rules present")
      Reported-by: default avatar <j2468h@googlemail.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      8ac68dc4
  14. Apr 22, 2020
  15. Mar 12, 2020
  16. May 30, 2019
  17. May 22, 2019
  18. Apr 29, 2019
  19. Feb 08, 2019
  20. Feb 03, 2019
  21. Jan 31, 2019
    • Richard Guy Briggs's avatar
      audit: ignore fcaps on umount · 57d46577
      Richard Guy Briggs authored
      Don't fetch fcaps when umount2 is called to avoid a process hang while
      it waits for the missing resource to (possibly never) re-appear.
      
      Note the comment above user_path_mountpoint_at():
       * A umount is a special case for path walking. We're not actually interested
       * in the inode in this situation, and ESTALE errors can be a problem.  We
       * simply want track down the dentry and vfsmount attached at the mountpoint
       * and avoid revalidating the last component.
      
      This can happen on ceph, cifs, 9p, lustre, fuse (gluster) or NFS.
      
      Please see the github issue tracker
      https://github.com/linux-audit/audit-kernel/issues/100
      
      
      
      Signed-off-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      [PM: merge fuzz in audit_log_fcaps()]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      57d46577
  22. Jan 25, 2019
  23. Jan 14, 2019
  24. Nov 26, 2018
  25. Nov 19, 2018
  26. Feb 23, 2018
  27. Nov 10, 2017
  28. Sep 04, 2017
  29. Jun 12, 2017
  30. May 30, 2017
    • Richard Guy Briggs's avatar
      audit: add ambient capabilities to CAPSET and BPRM_FCAPS records · 7786f6b6
      Richard Guy Briggs authored
      Capabilities were augmented to include ambient capabilities in v4.3
      commit 58319057 ("capabilities: ambient capabilities").
      
      Add ambient capabilities to the audit BPRM_FCAPS and CAPSET records.
      
      The record contains fields "old_pp", "old_pi", "old_pe", "new_pp",
      "new_pi", "new_pe" so in keeping with the previous record
      normalizations, change the "new_*" variants to simply drop the "new_"
      prefix.
      
      A sample of the replaced BPRM_FCAPS record:
      RAW: type=BPRM_FCAPS msg=audit(1491468034.252:237): fver=2
      fp=0000000000200000 fi=0000000000000000 fe=1 old_pp=0000000000000000
      old_pi=0000000000000000 old_pe=0000000000000000 old_pa=0000000000000000
      pp=0000000000200000 pi=0000000000000000 pe=0000000000200000
      pa=0000000000000000
      
      INTERPRET: type=BPRM_FCAPS msg=audit(04/06/2017 04:40:34.252:237):
      fver=2 fp=sys_admin fi=none fe=chown old_pp=none old_pi=none
      old_pe=none old_pa=none pp=sys_admin pi=none pe=sys_admin pa=none
      
      A sample of the replaced CAPSET record:
      RAW: type=CAPSET msg=audit(1491469502.371:242): pid=833
      cap_pi=0000003fffffffff cap_pp=0000003fffffffff cap_pe=0000003fffffffff
      cap_pa=0000000000000000
      
      INTERPRET: type=CAPSET msg=audit(04/06/2017 05:05:02.371:242) : pid=833
      cap_pi=chown,dac_override,dac_read_search,fowner,fsetid,kill,
      setgid,setuid,setpcap,linux_immutable,net_bind_service,net_broadcast,
      net_admin,net_raw,ipc_lock,ipc_owner,sys_module,sys_rawio,sys_chroot,
      sys_ptrace,sys_pacct,sys_admin,sys_boot,sys_nice,sys_resource,sys_time,
      sys_tty_config,mknod,lease,audit_write,audit_control,setfcap,
      mac_override,mac_admin,syslog,wake_alarm,block_suspend,audit_read
      cap_pp=chown,dac_override,dac_read_search,fowner,fsetid,kill,setgid,
      setuid,setpcap,linux_immutable,net_bind_service,net_broadcast,
      net_admin,net_raw,ipc_lock,ipc_owner,sys_module,sys_rawio,sys_chroot,
      sys_ptrace,sys_pacct,sys_admin,sys_boot,sys_nice,sys_resource,
      sys_time,sys_tty_config,mknod,lease,audit_write,audit_control,setfcap,
      mac_override,mac_admin,syslog,wake_alarm,block_suspend,audit_read
      cap_pe=chown,dac_override,dac_read_search,fowner,fsetid,kill,setgid,
      setuid,setpcap,linux_immutable,net_bind_service,net_broadcast,
      net_admin,net_raw,ipc_lock,ipc_owner,sys_module,sys_rawio,sys_chroot,
      sys_ptrace,sys_pacct,sys_admin,sys_boot,sys_nice,sys_resource,
      sys_time,sys_tty_config,mknod,lease,audit_write,audit_control,setfcap,
      mac_override,mac_admin,syslog,wake_alarm,block_suspend,audit_read
      cap_pa=none
      
      See: https://github.com/linux-audit/audit-kernel/issues/40
      
      
      
      Signed-off-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Acked-by: default avatarSerge Hallyn <serge@hallyn.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      7786f6b6
  31. May 02, 2017
  32. Mar 27, 2017
  33. Mar 21, 2017
    • Paul Moore's avatar
      audit: fix auditd/kernel connection state tracking · 5b52330b
      Paul Moore authored
      
      What started as a rather straightforward race condition reported by
      Dmitry using the syzkaller fuzzer ended up revealing some major
      problems with how the audit subsystem managed its netlink sockets and
      its connection with the userspace audit daemon.  Fixing this properly
      had quite the cascading effect and what we are left with is this rather
      large and complicated patch.  My initial goal was to try and decompose
      this patch into multiple smaller patches, but the way these changes
      are intertwined makes it difficult to split these changes into
      meaningful pieces that don't break or somehow make things worse for
      the intermediate states.
      
      The patch makes a number of changes, but the most significant are
      highlighted below:
      
      * The auditd tracking variables, e.g. audit_sock, are now gone and
      replaced by a RCU/spin_lock protected variable auditd_conn which is
      a structure containing all of the auditd tracking information.
      
      * We no longer track the auditd sock directly, instead we track it
      via the network namespace in which it resides and we use the audit
      socket associated with that namespace.  In spirit, this is what the
      code was trying to do prior to this patch (at least I think that is
      what the original authors intended), but it was done rather poorly
      and added a layer of obfuscation that only masked the underlying
      problems.
      
      * Big backlog queue cleanup, again.  In v4.10 we made some pretty big
      changes to how the audit backlog queues work, here we haven't changed
      the queue design so much as cleaned up the implementation.  Brought
      about by the locking changes, we've simplified kauditd_thread() quite
      a bit by consolidating the queue handling into a new helper function,
      kauditd_send_queue(), which allows us to eliminate a lot of very
      similar code and makes the looping logic in kauditd_thread() clearer.
      
      * All netlink messages sent to auditd are now sent via
      auditd_send_unicast_skb().  Other than just making sense, this makes
      the lock handling easier.
      
      * Change the audit_log_start() sleep behavior so that we never sleep
      on auditd events (unchanged) or if the caller is holding the
      audit_cmd_mutex (changed).  Previously we didn't sleep if the caller
      was auditd or if the message type fell between a certain range; the
      type check was a poor effort of doing what the cmd_mutex check now
      does.  Richard Guy Briggs originally proposed not sleeping the
      cmd_mutex owner several years ago but his patch wasn't acceptable
      at the time.  At least the idea lives on here.
      
      * A problem with the lost record counter has been resolved.  Steve
      Grubb and I both happened to notice this problem and according to
      some quick testing by Steve, this problem goes back quite some time.
      It's largely a harmless problem, although it may have left some
      careful sysadmins quite puzzled.
      
      Cc: <stable@vger.kernel.org> # 4.10.x-
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      5b52330b
  34. Feb 13, 2017
  35. Dec 06, 2016
Loading