07 Jun, 2018

1 commit

  • Pull audit updates from Paul Moore:
    "Another reasonable chunk of audit changes for v4.18, thirteen patches
    in total.

    The thirteen patches can mostly be broken down into one of four
    categories: general bug fixes, accessor functions for audit state
    stored in the task_struct, negative filter matches on executable
    names, and extending the (relatively) new seccomp logging knobs to the
    audit subsystem.

    The main driver for the accessor functions from Richard are the
    changes we're working on to associate audit events with containers,
    but I think they have some standalone value too so I figured it would
    be good to get them in now.

    The seccomp/audit patches from Tyler apply the seccomp logging
    improvements from a few releases ago to audit's seccomp logging;
    starting with this patchset the changes in
    /proc/sys/kernel/seccomp/actions_logged should apply to both the
    standard kernel logging and audit.

    As usual, everything passes the audit-testsuite and it happens to
    merge cleanly with your tree"

    [ Heh, except it had trivial merge conflicts with the SELinux tree that
    also came in from Paul - Linus ]

    * tag 'audit-pr-20180605' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
    audit: Fix wrong task in comparison of session ID
    audit: use existing session info function
    audit: normalize loginuid read access
    audit: use new audit_context access funciton for seccomp_actions_logged
    audit: use inline function to set audit context
    audit: use inline function to get audit context
    audit: convert sessionid unset to a macro
    seccomp: Don't special case audited processes when logging
    seccomp: Audit attempts to modify the actions_logged sysctl
    seccomp: Configurable separator for the actions_logged string
    seccomp: Separate read and write code for actions_logged sysctl
    audit: allow not equal op for audit by executable
    audit: add syscall information to FEATURE_CHANGE records

    Linus Torvalds
     

15 May, 2018

1 commit

  • Recognizing that the audit context is an internal audit value, use an
    access function to retrieve the audit context pointer for the task
    rather than reaching directly into the task struct to get it.

    Signed-off-by: Richard Guy Briggs
    [PM: merge fuzz in auditsc.c and selinuxfs.c, checkpatch.pl fixes]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

18 Apr, 2018

2 commits

  • The audit MAC_POLICY_LOAD record had redundant dangling keywords and was
    missing information about which LSM was responsible and its completion
    status. While this record is only issued on success, the parser expects
    the res= field to be present.

    Old record:
    type=MAC_POLICY_LOAD msg=audit(1479299795.404:43): policy loaded auid=0 ses=1

    Delete the redundant dangling keywords, add the lsm= field and the res=
    field.

    New record:
    type=MAC_POLICY_LOAD msg=audit(1523293846.204:894): auid=0 ses=1 lsm=selinux res=1

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

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

    Richard Guy Briggs
     
  • There were two formats of the audit MAC_STATUS record, one of which was more
    standard than the other. One listed enforcing status changes and the
    other listed enabled status changes with a non-standard label. In
    addition, the record was missing information about which LSM was
    responsible and the operation's completion status. While this record is
    only issued on success, the parser expects the res= field to be present.

    old enforcing/permissive:
    type=MAC_STATUS msg=audit(1523312831.378:24514): enforcing=0 old_enforcing=1 auid=0 ses=1
    old enable/disable:
    type=MAC_STATUS msg=audit(1523312831.378:24514): selinux=0 auid=0 ses=1

    List both sets of status and old values and add the lsm= field and the
    res= field.

    Here is the new format:
    type=MAC_STATUS msg=audit(1523293828.657:891): enforcing=0 old_enforcing=1 auid=0 ses=1 enabled=1 old-enabled=1 lsm=selinux res=1

    This record already accompanied a SYSCALL record.

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

    Signed-off-by: Richard Guy Briggs
    [PM: 80-char fixes, merge fuzz, use new SELinux state functions]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

17 Apr, 2018

1 commit


10 Apr, 2018

1 commit

  • Commit 0619f0f5e36f ("selinux: wrap selinuxfs state") triggers a BUG
    when SELinux is runtime-disabled (i.e. systemd or equivalent disables
    SELinux before initial policy load via /sys/fs/selinux/disable based on
    /etc/selinux/config SELINUX=disabled).

    This does not manifest if SELinux is disabled via kernel command line
    argument or if SELinux is enabled (permissive or enforcing).

    Before:
    SELinux: Disabled at runtime.
    BUG: Dentry 000000006d77e5c7{i=17,n=null} still in use (1) [unmount of selinuxfs selinuxfs]

    After:
    SELinux: Disabled at runtime.

    Fixes: 0619f0f5e36f ("selinux: wrap selinuxfs state")
    Reported-by: Tetsuo Handa
    Reported-by: Dmitry Vyukov
    Signed-off-by: Stephen Smalley
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     

