1. 29 4月, 2019 1 次提交
  2. 16 4月, 2019 2 次提交
    • O
      ntp: Audit NTP parameters adjustment · 7e8eda73
      Ondrej Mosnacek 提交于
      Emit an audit record every time selected NTP parameters are modified
      from userspace (via adjtimex(2) or clock_adjtime(2)). These parameters
      may be used to indirectly change system clock, and thus their
      modifications should be audited.
      
      Such events will now generate records of type AUDIT_TIME_ADJNTPVAL
      containing the following fields:
        - op -- which value was adjusted:
          - offset -- corresponding to the time_offset variable
          - freq   -- corresponding to the time_freq variable
          - status -- corresponding to the time_status variable
          - adjust -- corresponding to the time_adjust variable
          - tick   -- corresponding to the tick_usec variable
          - tai    -- corresponding to the timekeeping's TAI offset
        - old -- the old value
        - new -- the new value
      
      Example records:
      
      type=TIME_ADJNTPVAL msg=audit(1530616044.507:7): op=status old=64 new=8256
      type=TIME_ADJNTPVAL msg=audit(1530616044.511:11): op=freq old=0 new=49180377088000
      
      The records of this type will be associated with the corresponding
      syscall records.
      
      An overview of parameter changes that can be done via do_adjtimex()
      (based on information from Miroslav Lichvar) and whether they are
      audited:
        __timekeeping_set_tai_offset() -- sets the offset from the
                                          International Atomic Time
                                          (AUDITED)
        NTP variables:
          time_offset -- can adjust the clock by up to 0.5 seconds per call
                         and also speed it up or slow down by up to about
                         0.05% (43 seconds per day) (AUDITED)
          time_freq -- can speed up or slow down by up to about 0.05%
                       (AUDITED)
          time_status -- can insert/delete leap seconds and it also enables/
                         disables synchronization of the hardware real-time
                         clock (AUDITED)
          time_maxerror, time_esterror -- change error estimates used to
                                          inform userspace applications
                                          (NOT AUDITED)
          time_constant -- controls the speed of the clock adjustments that
                           are made when time_offset is set (NOT AUDITED)
          time_adjust -- can temporarily speed up or slow down the clock by up
                         to 0.05% (AUDITED)
          tick_usec -- a more extreme version of time_freq; can speed up or
                       slow down the clock by up to 10% (AUDITED)
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Reviewed-by: NRichard Guy Briggs <rgb@redhat.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      7e8eda73
    • O
      timekeeping: Audit clock adjustments · 2d87a067
      Ondrej Mosnacek 提交于
      Emit an audit record whenever the system clock is changed (i.e. shifted
      by a non-zero offset) by a syscall from userspace. The syscalls than can
      (at the time of writing) trigger such record are:
        - settimeofday(2), stime(2), clock_settime(2) -- via
          do_settimeofday64()
        - adjtimex(2), clock_adjtime(2) -- via do_adjtimex()
      
      The new records have type AUDIT_TIME_INJOFFSET and contain the following
      fields:
        - sec -- the 'seconds' part of the offset
        - nsec -- the 'nanoseconds' part of the offset
      
      Example record (time was shifted backwards by ~15.875 seconds):
      
      type=TIME_INJOFFSET msg=audit(1530616049.652:13): sec=-16 nsec=124887145
      
      The records of this type will be associated with the corresponding
      syscall records.
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Reviewed-by: NRichard Guy Briggs <rgb@redhat.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      [PM: fixed a line width problem in __audit_tk_injoffset()]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      2d87a067
  3. 09 4月, 2019 1 次提交
  4. 21 3月, 2019 2 次提交
    • D
      syscall_get_arch: add "struct task_struct *" argument · 16add411
      Dmitry V. Levin 提交于
      This argument is required to extend the generic ptrace API with
      PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going
      to be called from ptrace_request() along with syscall_get_nr(),
      syscall_get_arguments(), syscall_get_error(), and
      syscall_get_return_value() functions with a tracee as their argument.
      
      The primary intent is that the triple (audit_arch, syscall_nr, arg1..arg6)
      should describe what system call is being called and what its arguments
      are.
      
      Reverts: 5e937a9a ("syscall_get_arch: remove useless function arguments")
      Reverts: 1002d94d ("syscall.h: fix doc text for syscall_get_arch()")
      Reviewed-by: Andy Lutomirski <luto@kernel.org> # for x86
      Reviewed-by: NPalmer Dabbelt <palmer@sifive.com>
      Acked-by: NPaul Moore <paul@paul-moore.com>
      Acked-by: Paul Burton <paul.burton@mips.com> # MIPS parts
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Acked-by: Kees Cook <keescook@chromium.org> # seccomp parts
      Acked-by: Mark Salter <msalter@redhat.com> # for the c6x bit
      Cc: Elvira Khabirova <lineprinter@altlinux.org>
      Cc: Eugene Syromyatnikov <esyr@redhat.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: x86@kernel.org
      Cc: linux-alpha@vger.kernel.org
      Cc: linux-snps-arc@lists.infradead.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-c6x-dev@linux-c6x.org
      Cc: uclinux-h8-devel@lists.sourceforge.jp
      Cc: linux-hexagon@vger.kernel.org
      Cc: linux-ia64@vger.kernel.org
      Cc: linux-m68k@lists.linux-m68k.org
      Cc: linux-mips@vger.kernel.org
      Cc: nios2-dev@lists.rocketboards.org
      Cc: openrisc@lists.librecores.org
      Cc: linux-parisc@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: linux-riscv@lists.infradead.org
      Cc: linux-s390@vger.kernel.org
      Cc: linux-sh@vger.kernel.org
      Cc: sparclinux@vger.kernel.org
      Cc: linux-um@lists.infradead.org
      Cc: linux-xtensa@linux-xtensa.org
      Cc: linux-arch@vger.kernel.org
      Cc: linux-audit@redhat.com
      Signed-off-by: NDmitry V. Levin <ldv@altlinux.org>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      16add411
    • Y
      audit: Make audit_log_cap and audit_copy_inode static · 2efa48fe
      YueHaibing 提交于
      Fix sparse warning:
      
      kernel/auditsc.c:1150:6: warning: symbol 'audit_log_cap' was not declared. Should it be static?
      kernel/auditsc.c:1908:6: warning: symbol 'audit_copy_inode' was not declared. Should it be static?
      Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
      Acked-by: NRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      2efa48fe
  5. 19 3月, 2019 1 次提交
    • L
      audit: fix a memleak caused by auditing load module · 95e0b46f
      Li RongQing 提交于
      module.name will be allocated unconditionally when auditing load
      module, and audit_log_start() can fail with other reasons, or
      audit_log_exit maybe not called, caused module.name is not freed
      
      so free module.name in audit_free_context and __audit_syscall_exit
      
      unreferenced object 0xffff88af90837d20 (size 8):
        comm "modprobe", pid 1036, jiffies 4294704867 (age 3069.138s)
        hex dump (first 8 bytes):
          69 78 67 62 65 00 ff ff                          ixgbe...
        backtrace:
          [<0000000008da28fe>] __audit_log_kern_module+0x33/0x80
          [<00000000c1491e61>] load_module+0x64f/0x3850
          [<000000007fc9ae3f>] __do_sys_init_module+0x218/0x250
          [<0000000000d4a478>] do_syscall_64+0x117/0x400
          [<000000004924ded8>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
          [<000000007dc331dd>] 0xffffffffffffffff
      
      Fixes: ca86cad7 ("audit: log module name on init_module")
      Signed-off-by: NZhang Yu <zhangyu31@baidu.com>
      Signed-off-by: NLi RongQing <lirongqing@baidu.com>
      [PM: manual merge fixup in __audit_syscall_exit()]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      95e0b46f
  6. 04 2月, 2019 1 次提交
  7. 01 2月, 2019 1 次提交
  8. 31 1月, 2019 1 次提交
    • R
      audit: ignore fcaps on umount · 57d46577
      Richard Guy Briggs 提交于
      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/100Signed-off-by: NRichard Guy Briggs <rgb@redhat.com>
      [PM: merge fuzz in audit_log_fcaps()]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      57d46577
  9. 26 1月, 2019 3 次提交
  10. 15 1月, 2019 1 次提交
  11. 27 11月, 2018 2 次提交
  12. 20 11月, 2018 1 次提交
  13. 06 11月, 2018 1 次提交
    • R
      audit: print empty EXECVE args · ea956d8b
      Richard Guy Briggs 提交于
      Empty executable arguments were being skipped when printing out the list
      of arguments in an EXECVE record, making it appear they were somehow
      lost.  Include empty arguments as an itemized empty string.
      
      Reproducer:
      	autrace /bin/ls "" "/etc"
      	ausearch --start recent -m execve -i | grep EXECVE
      	type=EXECVE msg=audit(10/03/2018 13:04:03.208:1391) : argc=3 a0=/bin/ls a2=/etc
      
      With fix:
      	type=EXECVE msg=audit(10/03/2018 21:51:38.290:194) : argc=3 a0=/bin/ls a1= a2=/etc
      	type=EXECVE msg=audit(1538617898.290:194): argc=3 a0="/bin/ls" a1="" a2="/etc"
      
      Passes audit-testsuite.  GH issue tracker at
      https://github.com/linux-audit/audit-kernel/issues/99Signed-off-by: NRichard Guy Briggs <rgb@redhat.com>
      [PM: cleaned up the commit metadata]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      ea956d8b
  14. 31 7月, 2018 1 次提交
  15. 18 7月, 2018 1 次提交
  16. 03 7月, 2018 1 次提交
  17. 19 6月, 2018 3 次提交
  18. 22 5月, 2018 1 次提交
  19. 18 5月, 2018 2 次提交
  20. 15 5月, 2018 3 次提交
  21. 08 5月, 2018 2 次提交
    • T
      seccomp: Don't special case audited processes when logging · 326bee02
      Tyler Hicks 提交于
      Seccomp logging for "handled" actions such as RET_TRAP, RET_TRACE, or
      RET_ERRNO can be very noisy for processes that are being audited. This
      patch modifies the seccomp logging behavior to treat processes that are
      being inspected via the audit subsystem the same as processes that
      aren't under inspection. Handled actions will no longer be logged just
      because the process is being inspected. Since v4.14, applications have
      the ability to request logging of handled actions by using the
      SECCOMP_FILTER_FLAG_LOG flag when loading seccomp filters.
      
      With this patch, the logic for deciding if an action will be logged is:
      
        if action == RET_ALLOW:
          do not log
        else if action not in actions_logged:
          do not log
        else if action == RET_KILL:
          log
        else if action == RET_LOG:
          log
        else if filter-requests-logging:
          log
        else:
          do not log
      Reported-by: NSteve Grubb <sgrubb@redhat.com>
      Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      326bee02
    • T
      seccomp: Audit attempts to modify the actions_logged sysctl · ea6eca77
      Tyler Hicks 提交于
      The decision to log a seccomp action will always be subject to the
      value of the kernel.seccomp.actions_logged sysctl, even for processes
      that are being inspected via the audit subsystem, in an upcoming patch.
      Therefore, we need to emit an audit record on attempts at writing to the
      actions_logged sysctl when auditing is enabled.
      
      This patch updates the write handler for the actions_logged sysctl to
      emit an audit record on attempts to write to the sysctl. Successful
      writes to the sysctl will result in a record that includes a normalized
      list of logged actions in the "actions" field and a "res" field equal to
      1. Unsuccessful writes to the sysctl will result in a record that
      doesn't include the "actions" field and has a "res" field equal to 0.
      
      Not all unsuccessful writes to the sysctl are audited. For example, an
      audit record will not be emitted if an unprivileged process attempts to
      open the sysctl file for reading since that access control check is not
      part of the sysctl's write handler.
      
      Below are some example audit records when writing various strings to the
      actions_logged sysctl.
      
      Writing "not-a-real-action", when the kernel.seccomp.actions_logged
      sysctl previously was "kill_process kill_thread trap errno trace log",
      emits this audit record:
      
       type=CONFIG_CHANGE msg=audit(1525392371.454:120): op=seccomp-logging
       actions=? old-actions=kill_process,kill_thread,trap,errno,trace,log
       res=0
      
      If you then write "kill_process kill_thread errno trace log", this audit
      record is emitted:
      
       type=CONFIG_CHANGE msg=audit(1525392401.645:126): op=seccomp-logging
       actions=kill_process,kill_thread,errno,trace,log
       old-actions=kill_process,kill_thread,trap,errno,trace,log res=1
      
      If you then write "log log errno trace kill_process kill_thread", which
      is unordered and contains the log action twice, it results in the same
      actions value as the previous record:
      
       type=CONFIG_CHANGE msg=audit(1525392436.354:132): op=seccomp-logging
       actions=kill_process,kill_thread,errno,trace,log
       old-actions=kill_process,kill_thread,errno,trace,log res=1
      
      If you then write an empty string to the sysctl, this audit record is
      emitted:
      
       type=CONFIG_CHANGE msg=audit(1525392494.413:138): op=seccomp-logging
       actions=(none) old-actions=kill_process,kill_thread,errno,trace,log
       res=1
      
      No audit records are generated when reading the actions_logged sysctl.
      Suggested-by: NSteve Grubb <sgrubb@redhat.com>
      Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      ea6eca77
  22. 24 4月, 2018 1 次提交
  23. 16 2月, 2018 2 次提交
  24. 11 11月, 2017 1 次提交
  25. 10 10月, 2017 1 次提交
    • S
      audit: Record fanotify access control decisions · de8cd83e
      Steve Grubb 提交于
      The fanotify interface allows user space daemons to make access
      control decisions. Under common criteria requirements, we need to
      optionally record decisions based on policy. This patch adds a bit mask,
      FAN_AUDIT, that a user space daemon can 'or' into the response decision
      which will tell the kernel that it made a decision and record it.
      
      It would be used something like this in user space code:
      
        response.response = FAN_DENY | FAN_AUDIT;
        write(fd, &response, sizeof(struct fanotify_response));
      
      When the syscall ends, the audit system will record the decision as a
      AUDIT_FANOTIFY auxiliary record to denote that the reason this event
      occurred is the result of an access control decision from fanotify
      rather than DAC or MAC policy.
      
      A sample event looks like this:
      
      type=PATH msg=audit(1504310584.332:290): item=0 name="./evil-ls"
      inode=1319561 dev=fc:03 mode=0100755 ouid=1000 ogid=1000 rdev=00:00
      obj=unconfined_u:object_r:user_home_t:s0 nametype=NORMAL
      type=CWD msg=audit(1504310584.332:290): cwd="/home/sgrubb"
      type=SYSCALL msg=audit(1504310584.332:290): arch=c000003e syscall=2
      success=no exit=-1 a0=32cb3fca90 a1=0 a2=43 a3=8 items=1 ppid=901
      pid=959 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000
      fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts1 ses=3 comm="bash"
      exe="/usr/bin/bash" subj=unconfined_u:unconfined_r:unconfined_t:
      s0-s0:c0.c1023 key=(null)
      type=FANOTIFY msg=audit(1504310584.332:290): resp=2
      
      Prior to using the audit flag, the developer needs to call
      fanotify_init or'ing in FAN_ENABLE_AUDIT to ensure that the kernel
      supports auditing. The calling process must also have the CAP_AUDIT_WRITE
      capability.
      Signed-off-by: Nsgrubb <sgrubb@redhat.com>
      Reviewed-by: NAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      de8cd83e
  26. 05 9月, 2017 2 次提交
    • G
      audit: update the function comments · 196a5085
      Geliang Tang 提交于
      Update the function comments to match the code.
      Signed-off-by: NGeliang Tang <geliangtang@gmail.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      196a5085
    • M
      audit: Reduce overhead using a coarse clock · e832bf48
      Mel Gorman 提交于
      Commit 2115bb25 ("audit: Use timespec64 to represent audit timestamps")
      noted that audit timestamps were not y2038 safe and used a 64-bit
      timestamp. In itself, this makes sense but the conversion was from
      CURRENT_TIME to ktime_get_real_ts64() which is a heavier call to record
      an accurate timestamp which is required in some, but not all, cases. The
      impact is that when auditd is running without any rules that all syscalls
      have higher overhead. This is visible in the sysbench-thread benchmark as
      a 11.5% performance hit. That benchmark is dumb as rocks but it's also
      visible in redis as an 8-10% hit on all operations which is of greater
      concern. It is somewhat stupid of audit to track syscalls without any
      rules related to syscalls but that is how it behaves.
      
      The overhead can be directly measured with perf comparing 4.9 with 4.12
      
      4.9
           7.76%  sysbench         [kernel.vmlinux]    [k] __schedule
           7.62%  sysbench         [kernel.vmlinux]    [k] _raw_spin_lock
           7.37%  sysbench         libpthread-2.22.so  [.] __lll_lock_elision
           7.29%  sysbench         [kernel.vmlinux]    [.] syscall_return_via_sysret
           6.59%  sysbench         [kernel.vmlinux]    [k] native_sched_clock
           5.21%  sysbench         libc-2.22.so        [.] __sched_yield
           4.38%  sysbench         [kernel.vmlinux]    [k] entry_SYSCALL_64
           4.28%  sysbench         [kernel.vmlinux]    [k] do_syscall_64
           3.49%  sysbench         libpthread-2.22.so  [.] __lll_unlock_elision
           3.13%  sysbench         [kernel.vmlinux]    [k] __audit_syscall_exit
           2.87%  sysbench         [kernel.vmlinux]    [k] update_curr
           2.73%  sysbench         [kernel.vmlinux]    [k] pick_next_task_fair
           2.31%  sysbench         [kernel.vmlinux]    [k] syscall_trace_enter
           2.20%  sysbench         [kernel.vmlinux]    [k] __audit_syscall_entry
      .....
           0.00%  swapper          [kernel.vmlinux]    [k] read_tsc
      
      4.12
           7.84%  sysbench         [kernel.vmlinux]    [k] __schedule
           7.05%  sysbench         [kernel.vmlinux]    [k] _raw_spin_lock
           6.57%  sysbench         libpthread-2.22.so  [.] __lll_lock_elision
           6.50%  sysbench         [kernel.vmlinux]    [.] syscall_return_via_sysret
           5.95%  sysbench         [kernel.vmlinux]    [k] read_tsc
           5.71%  sysbench         [kernel.vmlinux]    [k] native_sched_clock
           4.78%  sysbench         libc-2.22.so        [.] __sched_yield
           4.30%  sysbench         [kernel.vmlinux]    [k] entry_SYSCALL_64
           3.94%  sysbench         [kernel.vmlinux]    [k] do_syscall_64
           3.37%  sysbench         libpthread-2.22.so  [.] __lll_unlock_elision
           3.32%  sysbench         [kernel.vmlinux]    [k] __audit_syscall_exit
           2.91%  sysbench         [kernel.vmlinux]    [k] __getnstimeofday64
      
      Note the additional overhead from read_tsc which goes from 0% to 5.95%.
      This is on a single-socket E3-1230 but similar overheads have been measured
      on an older machine which the patch also eliminates.
      
      The patch in question has no explanation as to why a fully-accurate timestamp
      is required and is likely an oversight.  Using a coarser, but monotically
      increasing, timestamp the overhead can be eliminated.  While it can be
      worked around by configuring or disabling audit, it's tricky enough to
      detect that a kernel fix is justified. With this patch, we see the following;
      
      sysbenchthread
                                    4.9.0                 4.12.0                 4.12.0
                                  vanilla                vanilla            coarse-v1r1
      Amean     1         1.49 (   0.00%)        1.66 ( -11.42%)        1.51 (  -1.34%)
      Amean     3         1.48 (   0.00%)        1.65 ( -11.45%)        1.50 (  -0.96%)
      Amean     5         1.49 (   0.00%)        1.67 ( -12.31%)        1.51 (  -1.83%)
      Amean     7         1.49 (   0.00%)        1.66 ( -11.72%)        1.50 (  -0.67%)
      Amean     12        1.48 (   0.00%)        1.65 ( -11.57%)        1.52 (  -2.89%)
      Amean     16        1.49 (   0.00%)        1.65 ( -11.13%)        1.51 (  -1.73%)
      
      The benchmark is reporting the time required for different thread counts to
      lock/unlock a private mutex which, while dense, demonstrates the syscall
      overhead. This is showing that 4.12 took a 11-12% hit but the overhead is
      almost eliminated by the patch. While the variance is not reported here,
      it's well within the noise with the patch applied.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NDeepa Dinamani <deepa.kernel@gmail.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      e832bf48
  27. 04 9月, 2017 1 次提交