06 Aug, 2018

1 commit

  • commit b305f7ed0f4f494ad6f3ef5667501535d5a8fa31 upstream.

    The variable 'context->module.name' may be null pointer when
    kmalloc return null, so it's better to check it before using
    to avoid null dereference.
    Another one more thing this patch does is using kstrdup instead
    of (kmalloc + strcpy), and signal a lost record via audit_log_lost.

    Cc: stable@vger.kernel.org # 4.11
    Signed-off-by: Yi Wang
    Reviewed-by: Jiang Biao
    Reviewed-by: Richard Guy Briggs
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Yi Wang
     

03 Aug, 2018

1 commit

  • [ Upstream commit 23bcc480dac204c7dbdf49d96b2c918ed98223c2 ]

    Current implementation of auditing by executable name only implements
    the 'equal' operator. This patch extends it to also support the 'not
    equal' operator.

    See: https://github.com/linux-audit/audit-kernel/issues/53

    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Richard Guy Briggs
    Signed-off-by: Paul Moore
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Ondrej Mosnáček
     

15 Sep, 2017

1 commit

  • Pull ipc compat cleanup and 64-bit time_t from Al Viro:
    "IPC copyin/copyout sanitizing, including 64bit time_t work from Deepa
    Dinamani"

    * 'work.ipc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    utimes: Make utimes y2038 safe
    ipc: shm: Make shmid_kernel timestamps y2038 safe
    ipc: sem: Make sem_array timestamps y2038 safe
    ipc: msg: Make msg_queue timestamps y2038 safe
    ipc: mqueue: Replace timespec with timespec64
    ipc: Make sys_semtimedop() y2038 safe
    get rid of SYSVIPC_COMPAT on ia64
    semtimedop(): move compat to native
    shmat(2): move compat to native
    msgrcv(2), msgsnd(2): move compat to native
    ipc(2): move compat to native
    ipc: make use of compat ipc_perm helpers
    semctl(): move compat to native
    semctl(): separate all layout-dependent copyin/copyout
    msgctl(): move compat to native
    msgctl(): split the actual work from copyin/copyout
    ipc: move compat shmctl to native
    shmctl: split the work from copyin/copyout

    Linus Torvalds
     

05 Sep, 2017