21 Mar, 2018

2 commits

  • Wrap the AVC state within the selinux_state structure and
    pass it explicitly to all AVC functions. The AVC private state
    is encapsulated in a selinux_avc structure that is referenced
    from the selinux_state.

    This change should have no effect on SELinux behavior or
    APIs (userspace or LSM).

    Signed-off-by: Stephen Smalley
    Reviewed-by: James Morris
    Signed-off-by: Paul Moore

    Stephen Smalley
     
  • Move global selinuxfs state to a per-instance structure (selinux_fs_info),
    and include a pointer to the selinux_state in this structure.
    Pass this selinux_state to all security server operations, thereby
    ensuring that each selinuxfs instance presents a view of and acts
    as an interface to a particular selinux_state instance.

    This change should have no effect on SELinux behavior or APIs
    (userspace or LSM). It merely wraps the selinuxfs global state,
    links it to a particular selinux_state (currently always the single
    global selinux_state) and uses that state for all operations.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

03 Mar, 2018

1 commit


02 Mar, 2018

1 commit

  • Define a selinux state structure (struct selinux_state) for
    global SELinux state and pass it explicitly to all security server
    functions. The public portion of the structure contains state
    that is used throughout the SELinux code, such as the enforcing mode.
    The structure also contains a pointer to a selinux_ss structure whose
    definition is private to the security server and contains security
    server specific state such as the policy database and SID table.

    This change should have no effect on SELinux behavior or APIs
    (userspace or LSM). It merely wraps SELinux state and passes it
    explicitly as needed.

    Signed-off-by: Stephen Smalley
    [PM: minor fixups needed due to collisions with the SCTP patches]
    Signed-off-by: Paul Moore

    Stephen Smalley
     

06 Jul, 2017

1 commit

  • Pull memdup_user() conversions from Al Viro:
    "A fairly self-contained series - hunting down open-coded memdup_user()
    and memdup_user_nul() instances"

    * 'work.memdup_user' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    bpf: don't open-code memdup_user()
    kimage_file_prepare_segments(): don't open-code memdup_user()
    ethtool: don't open-code memdup_user()
    do_ip_setsockopt(): don't open-code memdup_user()
    do_ipv6_setsockopt(): don't open-code memdup_user()
    irda: don't open-code memdup_user()
    xfrm_user_policy(): don't open-code memdup_user()
    ima_write_policy(): don't open-code memdup_user_nul()
    sel_write_validatetrans(): don't open-code memdup_user_nul()

    Linus Torvalds
     

26 May, 2017

1 commit


24 May, 2017

1 commit

  • Add a generic notificaiton mechanism in the LSM. Interested consumers
    can register a callback with the LSM and security modules can produce
    events.

    Because access to Infiniband QPs are enforced in the setup phase of a
    connection security should be enforced again if the policy changes.
    Register infiniband devices for policy change notification and check all
    QPs on that device when the notification is received.

    Add a call to the notification mechanism from SELinux when the AVC
    cache changes or setenforce is cleared.

    Signed-off-by: Daniel Jurgens
    Acked-by: James Morris
    Acked-by: Doug Ledford
    Signed-off-by: Paul Moore

    Daniel Jurgens
     

23 May, 2017

1 commit

  • Log the state of SELinux policy capabilities when a policy is loaded.
    For each policy capability known to the kernel, log the policy capability
    name and the value set in the policy. For policy capabilities that are
    set in the loaded policy but unknown to the kernel, log the policy
    capability index, since this is the only information presently available
    in the policy.

    Sample output with a policy created with a new capability defined
    that is not known to the kernel:
    SELinux: policy capability network_peer_controls=1
    SELinux: policy capability open_perms=1
    SELinux: policy capability extended_socket_class=1
    SELinux: policy capability always_check_network=0
    SELinux: policy capability cgroup_seclabel=0
    SELinux: unknown policy capability 5

    Resolves: https://github.com/SELinuxProject/selinux-kernel/issues/32

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

10 May, 2017

