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
     

12 Jun, 2015

1 commit


30 May, 2015

1 commit


27 Apr, 2015

1 commit

  • Pull fourth vfs update from Al Viro:
    "d_inode() annotations from David Howells (sat in for-next since before
    the beginning of merge window) + four assorted fixes"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    RCU pathwalk breakage when running into a symlink overmounting something
    fix I_DIO_WAKEUP definition
    direct-io: only inc/dec inode->i_dio_count for file systems
    fs/9p: fix readdir()
    VFS: assorted d_backing_inode() annotations
    VFS: fs/inode.c helpers: d_inode() annotations
    VFS: fs/cachefiles: d_backing_inode() annotations
    VFS: fs library helpers: d_inode() annotations
    VFS: assorted weird filesystems: d_inode() annotations
    VFS: normal filesystems (and lustre): d_inode() annotations
    VFS: security/: d_inode() annotations
    VFS: security/: d_backing_inode() annotations
    VFS: net/: d_inode() annotations
    VFS: net/unix: d_backing_inode() annotations
    VFS: kernel/: d_inode() annotations
    VFS: audit: d_backing_inode() annotations
    VFS: Fix up some ->d_inode accesses in the chelsio driver
    VFS: Cachefiles should perform fs modifications on the top layer only
    VFS: AF_UNIX sockets should call mknod on the top layer only

    Linus Torvalds
     

23 Apr, 2015

1 commit

  • Pull audit fixes from Paul Moore:
    "Seven audit patches for v4.1, all bug fixes.

    The largest, and perhaps most significant commit helps resolve some
    memory pressure issues related to the inode cache and audit, there are
    also a few small commits which help resolve some timing issues with
    the audit log queue, and the rest fall into the always popular "code
    clean-up" category.

    In general, nothing really substantial, just a nice set of maintenance
    patches"

    * 'upstream' of git://git.infradead.org/users/pcmoore/audit:
    audit: Remove condition which always evaluates to false
    audit: reduce mmap_sem hold for mm->exe_file
    audit: consolidate handling of mm->exe_file
    audit: code clean up
    audit: don't reset working wait time accidentally with auditd
    audit: don't lose set wait time on first successful call to audit_log_start()
    audit: move the tree pruning to a dedicated thread

    Linus Torvalds
     

16 Apr, 2015

1 commit


24 Feb, 2015

1 commit


18 Feb, 2015

1 commit

  • Pull getname/putname updates from Al Viro:
    "Rework of getname/getname_kernel/etc., mostly from Paul Moore. Gets
    rid of quite a pile of kludges between namei and audit..."

    * 'getname2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    audit: replace getname()/putname() hacks with reference counters
    audit: fix filename matching in __audit_inode() and __audit_inode_child()
    audit: enable filename recording via getname_kernel()
    simpler calling conventions for filename_mountpoint()
    fs: create proper filename objects using getname_kernel()
    fs: rework getname_kernel to handle up to PATH_MAX sized filenames
    cut down the number of do_path_lookup() callers

    Linus Torvalds
     

26 Jan, 2015

1 commit


23 Jan, 2015

3 commits

  • In order to ensure that filenames are not released before the audit
    subsystem is done with the strings there are a number of hacks built
    into the fs and audit subsystems around getname() and putname(). To
    say these hacks are "ugly" would be kind.

    This patch removes the filename hackery in favor of a more
    conventional reference count based approach. The diffstat below tells
    most of the story; lots of audit/fs specific code is replaced with a
    traditional reference count based approach that is easily understood,
    even by those not familiar with the audit and/or fs subsystems.

    CC: viro@zeniv.linux.org.uk
    CC: linux-fsdevel@vger.kernel.org
    Signed-off-by: Paul Moore
    Signed-off-by: Al Viro

    Paul Moore
     
  • In all likelihood there were some subtle, and perhaps not so subtle,
    bugs with filename matching in audit_inode() and audit_inode_child()
    for some time, however, recent changes to the audit filename code have
    definitely broken the filename matching code. The breakage could
    result in duplicate filenames in the audit log and other odd audit
    record entries. This patch fixes the filename matching code and
    restores some sanity to the filename audit records.

    CC: viro@zeniv.linux.org.uk
    CC: linux-fsdevel@vger.kernel.org
    Signed-off-by: Paul Moore
    Signed-off-by: Al Viro

    Paul Moore
     
  • Enable recording of filenames in getname_kernel() and remove the
    kludgy workaround in __audit_inode() now that we have proper filename
    logging for kernel users.

    CC: viro@zeniv.linux.org.uk
    CC: linux-fsdevel@vger.kernel.org
    Signed-off-by: Paul Moore
    Reviewed-by: Richard Guy Briggs
    Signed-off-by: Al Viro

    Paul Moore
     

