24 Sep, 2014

1 commit


20 Mar, 2014

2 commits

  • While reading through 3.14-rc1 I found a pretty siginficant mishandling
    of network namespaces in the recent audit changes.

    In struct audit_netlink_list and audit_reply add a reference to the
    network namespace of the caller and remove the userspace pid of the
    caller. This cleanly remembers the callers network namespace, and
    removes a huge class of races and nasty failure modes that can occur
    when attempting to relook up the callers network namespace from a pid_t
    (including the caller's network namespace changing, pid wraparound, and
    the pid simply not being present).

    Signed-off-by: "Eric W. Biederman"
    Acked-by: Richard Guy Briggs
    Signed-off-by: Eric Paris

    Eric W. Biederman
     
  • 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
     

15 Jan, 2014

1 commit

  • The equivalent uapi struct uses __u32 so make the kernel
    uses u32 too.

    This can prevent some oddities where the limit is
    logged/emitted as a negative value.

    Convert kstrtol to kstrtouint to disallow negative values.

    Signed-off-by: Joe Perches
    [eparis: do not remove static from audit_default declaration]

    Joe Perches
     

14 Jan, 2014

2 commits

  • Convert audit from only listening in init_net to use register_pernet_subsys()
    to dynamically manage the netlink socket list.

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

    Richard Guy Briggs
     
  • Normally, netlink ports use the PID of the userspace process as the port ID.
    If the PID is already in use by a port, the kernel will allocate another port
    ID to avoid conflict. Re-name all references to netlink ports from pid to
    portid to reflect this reality and avoid confusion with actual PIDs. Ports
    use the __u32 type, so re-type all portids accordingly.

    (This patch is very similar to ebiederman's 5deadd69)

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

    Richard Guy Briggs
     

06 Nov, 2013

2 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
     

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
     

12 May, 2013

1 commit

  • Pull audit changes from Eric Paris:
    "Al used to send pull requests every couple of years but he told me to
    just start pushing them to you directly.

    Our touching outside of core audit code is pretty straight forward. A
    couple of interface changes which hit net/. A simple argument bug
    calling audit functions in namei.c and the removal of some assembly
    branch prediction code on ppc"

    * git://git.infradead.org/users/eparis/audit: (31 commits)
    audit: fix message spacing printing auid
    Revert "audit: move kaudit thread start from auditd registration to kaudit init"
    audit: vfs: fix audit_inode call in O_CREAT case of do_last
    audit: Make testing for a valid loginuid explicit.
    audit: fix event coverage of AUDIT_ANOM_LINK
    audit: use spin_lock in audit_receive_msg to process tty logging
    audit: do not needlessly take a lock in tty_audit_exit
    audit: do not needlessly take a spinlock in copy_signal
    audit: add an option to control logging of passwords with pam_tty_audit
    audit: use spin_lock_irqsave/restore in audit tty code
    helper for some session id stuff
    audit: use a consistent audit helper to log lsm information
    audit: push loginuid and sessionid processing down
    audit: stop pushing loginid, uid, sessionid as arguments
    audit: remove the old depricated kernel interface
    audit: make validity checking generic
    audit: allow checking the type of audit message in the user filter
    audit: fix build break when AUDIT_DEBUG == 2
    audit: remove duplicate export of audit_enabled
    Audit: do not print error when LSMs disabled
    ...

    Linus Torvalds
     

01 May, 2013

1 commit

  • The userspace audit tools didn't like the existing formatting of the
    AUDIT_ANOM_LINK event. It needed to be expanded to emit an AUDIT_PATH
    event as well, so this implements the change. The bulk of the patch is
    moving code out of auditsc.c into audit.c and audit.h for general use.
    It expands audit_log_name to include an optional "struct path" argument
    for the simple case of just needing to report a pathname. This also
    makes
    audit_log_task_info available when syscall auditing is not enabled,
    since
    it is needed in either case for process details.

    Signed-off-by: Kees Cook
    Reported-by: Steve Grubb

    Eric Paris
     

30 Apr, 2013

2 commits

  • The files which include kernel/audit.h are complied only when
    CONFIG_AUDIT is set.

    Just like audit_pid, there is no need to surround audit_ever_enabled
    with CONFIG_AUDIT.

    Signed-off-by: Gao feng
    Cc: Al Viro
    Cc: Eric Paris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Gao feng
     
  • audit_enabled has already been exported in include/linux/audit.h. and
    kernel/audit.h includes include/linux/audit.h, no need to export
    aduit_enabled again in kernel/audit.h

    Signed-off-by: Gao feng
    Cc: Al Viro
    Cc: Eric Paris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Gao feng
     

12 Apr, 2013

1 commit


12 Oct, 2012

3 commits

  • In the cases where we already know the length of the parent, pass it as
    a parm so we don't need to recompute it. In the cases where we don't
    know the length, pass in AUDIT_NAME_FULL (-1) to indicate that it should
    be determined.

    Signed-off-by: Jeff Layton
    Signed-off-by: Al Viro

    Jeff Layton
     
  • All the callers set this to NULL now.

    Signed-off-by: Jeff Layton
    Signed-off-by: Al Viro

    Jeff Layton
     
  • Currently, this gets set mostly by happenstance when we call into
    audit_inode_child. While that might be a little more efficient, it seems
    wrong. If the syscall ends up failing before audit_inode_child ever gets
    called, then you'll have an audit_names record that shows the full path
    but has the parent inode info attached.

    Fix this by passing in a parent flag when we call audit_inode that gets
    set to the value of LOOKUP_PARENT. We can then fix up the pathname for
    the audit entry correctly from the get-go.

    While we're at it, clean up the no-op macro for audit_inode in the
    !CONFIG_AUDITSYSCALL case.

    Signed-off-by: Jeff Layton
    Signed-off-by: Al Viro

    Jeff Layton
     

18 Sep, 2012

2 commits

  • - Explicitly format uids gids in audit messges in the initial user
    namespace. This is safe because auditd is restrected to be in
    the initial user namespace.

    - Convert audit_sig_uid into a kuid_t.

    - Enable building the audit code and user namespaces at the same time.

    The net result is that the audit subsystem now uses kuid_t and kgid_t whenever
    possible making it almost impossible to confuse a raw uid_t with a kuid_t
    preventing bugs.

    Cc: Al Viro
    Cc: Eric Paris
    Cc: Greg Kroah-Hartman
    Signed-off-by: Eric W. Biederman

    Eric W. Biederman
     
  • The audit filter code guarantees that uid are always compared with
    uids and gids are always compared with gids, as the comparason
    operations are type specific. Take advantage of this proper to define
    audit_uid_comparator and audit_gid_comparator which use the type safe
    comparasons from uidgid.h.

    Build on audit_uid_comparator and audit_gid_comparator and replace
    audit_compare_id with audit_compare_uid and audit_compare_gid. This
    is one of those odd cases where being type safe and duplicating code
    leads to simpler shorter and more concise code.

    Don't allow bitmask operations in uid and gid comparisons in
    audit_data_to_entry. Bitmask operations are already denined in
    audit_rule_to_entry.

    Convert constants in audit_rule_to_entry and audit_data_to_entry into
    kuids and kgids when appropriate.

    Convert the uid and gid field in struct audit_names to be of type
    kuid_t and kgid_t respectively, so that the new uid and gid comparators
    can be applied in a type safe manner.

    Cc: Al Viro
    Cc: Eric Paris
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

18 Jan, 2012

1 commit


30 Oct, 2010

1 commit

  • I was doing some namespace checks and found some simple stuff in
    audit that could be cleaned up. Make some functions static, and
    put const on make_reply payload arg.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: Al Viro

    Stephen Hemminger
     

28 Jul, 2010

3 commits

  • Audit watch should depend on CONFIG_AUDIT_SYSCALL and should select
    FSNOTIFY. This splits the spagetti like mixing of audit_watch and
    audit_filter code so they can be configured seperately.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • deleting audit watch rules is not currently done under audit_filter_mutex.
    It was done this way because we could not hold the mutex during inotify
    manipulation. Since we are using fsnotify we don't need to do the extra
    get/put pair nor do we need the private list on which to store the parents
    while they are about to be freed.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • No real changes, just cleanup to the audit_watch split patch which we done
    with minimal code changes for easy review. Now fix interfaces to make
    things work better.

    Signed-off-by: Eric Paris

    Eric Paris
     

24 Jun, 2009

3 commits