1 commit

  • Pull misc vfs updates from Al Viro:
    "Assorted bits and pieces from various people. No common topic in this
    pile, sorry"

    * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs/affs: add rename exchange
    fs/affs: add rename2 to prepare multiple methods
    Make stat/lstat/fstatat pass AT_NO_AUTOMOUNT to vfs_statx()
    fs: don't set *REFERENCED on single use objects
    fs: compat: Remove warning from COMPATIBLE_IOCTL
    remove pointless extern of atime_need_update_rcu()
    fs: completely ignore unknown open flags
    fs: add a VALID_OPEN_FLAGS
    fs: remove _submit_bh()
    fs: constify tree_descr arrays passed to simple_fill_super()
    fs: drop duplicate header percpu-rwsem.h
    fs/affs: bugfix: Write files greater than page size on OFS
    fs/affs: bugfix: enable writes on OFS disks
    fs/affs: remove node generation check
    fs/affs: import amigaffs.h
    fs/affs: bugfix: make symbolic links work again

    Linus Torvalds
     

27 Apr, 2017

1 commit

  • simple_fill_super() is passed an array of tree_descr structures which
    describe the files to create in the filesystem's root directory. Since
    these arrays are never modified intentionally, they should be 'const' so
    that they are placed in .rodata and benefit from memory protection.
    This patch updates the function signature and all users, and also
    constifies tree_descr.name.

    Signed-off-by: Eric Biggers
    Signed-off-by: Al Viro

    Eric Biggers
     

29 Mar, 2017

1 commit


02 Mar, 2017