2 commits

  • Update the function comments to match the code.

    Signed-off-by: Geliang Tang
    Signed-off-by: Paul Moore

    Geliang Tang
     
  • Commit 2115bb250f26 ("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: Mel Gorman
    Acked-by: Arnd Bergmann
    Acked-by: Deepa Dinamani
    Signed-off-by: Paul Moore

    Mel Gorman
     

04 Sep, 2017

1 commit

  • struct timespec is not y2038 safe. Replace
    all uses of timespec by y2038 safe struct timespec64.

    Even though timespec is used here to represent timeouts,
    replace these with timespec64 so that it facilitates
    in verification by creating a y2038 safe kernel image
    that is free of timespec.

    The syscall interfaces themselves are not changed as part
    of the patch. They will be part of a different series.

    Signed-off-by: Deepa Dinamani
    Cc: Paul Moore
    Cc: Richard Guy Briggs
    Reviewed-by: Richard Guy Briggs
    Reviewed-by: Arnd Bergmann
    Acked-by: Paul Moore
    Signed-off-by: Al Viro

    Deepa Dinamani
     

06 Jul, 2017

1 commit

  • Pull audit updates from Paul Moore:
    "Things are relatively quiet on the audit front for v4.13, just five
    patches for a total diffstat of 102 lines.

    There are two patches from Richard to consistently record the POSIX
    capabilities and add the ambient capability information as well.

    I also chipped in two patches to fix a race condition with the auditd
    tracking code and ensure we don't skip sending any records to the
    audit multicast group.

    Finally a single style fix that I accepted because I must have been in
    a good mood that day.

    Everything passes our test suite, and should be relatively harmless,
    please merge for v4.13"

    * 'stable-4.13' of git://git.infradead.org/users/pcmoore/audit:
    audit: make sure we never skip the multicast broadcast
    audit: fix a race condition with the auditd tracking code
    audit: style fix
    audit: add ambient capabilities to CAPSET and BPRM_FCAPS records
    audit: unswing cap_* fields in PATH records

    Linus Torvalds
     

31 May, 2017

1 commit

  • Capabilities were augmented to include ambient capabilities in v4.3
    commit 58319057b784 ("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: Richard Guy Briggs
    Acked-by: Serge Hallyn
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

04 May, 2017

1 commit

  • Pull fsnotify updates from Jan Kara:
    "The branch contains mainly a rework of fsnotify infrastructure fixing
    a shortcoming that we have waited for response to fanotify permission
    events with SRCU read lock held and when the process consuming events
    was slow to respond the kernel has stalled.

    It also contains several cleanups of unnecessary indirections in
    fsnotify framework and a bugfix from Amir fixing leakage of kernel
    internal errno to userspace"

    * 'fsnotify' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: (37 commits)
    fanotify: don't expose EOPENSTALE to userspace
    fsnotify: remove a stray unlock
    fsnotify: Move ->free_mark callback to fsnotify_ops
    fsnotify: Add group pointer in fsnotify_init_mark()
    fsnotify: Drop inode_mark.c
    fsnotify: Remove fsnotify_find_{inode|vfsmount}_mark()
    fsnotify: Remove fsnotify_detach_group_marks()
    fsnotify: Rename fsnotify_clear_marks_by_group_flags()
    fsnotify: Inline fsnotify_clear_{inode|vfsmount}_mark_group()
    fsnotify: Remove fsnotify_recalc_{inode|vfsmount}_mask()
    fsnotify: Remove fsnotify_set_mark_{,ignored_}mask_locked()
    fanotify: Release SRCU lock when waiting for userspace response
    fsnotify: Pass fsnotify_iter_info into handle_event handler
    fsnotify: Provide framework for dropping SRCU lock in ->handle_event
    fsnotify: Remove special handling of mark destruction on group shutdown
    fsnotify: Detach mark from object list when last reference is dropped
    fsnotify: Move queueing of mark for destruction into fsnotify_put_mark()
    inotify: Do not drop mark reference under idr_lock
    fsnotify: Free fsnotify_mark_connector when there is no mark attached
    fsnotify: Lock object list with connector lock
    ...

    Linus Torvalds
     

02 May, 2017

1 commit

  • struct timespec is not y2038 safe.
    Audit timestamps are recorded in string format into
    an audit buffer for a given context.
    These mark the entry timestamps for the syscalls.
    Use y2038 safe struct timespec64 to represent the times.
    The log strings can handle this transition as strings can
    hold upto 1024 characters.

    Signed-off-by: Deepa Dinamani
    Reviewed-by: Arnd Bergmann
    Acked-by: Paul Moore
    Acked-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Deepa Dinamani
     

10 Apr, 2017

2 commits

  • Currently we free fsnotify_mark_connector structure only when inode /
    vfsmount is getting freed. This can however impose noticeable memory
    overhead when marks get attached to inodes only temporarily. So free the
    connector structure once the last mark is detached from the object.
    Since notification infrastructure can be working with the connector
    under the protection of fsnotify_mark_srcu, we have to be careful and
    free the fsnotify_mark_connector only after SRCU period passes.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Currently notification marks are attached to object (inode or vfsmnt) by
    a hlist_head in the object. The list is also protected by a spinlock in
    the object. So while there is any mark attached to the list of marks,
    the object must be pinned in memory (and thus e.g. last iput() deleting
    inode cannot happen). Also for list iteration in fsnotify() to work, we
    must hold fsnotify_mark_srcu lock so that mark itself and
    mark->obj_list.next cannot get freed. Thus we are required to wait for
    response to fanotify events from userspace process with
    fsnotify_mark_srcu lock held. That causes issues when userspace process
    is buggy and does not reply to some event - basically the whole
    notification subsystem gets eventually stuck.

    So to be able to drop fsnotify_mark_srcu lock while waiting for
    response, we have to pin the mark in memory and make sure it stays in
    the object list (as removing the mark waiting for response could lead to
    lost notification events for groups later in the list). However we don't
    want inode reclaim to block on such mark as that would lead to system
    just locking up elsewhere.

    This commit is the first in the series that paves way towards solving
    these conflicting lifetime needs. Instead of anchoring the list of marks
    directly in the object, we anchor it in a dedicated structure
    (fsnotify_mark_connector) and just point to that structure from the
    object. The following commits will also add spinlock protecting the list
    and object pointer to the structure.

    Reviewed-by: Miklos Szeredi
    Reviewed-by: Amir Goldstein
    Signed-off-by: Jan Kara

    Jan Kara
     

28 Mar, 2017

1 commit

  • Commit 5b52330bbfe6 ("audit: fix auditd/kernel connection state
    tracking") made inlining audit_signal_info() a bit pointless as
    it was always calling into auditd_test_task() so let's remove the
    inline function in kernel/audit.h and convert __audit_signal_info()
    in kernel/auditsc.c into audit_signal_info().

    Reviewed-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Paul Moore
     

21 Mar, 2017

1 commit

  • 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: # 4.10.x-
    Reported-by: Dmitry Vyukov
    Signed-off-by: Paul Moore

    Paul Moore
     

22 Feb, 2017

1 commit

  • Pull audit updates from Paul Moore:
    "The audit changes for v4.11 are relatively small compared to what we
    did for v4.10, both in terms of size and impact.

    - two patches from Steve tweak the formatting for some of the audit
    records to make them more consistent with other audit records.

    - three patches from Richard record the name of a module on module
    load, fix the logging of sockaddr information when using
    socketcall() on 32-bit systems, and add the ability to reset
    audit's lost record counter.

    - my lone patch just fixes an annoying style nit that I was reminded
    about by one of Richard's patches.

    All these patches pass our test suite"

    * 'stable-4.11' of git://git.infradead.org/users/pcmoore/audit:
    audit: remove unnecessary curly braces from switch/case statements
    audit: log module name on init_module
    audit: log 32-bit socketcalls
    audit: add feature audit_lost reset
    audit: Make AUDIT_ANOM_ABEND event normalized
    audit: Make AUDIT_KERNEL event conform to the specification

    Linus Torvalds
     

15 Feb, 2017

1 commit


14 Feb, 2017

1 commit

  • This adds a new auxiliary record MODULE_INIT to the SYSCALL event.

    We get finit_module for free since it made most sense to hook this in to
    load_module().

    https://github.com/linux-audit/audit-kernel/issues/7
    https://github.com/linux-audit/audit-kernel/wiki/RFE-Module-Load-Record-Format

    Signed-off-by: Richard Guy Briggs
    Acked-by: Jessica Yu
    [PM: corrected links in the commit description]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

15 Dec, 2016

2 commits

  • Pull audit updates from Paul Moore:
    "After the small number of patches for v4.9, we've got a much bigger
    pile for v4.10.

    The bulk of these patches involve a rework of the audit backlog queue
    to enable us to move the netlink multicasting out of the task/thread
    that generates the audit record and into the kernel thread that emits
    the record (just like we do for the audit unicast to auditd).

    While we were playing with the backlog queue(s) we fixed a number of
    other little problems with the code, and from all the testing so far
    things look to be in much better shape now. Doing this also allowed us
    to re-enable disabling IRQs for some netns operations ("netns: avoid
    disabling irq for netns id").

    The remaining patches fix some small problems that are well documented
    in the commit descriptions, as well as adding session ID filtering
    support"

    * 'stable-4.10' of git://git.infradead.org/users/pcmoore/audit:
    audit: use proper refcount locking on audit_sock
    netns: avoid disabling irq for netns id
    audit: don't ever sleep on a command record/message
    audit: handle a clean auditd shutdown with grace
    audit: wake up kauditd_thread after auditd registers
    audit: rework audit_log_start()
    audit: rework the audit queue handling
    audit: rename the queues and kauditd related functions
    audit: queue netlink multicast sends just like we do for unicast sends
    audit: fixup audit_init()
    audit: move kaudit thread start from auditd registration to kaudit init (#2)
    audit: add support for session ID user filter
    audit: fix formatting of AUDIT_CONFIG_CHANGE events
    audit: skip sessionid sentinel value when auto-incrementing
    audit: tame initialization warning len_abuf in audit_log_execve_info
    audit: less stack usage for /proc/*/loginuid

    Linus Torvalds
     
  • The audit event specification asks for certain fields to exist in
    all events. Running 'ausearch -m anom_abend -sv yes' returns no
    events. This patch adds the result field so that the
    AUDIT_ANOM_ABEND event conforms to the rules.

    Signed-off-by: Steve Grubb
    Signed-off-by: Paul Moore

    Steve Grubb
     

30 Nov, 2016

1 commit

  • Define AUDIT_SESSIONID in the uapi and add support for specifying user
    filters based on the session ID. Also add the new session ID filter
    to the feature bitmap so userspace knows it is available.

    https://github.com/linux-audit/audit-kernel/issues/4
    RFE: add a session ID filter to the kernel's user filter

    Signed-off-by: Richard Guy Briggs
    [PM: combine multiple patches from Richard into this one]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

21 Nov, 2016

1 commit


15 Nov, 2016

1 commit


05 Oct, 2016

1 commit

  • Pull audit updates from Paul Moore:
    "Another relatively small pull request for v4.9 with just two patches.

    The patch from Richard updates the list of features we support and
    report back to userspace; this should have been sent earlier with the
    rest of the v4.8 patches but it got lost in my inbox.

    The second patch fixes a problem reported by our Android friends where
    we weren't very consistent in recording PIDs"

    * 'stable-4.9' of git://git.infradead.org/users/pcmoore/audit:
    audit: add exclude filter extension to feature bitmap
    audit: consistently record PIDs with task_tgid_nr()

    Linus Torvalds
     

31 Aug, 2016

1 commit

  • Unfortunately we record PIDs in audit records using a variety of
    methods despite the correct way being the use of task_tgid_nr().
    This patch converts all of these callers, except for the case of
    AUDIT_SET in audit_receive_msg() (see the comment in the code).

    Reported-by: Jeff Vander Stoep
    Signed-off-by: Paul Moore

    Paul Moore
     

30 Jul, 2016

1 commit

  • Pull audit updates from Paul Moore:
    "Six audit patches for 4.8.

    There are a couple of style and minor whitespace tweaks for the logs,
    as well as a minor fixup to catch errors on user filter rules, however
    the major improvements are a fix to the s390 syscall argument masking
    code (reviewed by the nice s390 folks), some consolidation around the
    exclude filtering (less code, always a win), and a double-fetch fix
    for recording the execve arguments"

    * 'stable-4.8' of git://git.infradead.org/users/pcmoore/audit:
    audit: fix a double fetch in audit_log_single_execve_arg()
    audit: fix whitespace in CWD record
    audit: add fields to exclude filter by reusing user filter
    s390: ensure that syscall arguments are properly masked on s390
    audit: fix some horrible switch statement style crimes
    audit: fixup: log on errors from filter user rules

    Linus Torvalds
     

21 Jul, 2016

1 commit

  • There is a double fetch problem in audit_log_single_execve_arg()
    where we first check the execve(2) argumnets for any "bad" characters
    which would require hex encoding and then re-fetch the arguments for
    logging in the audit record[1]. Of course this leaves a window of
    opportunity for an unsavory application to munge with the data.

    This patch reworks things by only fetching the argument data once[2]
    into a buffer where it is scanned and logged into the audit
    records(s). In addition to fixing the double fetch, this patch
    improves on the original code in a few other ways: better handling
    of large arguments which require encoding, stricter record length
    checking, and some performance improvements (completely unverified,
    but we got rid of some strlen() calls, that's got to be a good
    thing).

    As part of the development of this patch, I've also created a basic
    regression test for the audit-testsuite, the test can be tracked on
    GitHub at the following link:

    * https://github.com/linux-audit/audit-testsuite/issues/25

    [1] If you pay careful attention, there is actually a triple fetch
    problem due to a strnlen_user() call at the top of the function.

    [2] This is a tiny white lie, we do make a call to strnlen_user()
    prior to fetching the argument data. I don't like it, but due to the
    way the audit record is structured we really have no choice unless we
    copy the entire argument at once (which would require a rather
    wasteful allocation). The good news is that with this patch the
    kernel no longer relies on this strnlen_user() value for anything
    beyond recording it in the log, we also update it with a trustworthy
    value whenever possible.

    Reported-by: Pengfei Wang
    Cc:
    Signed-off-by: Paul Moore

    Paul Moore
     

15 Jul, 2016

1 commit


30 Jun, 2016

1 commit

  • Pull audit fixes from Paul Moore:
    "Two small patches to fix audit problems in 4.7-rcX: the first fixes a
    potential kref leak, the second removes some header file noise.

    The first is an important bug fix that really should go in before 4.7
    is released, the second is not critical, but falls into the very-nice-
    to-have category so I'm including in the pull request.

    Both patches are straightforward, self-contained, and pass our
    testsuite without problem"

    * 'stable-4.7' of git://git.infradead.org/users/pcmoore/audit:
    audit: move audit_get_tty to reduce scope and kabi changes
    audit: move calcs after alloc and check when logging set loginuid

    Linus Torvalds
     

29 Jun, 2016

2 commits


17 Jun, 2016

1 commit


19 May, 2016

1 commit

  • Pull audit updates from Paul Moore:
    "Four small audit patches for 4.7.

    Two are simple cleanups around the audit thread management code, one
    adds a tty field to AUDIT_LOGIN events, and the final patch makes
    tty_name() usable regardless of CONFIG_TTY.

    Nothing controversial, and it all passes our regression test"

    * 'stable-4.7' of git://git.infradead.org/users/pcmoore/audit:
    tty: provide tty_name() even without CONFIG_TTY
    audit: add tty field to LOGIN event
    audit: we don't need to __set_current_state(TASK_RUNNING)
    audit: cleanup prune_tree_thread

    Linus Torvalds
     

27 Apr, 2016

1 commit

  • The tty field was missing from AUDIT_LOGIN events.

    Refactor code to create a new function audit_get_tty(), using it to
    replace the call in audit_log_task_info() and to add it to
    audit_log_set_loginuid(). Lock and bump the kref to protect it, adding
    audit_put_tty() alias to decrement it.

    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

23 Mar, 2016

1 commit


25 Dec, 2015

1 commit


09 Sep, 2015

1 commit

  • Pull audit update from Paul Moore:
    "This is one of the larger audit patchsets in recent history,
    consisting of eight patches and almost 400 lines of changes.

    The bulk of the patchset is the new "audit by executable"
    functionality which allows admins to set an audit watch based on the
    executable on disk. Prior to this, admins could only track an
    application by PID, which has some obvious limitations.

    Beyond the new functionality we also have some refcnt fixes and a few
    minor cleanups"

    * 'upstream' of git://git.infradead.org/users/pcmoore/audit:
    fixup: audit: implement audit by executable
    audit: implement audit by executable
    audit: clean simple fsnotify implementation
    audit: use macros for unset inode and device values
    audit: make audit_del_rule() more robust
    audit: fix uninitialized variable in audit_add_rule()
    audit: eliminate unnecessary extra layer of watch parent references
    audit: eliminate unnecessary extra layer of watch references

    Linus Torvalds
     

07 Aug, 2015

2 commits

  • This adds the ability audit the actions of a not-yet-running process.

    This patch implements the ability to filter on the executable path. Instead of
    just hard coding the ino and dev of the executable we care about at the moment
    the rule is inserted into the kernel, use the new audit_fsnotify
    infrastructure to manage this dynamically. This means that if the filename
    does not yet exist but the containing directory does, or if the inode in
    question is unlinked and creat'd (aka updated) the rule will just continue to
    work. If the containing directory is moved or deleted or the filesystem is
    unmounted, the rule is deleted automatically. A future enhancement would be to
    have the rule survive across directory disruptions.

    This is a heavily modified version of a patch originally submitted by Eric
    Paris with some ideas from Peter Moody.

    Cc: Peter Moody
    Cc: Eric Paris
    Signed-off-by: Richard Guy Briggs
    [PM: minor whitespace clean to satisfy ./scripts/checkpatch]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     
  • Clean up a number of places were casted magic numbers are used to represent
    unset inode and device numbers in preparation for the audit by executable path
    patch set.

    Signed-off-by: Richard Guy Briggs
    [PM: enclosed the _UNSET macros in parentheses for ./scripts/checkpatch]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

09 Jul, 2015

1 commit

  • The "fix" in commit 0b08c5e5944 ("audit: Fix check of return value of
    strnlen_user()") didn't fix anything, it broke things. As reported by
    Steven Rostedt:

    "Yes, strnlen_user() returns 0 on fault, but if you look at what len is
    set to, than you would notice that on fault len would be -1"

    because we just subtracted one from the return value. So testing
    against 0 doesn't test for a fault condition, it tests against a
    perfectly valid empty string.

    Also fix up the usual braindamage wrt using WARN_ON() inside a
    conditional - make it part of the conditional and remove the explicit
    unlikely() (which is already part of the WARN_ON*() logic, exactly so
    that you don't have to write unreadable code.

    Reported-and-tested-by: Steven Rostedt
    Cc: Jan Kara
    Cc: Paul Moore
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

28 Jun, 2015

1 commit

  • Pull audit updates from Paul Moore:
    "Four small audit patches for v4.2, all bug fixes. Only 10 lines of
    change this time so very unremarkable, the patch subject lines pretty
    much tell the whole story"

    * 'upstream' of git://git.infradead.org/users/pcmoore/audit:
    audit: Fix check of return value of strnlen_user()
    audit: obsolete audit_context check is removed in audit_filter_rules()
    audit: fix for typo in comment to function audit_log_link_denied()
    lsm: rename duplicate labels in LSM_AUDIT_DATA_TASK audit message type

    Linus Torvalds