01 Jan, 2015

1 commit

  • Pull audit fix from Paul Moore:
    "One audit patch to resolve a panic/oops when recording filenames in
    the audit log, see the mail archive link below.

    The fix isn't as nice as I would like, as it involves an allocate/copy
    of the filename, but it solves the problem and the overhead should
    only affect users who have configured audit rules involving file
    names.

    We'll revisit this issue with future kernels in an attempt to make
    this suck less, but in the meantime I think this fix should go into
    the next release of v3.19-rcX.

    [ https://marc.info/?t=141986927600001&r=1&w=2 ]"

    * 'upstream' of git://git.infradead.org/users/pcmoore/audit:
    audit: create private file name copies when auditing inodes

    Linus Torvalds
     

30 Dec, 2014

1 commit

  • Unfortunately, while commit 4a928436 ("audit: correctly record file
    names with different path name types") fixed a problem where we were
    not recording filenames, it created a new problem by attempting to use
    these file names after they had been freed. This patch resolves the
    issue by creating a copy of the filename which the audit subsystem
    frees after it is done with the string.

    At some point it would be nice to resolve this issue with refcounts,
    or something similar, instead of having to allocate/copy strings, but
    that is almost surely beyond the scope of a -rcX patch so we'll defer
    that for later. On the plus side, only audit users should be impacted
    by the string copying.

    Reported-by: Toralf Foerster
    Signed-off-by: Paul Moore

    Paul Moore
     

24 Dec, 2014

1 commit

  • Pull audit fixes from Paul Moore:
    "Four patches to fix various problems with the audit subsystem, all are
    fairly small and straightforward.

    One patch fixes a problem where we weren't using the correct gfp
    allocation flags (GFP_KERNEL regardless of context, oops), one patch
    fixes a problem with old userspace tools (this was broken for a
    while), one patch fixes a problem where we weren't recording pathnames
    correctly, and one fixes a problem with PID based filters.

    In general I don't think there is anything controversial with this
    patchset, and it fixes some rather unfortunate bugs; the allocation
    flag one can be particularly scary looking for users"

    * 'upstream' of git://git.infradead.org/users/pcmoore/audit:
    audit: restore AUDIT_LOGINUID unset ABI
    audit: correctly record file names with different path name types
    audit: use supplied gfp_mask from audit_buffer in kauditd_send_multicast_skb
    audit: don't attempt to lookup PIDs when changing PID filtering audit rules

    Linus Torvalds
     

23 Dec, 2014

1 commit

  • There is a problem with the audit system when multiple audit records
    are created for the same path, each with a different path name type.
    The root cause of the problem is in __audit_inode() when an exact
    match (both the path name and path name type) is not found for a
    path name record; the existing code creates a new path name record,
    but it never sets the path name in this record, leaving it NULL.
    This patch corrects this problem by assigning the path name to these
    newly created records.

    There are many ways to reproduce this problem, but one of the
    easiest is the following (assuming auditd is running):

    # mkdir /root/tmp/test
    # touch /root/tmp/test/567
    # auditctl -a always,exit -F dir=/root/tmp/test
    # touch /root/tmp/test/567

    Afterwards, or while the commands above are running, check the audit
    log and pay special attention to the PATH records. A faulty kernel
    will display something like the following for the file creation:

    type=SYSCALL msg=audit(1416957442.025:93): arch=c000003e syscall=2
    success=yes exit=3 ... comm="touch" exe="/usr/bin/touch"
    type=CWD msg=audit(1416957442.025:93): cwd="/root/tmp"
    type=PATH msg=audit(1416957442.025:93): item=0 name="test/"
    inode=401409 ... nametype=PARENT
    type=PATH msg=audit(1416957442.025:93): item=1 name=(null)
    inode=393804 ... nametype=NORMAL
    type=PATH msg=audit(1416957442.025:93): item=2 name=(null)
    inode=393804 ... nametype=NORMAL

    While a patched kernel will show the following:

    type=SYSCALL msg=audit(1416955786.566:89): arch=c000003e syscall=2
    success=yes exit=3 ... comm="touch" exe="/usr/bin/touch"
    type=CWD msg=audit(1416955786.566:89): cwd="/root/tmp"
    type=PATH msg=audit(1416955786.566:89): item=0 name="test/"
    inode=401409 ... nametype=PARENT
    type=PATH msg=audit(1416955786.566:89): item=1 name="test/567"
    inode=393804 ... nametype=NORMAL

    This issue was brought up by a number of people, but special credit
    should go to hujianyang@huawei.com for reporting the problem along
    with an explanation of the problem and a patch. While the original
    patch did have some problems (see the archive link below), it did
    demonstrate the problem and helped kickstart the fix presented here.

    * https://lkml.org/lkml/2014/9/5/66

    Reported-by: hujianyang
    Signed-off-by: Paul Moore
    Acked-by: Richard Guy Briggs

    Paul Moore
     

20 Nov, 2014

2 commits


20 Oct, 2014

1 commit

  • Pull audit updates from Eric Paris:
    "So this change across a whole bunch of arches really solves one basic
    problem. We want to audit when seccomp is killing a process. seccomp
    hooks in before the audit syscall entry code. audit_syscall_entry
    took as an argument the arch of the given syscall. Since the arch is
    part of what makes a syscall number meaningful it's an important part
    of the record, but it isn't available when seccomp shoots the
    syscall...

    For most arch's we have a better way to get the arch (syscall_get_arch)
    So the solution was two fold: Implement syscall_get_arch() everywhere
    there is audit which didn't have it. Use syscall_get_arch() in the
    seccomp audit code. Having syscall_get_arch() everywhere meant it was
    a useless flag on the stack and we could get rid of it for the typical
    syscall entry.

    The other changes inside the audit system aren't grand, fixed some
    records that had invalid spaces. Better locking around the task comm
    field. Removing some dead functions and structs. Make some things
    static. Really minor stuff"

    * git://git.infradead.org/users/eparis/audit: (31 commits)
    audit: rename audit_log_remove_rule to disambiguate for trees
    audit: cull redundancy in audit_rule_change
    audit: WARN if audit_rule_change called illegally
    audit: put rule existence check in canonical order
    next: openrisc: Fix build
    audit: get comm using lock to avoid race in string printing
    audit: remove open_arg() function that is never used
    audit: correct AUDIT_GET_FEATURE return message type
    audit: set nlmsg_len for multicast messages.
    audit: use union for audit_field values since they are mutually exclusive
    audit: invalid op= values for rules
    audit: use atomic_t to simplify audit_serial()
    kernel/audit.c: use ARRAY_SIZE instead of sizeof/sizeof[0]
    audit: reduce scope of audit_log_fcaps
    audit: reduce scope of audit_net_id
    audit: arm64: Remove the audit arch argument to audit_syscall_entry
    arm64: audit: Add audit hook in syscall_trace_enter/exit()
    audit: x86: drop arch from __audit_syscall_entry() interface
    sparc: implement is_32bit_task
    sparc: properly conditionalize use of TIF_32BIT
    ...

    Linus Torvalds
     

24 Sep, 2014

4 commits

  • When task->comm is passed directly to audit_log_untrustedstring() without
    getting a copy or using the task_lock, there is a race that could happen that
    would output a NULL (\0) in the output string that would effectively truncate
    the rest of the report text after the comm= field in the audit, losing fields.

    Use get_task_comm() to get a copy while acquiring the task_lock to prevent
    this and to prevent the result from being a mixture of old and new values of
    comm.

    Signed-off-by: Tetsuo Handa
    Signed-off-by: Richard Guy Briggs

    Richard Guy Briggs
     
  • open_arg() was added in commit 55669bfa "audit: AUDIT_PERM support"
    and never used. Remove it.

    Signed-off-by: Richard Guy Briggs

    Richard Guy Briggs
     
  • Since the arch is found locally in __audit_syscall_entry(), there is no need to
    pass it in as a parameter. Delete it from the parameter list.

    x86* was the only arch to call __audit_syscall_entry() directly and did so from
    assembly code.

    Signed-off-by: Richard Guy Briggs
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: x86@kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-audit@redhat.com
    Signed-off-by: Eric Paris

    ---

    As this patch relies on changes in the audit tree, I think it
    appropriate to send it through my tree rather than the x86 tree.

    Richard Guy Briggs
     
  • The AUDIT_SECCOMP record looks something like this:

    type=SECCOMP msg=audit(1373478171.953:32775): auid=4325 uid=4325 gid=4325 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0 pid=12381 comm="test" sig=31 syscall=231 compat=0 ip=0x39ea8bca89 code=0x0

    In order to determine what syscall 231 maps to, we need to have the arch= field right before it.

    To see the event, compile this test.c program:

    =====
    int main(void)
    {
    return seccomp_load(seccomp_init(SCMP_ACT_KILL));
    }
    =====

    gcc -g test.c -o test -lseccomp

    After running the program, find the record by: ausearch --start recent -m SECCOMP -i

    Signed-off-by: Richard Guy Briggs
    signed-off-by: Eric Paris

    Richard Guy Briggs