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

5 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
     
  • Since every arch should have syscall_get_arch() defined, stop using the
    function argument and just collect this ourselves. We do not drop the
    argument as fixing some code paths (in assembly) to not pass this first
    argument is non-trivial. The argument will be dropped when that is
    fixed.

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

    Richard Guy Briggs
     

09 Sep, 2014

1 commit


10 Jun, 2014

1 commit

  • Fixes an easy DoS and possible information disclosure.

    This does nothing about the broken state of x32 auditing.

    eparis: If the admin has enabled auditd and has specifically loaded
    audit rules. This bug has been around since before git. Wow...

    Cc: stable@vger.kernel.org
    Signed-off-by: Andy Lutomirski
    Signed-off-by: Eric Paris
    Signed-off-by: Linus Torvalds

    Andy Lutomirski
     

13 Apr, 2014

1 commit

  • Pull audit updates from Eric Paris.

    * git://git.infradead.org/users/eparis/audit: (28 commits)
    AUDIT: make audit_is_compat depend on CONFIG_AUDIT_COMPAT_GENERIC
    audit: renumber AUDIT_FEATURE_CHANGE into the 1300 range
    audit: do not cast audit_rule_data pointers pointlesly
    AUDIT: Allow login in non-init namespaces
    audit: define audit_is_compat in kernel internal header
    kernel: Use RCU_INIT_POINTER(x, NULL) in audit.c
    sched: declare pid_alive as inline
    audit: use uapi/linux/audit.h for AUDIT_ARCH declarations
    syscall_get_arch: remove useless function arguments
    audit: remove stray newline from audit_log_execve_info() audit_panic() call
    audit: remove stray newlines from audit_log_lost messages
    audit: include subject in login records
    audit: remove superfluous new- prefix in AUDIT_LOGIN messages
    audit: allow user processes to log from another PID namespace
    audit: anchor all pid references in the initial pid namespace
    audit: convert PPIDs to the inital PID namespace.
    pid: get pid_t ppid of task in init_pid_ns
    audit: rename the misleading audit_get_context() to audit_take_context()
    audit: Add generic compat syscall support
    audit: Add CONFIG_HAVE_ARCH_AUDITSYSCALL
    ...

    Linus Torvalds
     

20 Mar, 2014