1 commit

  • commit 1ea0ce40690dff38935538e8dab7b12683ded0d3 ("selinux: allow
    changing labels for cgroupfs") broke the Android init program,
    which looks up security contexts whenever creating directories
    and attempts to assign them via setfscreatecon().
    When creating subdirectories in cgroup mounts, this would previously
    be ignored since cgroup did not support userspace setting of security
    contexts. However, after the commit, SELinux would attempt to honor
    the requested context on cgroup directories and fail due to permission
    denial. Avoid breaking existing userspace/policy by wrapping this change
    with a conditional on a new cgroup_seclabel policy capability. This
    preserves existing behavior until/unless a new policy explicitly enables
    this capability.

    Reported-by: John Stultz
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Stephen Smalley
     

25 Feb, 2017

1 commit

  • ->fault(), ->page_mkwrite(), and ->pfn_mkwrite() calls do not need to
    take a vma and vmf parameter when the vma already resides in vmf.

    Remove the vma parameter to simplify things.

    [arnd@arndb.de: fix ARM build]
    Link: http://lkml.kernel.org/r/20170125223558.1451224-1-arnd@arndb.de
    Link: http://lkml.kernel.org/r/148521301778.19116.10840599906674778980.stgit@djiang5-desk3.ch.intel.com
    Signed-off-by: Dave Jiang
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Ross Zwisler
    Cc: Theodore Ts'o
    Cc: Darrick J. Wong
    Cc: Matthew Wilcox
    Cc: Dave Hansen
    Cc: Christoph Hellwig
    Cc: Jan Kara
    Cc: Dan Williams
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dave Jiang
     

09 Jan, 2017

4 commits

  • Use SECINITSID_SECURITY as the default SID for booleans which don't have
    a matching SID returned from security_genfs_sid(), also update the
    error message to a warning which matches this.

    This prevents the policy failing to load (and consequently the system
    failing to boot) when there is no default genfscon statement matched for
    the selinuxfs in the new policy.

    Signed-off-by: Gary Tierney
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Gary Tierney
     
  • Adds error logging to the code paths which can fail when loading a new
    policy in sel_write_load(). If the policy fails to be loaded from
    userspace then a warning message is printed, whereas if a failure occurs
    after loading policy from userspace an error message will be printed
    with details on where policy loading failed (recreating one of /classes/,
    /policy_capabilities/, /booleans/ in the SELinux fs).

    Also, if sel_make_bools() fails to obtain an SID for an entry in
    /booleans/* an error will be printed indicating the path of the
    boolean.

    Signed-off-by: Gary Tierney
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Gary Tierney
     
  • SELinux was sometimes using the task "objective" credentials when
    it could/should use the "subjective" credentials. This was sometimes
    hidden by the fact that we were unnecessarily passing around pointers
    to the current task, making it appear as if the task could be something
    other than current, so eliminate all such passing of current. Inline
    various permission checking helper functions that can be reduced to a
    single avc_has_perm() call.

    Since the credentials infrastructure only allows a task to alter
    its own credentials, we can always assume that current must be the same
    as the target task in selinux_setprocattr after the check. We likely
    should move this check from selinux_setprocattr() to proc_pid_attr_write()
    and drop the task argument to the security hook altogether; it can only
    serve to confuse things.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     
  • Extend SELinux to support distinctions among all network address families
    implemented by the kernel by defining new socket security classes
    and mapping to them. Otherwise, many sockets are mapped to the generic
    socket class and are indistinguishable in policy. This has come up
    previously with regard to selectively allowing access to bluetooth sockets,
    and more recently with regard to selectively allowing access to AF_ALG
    sockets. Guido Trentalancia submitted a patch that took a similar approach
    to add only support for distinguishing AF_ALG sockets, but this generalizes
    his approach to handle all address families implemented by the kernel.
    Socket security classes are also added for ICMP and SCTP sockets.
    Socket security classes were not defined for AF_* values that are reserved
    but unimplemented in the kernel, e.g. AF_NETBEUI, AF_SECURITY, AF_ASH,
    AF_ECONET, AF_SNA, AF_WANPIPE.

    Backward compatibility is provided by only enabling the finer-grained
    socket classes if a new policy capability is set in the policy; older
    policies will behave as before. The legacy redhat1 policy capability
    that was only ever used in testing within Fedora for ptrace_child
    is reclaimed for this purpose; as far as I can tell, this policy
    capability is not enabled in any supported distro policy.

    Add a pair of conditional compilation guards to detect when new AF_* values
    are added so that we can update SELinux accordingly rather than having to
    belatedly update it long after new address families are introduced.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

21 Nov, 2016

1 commit

  • At present, one can write any signed integer value to
    /sys/fs/selinux/enforce and it will be stored,
    e.g. echo -1 > /sys/fs/selinux/enforce or echo 2 >
    /sys/fs/selinux/enforce. This makes no real difference
    to the kernel, since it only ever cares if it is zero or non-zero,
    but some userspace code compares it with 1 to decide if SELinux
    is enforcing, and this could confuse it. Only a process that is
    already root and is allowed the setenforce permission in SELinux
    policy can write to /sys/fs/selinux/enforce, so this is not considered
    to be a security issue, but it should be fixed.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

15 Nov, 2016

1 commit

  • Fix the comment for function __inode_security_revalidate, which returns
    an integer.

    Use the LABEL_* constants consistently for isec->initialized.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Paul Moore

    Andreas Gruenbacher
     

28 Sep, 2016

1 commit

  • CURRENT_TIME macro is not appropriate for filesystems as it
    doesn't use the right granularity for filesystem timestamps.
    Use current_time() instead.

    CURRENT_TIME is also not y2038 safe.

    This is also in preparation for the patch that transitions
    vfs timestamps to use 64 bit time and hence make them
    y2038 safe. As part of the effort current_time() will be
    extended to do range checks. Hence, it is necessary for all
    file system timestamps to use current_time(). Also,
    current_time() will be transitioned along with vfs to be
    y2038 safe.

    Note that whenever a single call to current_time() is used
    to change timestamps in different inodes, it is because they
    share the same time granularity.

    Signed-off-by: Deepa Dinamani
    Reviewed-by: Arnd Bergmann
    Acked-by: Felipe Balbi
    Acked-by: Steven Whitehouse
    Acked-by: Ryusuke Konishi
    Acked-by: David Sterba
    Signed-off-by: Al Viro

    Deepa Dinamani
     

16 Jun, 2016

1 commit

  • avc_cache_threshold is of type unsigned int. Do not use a signed
    new_value in sscanf(page, "%u", &new_value).

    Signed-off-by: Heinrich Schuchardt
    [PM: subject prefix fix, description cleanup]
    Signed-off-by: Paul Moore

    Heinrich Schuchardt
     

23 Jan, 2016

1 commit

  • parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
    inode_foo(inode) being mutex_foo(&inode->i_mutex).

    Please, use those for access to ->i_mutex; over the coming cycle
    ->i_mutex will become rwsem, with ->lookup() done with it held
    only shared.

    Signed-off-by: Al Viro

    Al Viro
     

18 Jan, 2016

1 commit

  • Pull security subsystem updates from James Morris:

    - EVM gains support for loading an x509 cert from the kernel
    (EVM_LOAD_X509), into the EVM trusted kernel keyring.

    - Smack implements 'file receive' process-based permission checking for
    sockets, rather than just depending on inode checks.

    - Misc enhancments for TPM & TPM2.

    - Cleanups and bugfixes for SELinux, Keys, and IMA.

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (41 commits)
    selinux: Inode label revalidation performance fix
    KEYS: refcount bug fix
    ima: ima_write_policy() limit locking
    IMA: policy can be updated zero times
    selinux: rate-limit netlink message warnings in selinux_nlmsg_perm()
    selinux: export validatetrans decisions
    gfs2: Invalid security labels of inodes when they go invalid
    selinux: Revalidate invalid inode security labels
    security: Add hook to invalidate inode security labels
    selinux: Add accessor functions for inode->i_security
    security: Make inode argument of inode_getsecid non-const
    security: Make inode argument of inode_getsecurity non-const
    selinux: Remove unused variable in selinux_inode_init_security
    keys, trusted: seal with a TPM2 authorization policy
    keys, trusted: select hash algorithm for TPM2 chips
    keys, trusted: fix: *do not* allow duplicate key options
    tpm_ibmvtpm: properly handle interrupted packet receptions
    tpm_tis: Tighten IRQ auto-probing
    tpm_tis: Refactor the interrupt setup
    tpm_tis: Get rid of the duplicate IRQ probing code
    ...

    Linus Torvalds
     

04 Jan, 2016

1 commit

  • Nothing in there gives a damn about the buffer alignment - it
    just parses its contents. So the use of get_zeroed_page()
    doesn't buy us anything - might as well had been kmalloc(),
    which makes that code equivalent to open-coded memdup_user_nul()

    Signed-off-by: Al Viro

    Al Viro
     

25 Dec, 2015

1 commit

  • Make validatetrans decisions available through selinuxfs.
    "/validatetrans" is added to selinuxfs for this purpose.
    This functionality is needed by file system servers
    implemented in userspace or kernelspace without the VFS
    layer.

    Writing "$oldcontext $newcontext $tclass $taskcontext"
    to /validatetrans is expected to return 0 if the transition
    is allowed and -EPERM otherwise.

    Signed-off-by: Andrew Perepechko
    CC: andrew.perepechko@seagate.com
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Andrew Perepechko
     

22 Oct, 2015

1 commit

  • There seems to be a little confusion as to whether the scontext_len
    parameter of security_context_to_sid() includes the nul-byte or
    not. Reading security_context_to_sid_core(), it seems that the
    expectation is that it does not (both the string copying and the test
    for scontext_len being zero hint at that).

    Introduce the helper security_context_str_to_sid() to do the strlen()
    call and fix all callers.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Rasmus Villemoes
     

11 Sep, 2015

1 commit

  • With two exceptions (drm/qxl and drm/radeon) all vm_operations_struct
    structs should be constant.

    Signed-off-by: Kirill A. Shutemov
    Reviewed-by: Oleg Nesterov
    Cc: "H. Peter Anvin"
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: Ingo Molnar
    Cc: Minchan Kim
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kirill A. Shutemov
     

01 Jul, 2015

1 commit

  • This allows for better documentation in the code and
    it allows for a simpler and fully correct version of
    fs_fully_visible to be written.

    The mount points converted and their filesystems are:
    /sys/hypervisor/s390/ s390_hypfs
    /sys/kernel/config/ configfs
    /sys/kernel/debug/ debugfs
    /sys/firmware/efi/efivars/ efivarfs
    /sys/fs/fuse/connections/ fusectl
    /sys/fs/pstore/ pstore
    /sys/kernel/tracing/ tracefs
    /sys/fs/cgroup/ cgroup
    /sys/kernel/security/ securityfs
    /sys/fs/selinux/ selinuxfs
    /sys/fs/smackfs/ smackfs

    Cc: stable@vger.kernel.org
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

16 Apr, 2015

1 commit


27 Mar, 2015

1 commit


26 Mar, 2015

1 commit


26 Jan, 2015

1 commit


04 Nov, 2014

1 commit


04 Apr, 2014

1 commit

  • Pull security subsystem updates from James Morris:
    "Apart from reordering the SELinux mmap code to ensure DAC is called
    before MAC, these are minor maintenance updates"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (23 commits)
    selinux: correctly label /proc inodes in use before the policy is loaded
    selinux: put the mmap() DAC controls before the MAC controls
    selinux: fix the output of ./scripts/get_maintainer.pl for SELinux
    evm: enable key retention service automatically
    ima: skip memory allocation for empty files
    evm: EVM does not use MD5
    ima: return d_name.name if d_path fails
    integrity: fix checkpatch errors
    ima: fix erroneous removal of security.ima xattr
    security: integrity: Use a more current logging style
    MAINTAINERS: email updates and other misc. changes
    ima: reduce memory usage when a template containing the n field is used
    ima: restore the original behavior for sending data with ima template
    Integrity: Pass commname via get_task_comm()
    fs: move i_readcount
    ima: use static const char array definitions
    security: have cap_dentry_init_security return error
    ima: new helper: file_inode(file)
    kernel: Mark function as static in kernel/seccomp.c
    capability: Use current logging styles
    ...

    Linus Torvalds