7 commits

  • There's an unnecessary use of a \n in audit_panic.

    Signed-off-by: Richard Guy Briggs

    Joe Perches
     
  • The login uid change record does not include the selinux context of the
    task logging in. Add that information.

    (Updated from 2011-01: RHBZ:670328 -- RGB)

    Reported-by: Steve Grubb
    Acked-by: James Morris
    Signed-off-by: Eric Paris
    Signed-off-by: Aristeu Rozanski
    Signed-off-by: Richard Guy Briggs

    Eric Paris
     
  • The new- prefix on ses and auid are un-necessary and break ausearch.

    Signed-off-by: Richard Guy Briggs

    Richard Guy Briggs
     
  • Store and log all PIDs with reference to the initial PID namespace and
    use the access functions task_pid_nr() and task_tgid_nr() for task->pid
    and task->tgid.

    Cc: "Eric W. Biederman"
    (informed by ebiederman's c776b5d2)
    Signed-off-by: Richard Guy Briggs

    Richard Guy Briggs
     
  • sys_getppid() returns the parent pid of the current process in its own pid
    namespace. Since audit filters are based in the init pid namespace, a process
    could avoid a filter or trigger an unintended one by being in an alternate pid
    namespace or log meaningless information.

    Switch to task_ppid_nr() for PPIDs to anchor all audit filters in the
    init_pid_ns.

    (informed by ebiederman's 6c621b7e)
    Cc: stable@vger.kernel.org
    Cc: Eric W. Biederman
    Signed-off-by: Richard Guy Briggs

    Richard Guy Briggs
     
  • "get" usually implies incrementing a refcount into a structure to indicate a
    reference being held by another part of code.

    Change this function name to indicate it is in fact being taken from it,
    returning the value while clearing it in the supplying structure.

    Signed-off-by: Richard Guy Briggs

    Richard Guy Briggs
     
  • During an audit event, cache and print the value of the process's
    proctitle value (proc//cmdline). This is useful in situations
    where processes are started via fork'd virtual machines where the
    comm field is incorrect. Often times, setting the comm field still
    is insufficient as the comm width is not very wide and most
    virtual machine "package names" do not fit. Also, during execution,
    many threads have their comm field set as well. By tying it back to
    the global cmdline value for the process, audit records will be more
    complete in systems with these properties. An example of where this
    is useful and applicable is in the realm of Android. With Android,
    their is no fork/exec for VM instances. The bare, preloaded Dalvik
    VM listens for a fork and specialize request. When this request comes
    in, the VM forks, and the loads the specific application (specializing).
    This was done to take advantage of COW and to not require a load of
    basic packages by the VM on very app spawn. When this spawn occurs,
    the package name is set via setproctitle() and shows up in procfs.
    Many of these package names are longer then 16 bytes, the historical
    width of task->comm. Having the cmdline in the audit records will
    couple the application back to the record directly. Also, on my
    Debian development box, some audit records were more useful then
    what was printed under comm.

    The cached proctitle is tied to the life-cycle of the audit_context
    structure and is built on demand.

    Proctitle is controllable by userspace, and thus should not be trusted.
    It is meant as an aid to assist in debugging. The proctitle event is
    emitted during syscall audits, and can be filtered with auditctl.

    Example:
    type=AVC msg=audit(1391217013.924:386): avc: denied { getattr } for pid=1971 comm="mkdir" name="/" dev="selinuxfs" ino=1 scontext=system_u:system_r:consolekit_t:s0-s0:c0.c255 tcontext=system_u:object_r:security_t:s0 tclass=filesystem
    type=SYSCALL msg=audit(1391217013.924:386): arch=c000003e syscall=137 success=yes exit=0 a0=7f019dfc8bd7 a1=7fffa6aed2c0 a2=fffffffffff4bd25 a3=7fffa6aed050 items=0 ppid=1967 pid=1971 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="mkdir" exe="/bin/mkdir" subj=system_u:system_r:consolekit_t:s0-s0:c0.c255 key=(null)
    type=UNKNOWN[1327] msg=audit(1391217013.924:386): proctitle=6D6B646972002D70002F7661722F72756E2F636F6E736F6C65

    Acked-by: Steve Grubb (wrt record formating)

    Signed-off-by: William Roberts
    Signed-off-by: Eric Paris

    William Roberts
     

08 Mar, 2014

1 commit


06 Feb, 2014

1 commit

  • This changes 'do_execve()' to get the executable name as a 'struct
    filename', and to free it when it is done. This is what the normal
    users want, and it simplifies and streamlines their error handling.

    The controlled lifetime of the executable name also fixes a
    use-after-free problem with the trace_sched_process_exec tracepoint: the
    lifetime of the passed-in string for kernel users was not at all
    obvious, and the user-mode helper code used UMH_WAIT_EXEC to serialize
    the pathname allocation lifetime with the execve() having finished,
    which in turn meant that the trace point that happened after
    mm_release() of the old process VM ended up using already free'd memory.

    To solve the kernel string lifetime issue, this simply introduces
    "getname_kernel()" that works like the normal user-space getname()
    function, except with the source coming from kernel memory.

    As Oleg points out, this also means that we could drop the tcomm[] array
    from 'struct linux_binprm', since the pathname lifetime now covers
    setup_new_exec(). That would be a separate cleanup.

    Reported-by: Igor Zhbanov
    Tested-by: Steven Rostedt
    Cc: Oleg Nesterov
    Cc: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

14 Jan, 2014

6 commits

  • Remove spaces between "new", "old" label modifiers and "auid", "ses" labels in
    log output since userspace tools can't parse orphaned keywords.

    Make variable names more consistent and intuitive.

    Make audit_log_format() argument code easier to read.

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

    Richard Guy Briggs
     
  • Right now the sessionid value in the kernel is a combination of u32,
    int, and unsigned int. Just use unsigned int throughout.

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

    Eric Paris
     
  • Currently when the coredump signals are logged by the audit system, the
    actual path to the executable is not logged. Without details of exe, the
    system admin may not have an exact idea on what program failed.

    This patch changes the audit_log_task() so that the path to the exe is also
    logged.

    This was copied from audit_log_task_info() and the latter enhanced to avoid
    disappearing text fields.

    Signed-off-by: Paul Davies C
    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Eric Paris

    Paul Davies C
     
  • The audit_log_abend() is used only by the audit_core_dumps(). Thus there is no
    need of maintaining the audit_log_abend() as a separate function.

    This patch drops the audit_log_abend() and pushes its functionalities back to
    the audit_core_dumps(). Apart from that the "reason" field is also dropped
    from being logged since the reason can be deduced from the signal number.

    Signed-off-by: Paul Davies C
    Acked-by: Eric Paris
    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Eric Paris

    Paul Davies C
     
  • If audit is disabled, we shouldn't generate loginuid audit
    log.

    Acked-by: Eric Paris
    Signed-off-by: Gao feng
    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Eric Paris

    Gao feng
     
  • - Always report the current process as capset now always only works on
    the current process. This prevents reporting 0 or a random pid in
    a random pid namespace.

    - Don't bother to pass the pid as is available.

    Signed-off-by: "Eric W. Biederman"
    (cherry picked from commit bcc85f0af31af123e32858069eb2ad8f39f90e67)
    (cherry picked from commit f911cac4556a7a23e0b3ea850233d13b32328692)

    Signed-off-by: Richard Guy Briggs
    [eparis: fix build error when audit disabled]
    Signed-off-by: Eric Paris

    Eric W. Biederman
     

07 Nov, 2013

1 commit

  • sfr pointed out that with CONFIG_UIDGID_STRICT_TYPE_CHECKS set the audit
    tree would not build. This is because the oldsessionid in
    audit_set_loginuid() was accidentally being declared as a kuid_t. This
    patch fixes that declaration mistake.

    Example of problem:
    kernel/auditsc.c: In function 'audit_set_loginuid':
    kernel/auditsc.c:2003:15: error: incompatible types when assigning to
    type 'kuid_t' from type 'int'
    oldsessionid = audit_get_sessionid(current);

    Reported-by: Stephen Rothwell
    Signed-off-by: Eric Paris

    Eric Paris
     

06 Nov, 2013

11 commits

  • Move the audit_bprm() call from search_binary_handler() to exec_binprm(). This
    allows us to get rid of the mm member of struct audit_aux_data_execve since
    bprm->mm will equal current->mm.

    This also mitigates the issue that ->argc could be modified by the
    load_binary() call in search_binary_handler().

    audit_bprm() was being called to add an AUDIT_EXECVE record to the audit
    context every time search_binary_handler() was recursively called. Only one
    reference is necessary.

    Reported-by: Oleg Nesterov
    Cc: Eric Paris
    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Eric Paris
    ---
    This patch is against 3.11, but was developed on Oleg's post-3.11 patches that
    introduce exec_binprm().

    Richard Guy Briggs
     
  • audit_bprm() was being called to add an AUDIT_EXECVE record to the audit
    context every time search_binary_handler() was recursively called. Only one
    reference is necessary, so just update it. Move the the contents of
    audit_aux_data_execve into the union in audit_context, removing dependence on a
    kmalloc along the way.

    Reported-by: Oleg Nesterov
    Cc: Eric Paris
    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Eric Paris

    Richard Guy Briggs
     
  • Get rid of write-only audit_aux_data_exeve structure member envc.

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

    Richard Guy Briggs
     
  • Signed-off-by: "Eric W. Biederman"
    (cherry picked from ebiederman commit 6904431d6b41190e42d6b94430b67cb4e7e6a4b7)
    Signed-off-by: Eric Paris

    Eric W. Biederman
     
  • It appears this one comparison function got missed in f368c07d (and 9c937dcc).

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

    Richard Guy Briggs
     
  • This adds a new 'audit_feature' bit which allows userspace to set it
    such that the loginuid is absolutely immutable, even if you have
    CAP_AUDIT_CONTROL.

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

    Eric Paris
     
  • This is a new audit feature which only grants processes with
    CAP_AUDIT_CONTROL the ability to unset their loginuid. They cannot
    directly set it from a valid uid to another valid uid. The ability to
    unset the loginuid is nice because a priviledged task, like that of
    container creation, can unset the loginuid and then priv is not needed
    inside the container when a login daemon needs to set the loginuid.

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

    Eric Paris
     
  • If a task has CAP_AUDIT_CONTROL allow that task to unset their loginuid.
    This would allow a child of that task to set their loginuid without
    CAP_AUDIT_CONTROL. Thus when launching a new login daemon, a
    priviledged helper would be able to unset the loginuid and then the
    daemon, which may be malicious user facing, do not need priv to function
    correctly.

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

    Eric Paris
     
  • After trying to use this feature in Fedora we found the hard coding
    policy like this into the kernel was a bad idea. Surprise surprise.
    We ran into these problems because it was impossible to launch a
    container as a logged in user and run a login daemon inside that container.
    This reverts back to the old behavior before this option was added. The
    option will be re-added in a userspace selectable manor such that
    userspace can choose when it is and when it is not appropriate.

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

    Eric Paris
     
  • This is just a code rework. It makes things more readable. It does not
    make any functional changes.

    It does change the log messages to include both the old session id as
    well the new and it includes a new res field, which means we get
    messages even when the user did not have permission to change the
    loginuid.

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

    Eric Paris
     
  • If audit_filter_task() nacks the new thread it makes sense
    to clear TIF_SYSCALL_AUDIT which can be copied from parent
    by dup_task_struct().

    A wrong TIF_SYSCALL_AUDIT is not really bad but it triggers
    the "slow" audit paths in entry.S to ensure the task can not
    miss audit_syscall_*() calls, this is pointless if the task
    has no ->audit_context.

    Signed-off-by: Oleg Nesterov
    Acked-by: Steve Grubb
    Acked-by: Eric Paris
    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Eric Paris

    Oleg Nesterov
     

10 Jul, 2013

1 commit

  • The old audit PATH records for mq_open looked like this:

    type=PATH msg=audit(1366282323.982:869): item=1 name=(null) inode=6777
    dev=00:0c mode=041777 ouid=0 ogid=0 rdev=00:00
    obj=system_u:object_r:tmpfs_t:s15:c0.c1023
    type=PATH msg=audit(1366282323.982:869): item=0 name="test_mq" inode=26732
    dev=00:0c mode=0100700 ouid=0 ogid=0 rdev=00:00
    obj=staff_u:object_r:user_tmpfs_t:s15:c0.c1023

    ...with the audit related changes that went into 3.7, they now look like this:

    type=PATH msg=audit(1366282236.776:3606): item=2 name=(null) inode=66655
    dev=00:0c mode=0100700 ouid=0 ogid=0 rdev=00:00
    obj=staff_u:object_r:user_tmpfs_t:s15:c0.c1023
    type=PATH msg=audit(1366282236.776:3606): item=1 name=(null) inode=6926
    dev=00:0c mode=041777 ouid=0 ogid=0 rdev=00:00
    obj=system_u:object_r:tmpfs_t:s15:c0.c1023
    type=PATH msg=audit(1366282236.776:3606): item=0 name="test_mq"

    Both of these look wrong to me. As Steve Grubb pointed out:

    "What we need is 1 PATH record that identifies the MQ. The other PATH
    records probably should not be there."

    Fix it to record the mq root as a parent, and flag it such that it
    should be hidden from view when the names are logged, since the root of
    the mq filesystem isn't terribly interesting. With this change, we get
    a single PATH record that looks more like this:

    type=PATH msg=audit(1368021604.836:484): item=0 name="test_mq" inode=16914
    dev=00:0c mode=0100644 ouid=0 ogid=0 rdev=00:00
    obj=unconfined_u:object_r:user_tmpfs_t:s0

    In order to do this, a new audit_inode_parent_hidden() function is
    added. If we do it this way, then we avoid having the existing callers
    of audit_inode needing to do any sort of flag conversion if auditing is
    inactive.

    Signed-off-by: Jeff Layton
    Reported-by: Jiri Jaburek
    Cc: Steve Grubb
    Cc: Eric Paris
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jeff Layton
     

08 May, 2013

1 commit

  • audit rule additions containing "-F auid!=4294967295" were failing
    with EINVAL because of a regression caused by e1760bd.

    Apparently some userland audit rule sets want to know if loginuid uid
    has been set and are using a test for auid != 4294967295 to determine
    that.

    In practice that is a horrible way to ask if a value has been set,
    because it relies on subtle implementation details and will break
    every time the uid implementation in the kernel changes.

    So add a clean way to test if the audit loginuid has been set, and
    silently convert the old idiom to the cleaner and more comprehensible
    new idiom.

    Cc: # 3.7
    Reported-By: Richard Guy Briggs
    Signed-off-by: "Eric W. Biederman"
    Tested-by: Richard Guy Briggs
    Signed-off-by: Eric Paris

    Eric W. Biederman