09 Jul, 2019

1 commit

  • Pull integrity updates from Mimi Zohar:
    "Bug fixes, code clean up, and new features:

    - IMA policy rules can be defined in terms of LSM labels, making the
    IMA policy dependent on LSM policy label changes, in particular LSM
    label deletions. The new environment, in which IMA-appraisal is
    being used, frequently updates the LSM policy and permits LSM label
    deletions.

    - Prevent an mmap'ed shared file opened for write from also being
    mmap'ed execute. In the long term, making this and other similar
    changes at the VFS layer would be preferable.

    - The IMA per policy rule template format support is needed for a
    couple of new/proposed features (eg. kexec boot command line
    measurement, appended signatures, and VFS provided file hashes).

    - Other than the "boot-aggregate" record in the IMA measuremeent
    list, all other measurements are of file data. Measuring and
    storing the kexec boot command line in the IMA measurement list is
    the first buffer based measurement included in the measurement
    list"

    * 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity:
    integrity: Introduce struct evm_xattr
    ima: Update MAX_TEMPLATE_NAME_LEN to fit largest reasonable definition
    KEXEC: Call ima_kexec_cmdline to measure the boot command line args
    IMA: Define a new template field buf
    IMA: Define a new hook to measure the kexec boot command line arguments
    IMA: support for per policy rule template formats
    integrity: Fix __integrity_init_keyring() section mismatch
    ima: Use designated initializers for struct ima_event_data
    ima: use the lsm policy update notifier
    LSM: switch to blocking policy update notifiers
    x86/ima: fix the Kconfig dependency for IMA_ARCH_POLICY
    ima: Make arch_policy_entry static
    ima: prevent a file already mmap'ed write to be mmap'ed execute
    x86/ima: check EFI SetupMode too

    Linus Torvalds
     

14 Jun, 2019

1 commit

  • Atomic policy updaters are not very useful as they cannot
    usually perform the policy updates on their own. Since it
    seems that there is no strict need for the atomicity,
    switch to the blocking variant. While doing so, rename
    the functions accordingly.

    Signed-off-by: Janne Karhunen
    Acked-by: Paul Moore
    Acked-by: James Morris
    Signed-off-by: Mimi Zohar

    Janne Karhunen
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

08 May, 2019

1 commit

  • Pull mount ABI updates from Al Viro:
    "The syscalls themselves, finally.

    That's not all there is to that stuff, but switching individual
    filesystems to new methods is fortunately independent from everything
    else, so e.g. NFS series can go through NFS tree, etc.

    As those conversions get done, we'll be finally able to get rid of a
    bunch of duplication in fs/super.c introduced in the beginning of the
    entire thing. I expect that to be finished in the next window..."

    * 'work.mount-syscalls' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    vfs: Add a sample program for the new mount API
    vfs: syscall: Add fspick() to select a superblock for reconfiguration
    vfs: syscall: Add fsmount() to create a mount for a superblock
    vfs: syscall: Add fsconfig() for configuring and managing a context
    vfs: Implement logging through fs_context
    vfs: syscall: Add fsopen() to prepare for superblock creation
    Make anon_inodes unconditional
    teach move_mount(2) to work with OPEN_TREE_CLONE
    vfs: syscall: Add move_mount(2) to move mounts around
    vfs: syscall: Add open_tree(2) to reference or clone a mount

    Linus Torvalds
     

21 Mar, 2019

2 commits

  • This patch introduces a new security hook that is intended for
    initializing the security data for newly created kernfs nodes, which
    provide a way of storing a non-default security context, but need to
    operate independently from mounts (and therefore may not have an
    associated inode at the moment of creation).

    The main motivation is to allow kernfs nodes to inherit the context of
    the parent under SELinux, similar to the behavior of
    security_inode_init_security(). Other LSMs may implement their own logic
    for handling the creation of new nodes.

    This patch also adds helper functions to for
    getting/setting security xattrs of a kernfs node so that LSMs hooks are
    able to do their job. Other important attributes should be accessible
    direcly in the kernfs_node fields (in case there is need for more, then
    new helpers should be added to kernfs.h along with the patch that needs
    them).

    Signed-off-by: Ondrej Mosnacek
    Acked-by: Casey Schaufler
    [PM: more manual merge fixes]
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     
  • Add a move_mount() system call that will move a mount from one place to
    another and, in the next commit, allow to attach an unattached mount tree.

    The new system call looks like the following:

    int move_mount(int from_dfd, const char *from_path,
    int to_dfd, const char *to_path,
    unsigned int flags);

    Signed-off-by: David Howells
    cc: linux-api@vger.kernel.org
    Signed-off-by: Al Viro

    David Howells
     

13 Mar, 2019

1 commit

  • Pull vfs mount infrastructure updates from Al Viro:
    "The rest of core infrastructure; no new syscalls in that pile, but the
    old parts are switched to new infrastructure. At that point
    conversions of individual filesystems can happen independently; some
    are done here (afs, cgroup, procfs, etc.), there's also a large series
    outside of that pile dealing with NFS (quite a bit of option-parsing
    stuff is getting used there - it's one of the most convoluted
    filesystems in terms of mount-related logics), but NFS bits are the
    next cycle fodder.

    It got seriously simplified since the last cycle; documentation is
    probably the weakest bit at the moment - I considered dropping the
    commit introducing Documentation/filesystems/mount_api.txt (cutting
    the size increase by quarter ;-), but decided that it would be better
    to fix it up after -rc1 instead.

    That pile allows to do followup work in independent branches, which
    should make life much easier for the next cycle. fs/super.c size
    increase is unpleasant; there's a followup series that allows to
    shrink it considerably, but I decided to leave that until the next
    cycle"

    * 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (41 commits)
    afs: Use fs_context to pass parameters over automount
    afs: Add fs_context support
    vfs: Add some logging to the core users of the fs_context log
    vfs: Implement logging through fs_context
    vfs: Provide documentation for new mount API
    vfs: Remove kern_mount_data()
    hugetlbfs: Convert to fs_context
    cpuset: Use fs_context
    kernfs, sysfs, cgroup, intel_rdt: Support fs_context
    cgroup: store a reference to cgroup_ns into cgroup_fs_context
    cgroup1_get_tree(): separate "get cgroup_root to use" into a separate helper
    cgroup_do_mount(): massage calling conventions
    cgroup: stash cgroup_root reference into cgroup_fs_context
    cgroup2: switch to option-by-option parsing
    cgroup1: switch to option-by-option parsing
    cgroup: take options parsing into ->parse_monolithic()
    cgroup: fold cgroup1_mount() into cgroup1_get_tree()
    cgroup: start switching to fs_context
    ipc: Convert mqueue fs to fs_context
    proc: Add fs_context support to procfs
    ...

    Linus Torvalds
     

08 Mar, 2019

1 commit

  • Pull audit updates from Paul Moore:
    "A lucky 13 audit patches for v5.1.

    Despite the rather large diffstat, most of the changes are from two
    bug fix patches that move code from one Kconfig option to another.

    Beyond that bit of churn, the remaining changes are largely cleanups
    and bug-fixes as we slowly march towards container auditing. It isn't
    all boring though, we do have a couple of new things: file
    capabilities v3 support, and expanded support for filtering on
    filesystems to solve problems with remote filesystems.

    All changes pass the audit-testsuite. Please merge for v5.1"

    * tag 'audit-pr-20190305' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
    audit: mark expected switch fall-through
    audit: hide auditsc_get_stamp and audit_serial prototypes
    audit: join tty records to their syscall
    audit: remove audit_context when CONFIG_ AUDIT and not AUDITSYSCALL
    audit: remove unused actx param from audit_rule_match
    audit: ignore fcaps on umount
    audit: clean up AUDITSYSCALL prototypes and stubs
    audit: more filter PATH records keyed on filesystem magic
    audit: add support for fcaps v3
    audit: move loginuid and sessionid from CONFIG_AUDITSYSCALL to CONFIG_AUDIT
    audit: add syscall information to CONFIG_CHANGE records
    audit: hand taken context to audit_kill_trees for syscall logging
    audit: give a clue what CONFIG_CHANGE op was involved

    Linus Torvalds
     

28 Feb, 2019

2 commits

  • new primitive: vfs_dup_fs_context(). Comes with fs_context
    method (->dup()) for copying the filesystem-specific parts
    of fs_context, along with LSM one (->fs_context_dup()) for
    doing the same to LSM parts.

    [needs better commit message, and change of Author:, anyway]

    Signed-off-by: Al Viro

    Al Viro
     
  • Add LSM hooks for use by the new mount API and filesystem context code.
    This includes:

    (1) Hooks to handle allocation, duplication and freeing of the security
    record attached to a filesystem context.

    (2) A hook to snoop source specifications. There may be multiple of these
    if the filesystem supports it. They will to be local files/devices if
    fs_context::source_is_dev is true and will be something else, possibly
    remote server specifications, if false.

    (3) A hook to snoop superblock configuration options in key[=val] form.
    If the LSM decides it wants to handle it, it can suppress the option
    being passed to the filesystem. Note that 'val' may include commas
    and binary data with the fsopen patch.

    (4) A hook to perform validation and allocation after the configuration
    has been done but before the superblock is allocated and set up.

    (5) A hook to transfer the security from the context to a newly created
    superblock.

    (6) A hook to rule on whether a path point can be used as a mountpoint.

    These are intended to replace:

    security_sb_copy_data
    security_sb_kern_mount
    security_sb_mount
    security_sb_set_mnt_opts
    security_sb_clone_mnt_opts
    security_sb_parse_opts_str

    [AV -- some of the methods being replaced are already gone, some of the
    methods are not added for the lack of need]

    Signed-off-by: David Howells
    cc: linux-security-module@vger.kernel.org
    Signed-off-by: Al Viro

    David Howells
     

26 Feb, 2019

1 commit

  • To avoid potential confusion, explicitly ignore "security=" when "lsm=" is
    used on the command line, and report that it is happening.

    Suggested-by: Tetsuo Handa
    Signed-off-by: Kees Cook
    Acked-by: Casey Schaufler
    Acked-by: John Johansen
    Signed-off-by: James Morris

    Kees Cook
     

01 Feb, 2019

1 commit

  • The audit_rule_match() struct audit_context *actx parameter is not used
    by any in-tree consumers (selinux, apparmour, integrity, smack).

    The audit context is an internal audit structure that should only be
    accessed by audit accessor functions.

    It was part of commit 03d37d25e0f9 ("LSM/Audit: Introduce generic
    Audit LSM hooks") but appears to have never been used.

    Remove it.

    Please see the github issue
    https://github.com/linux-audit/audit-kernel/issues/107

    Signed-off-by: Richard Guy Briggs
    [PM: fixed the referenced commit title]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

23 Jan, 2019

1 commit


19 Jan, 2019

2 commits

  • Fixes the following sparse warnings:

    security/security.c:533:5: warning:
    symbol 'lsm_task_alloc' was not declared. Should it be static?
    security/security.c:554:5: warning:
    symbol 'lsm_ipc_alloc' was not declared. Should it be static?
    security/security.c:575:5: warning:
    symbol 'lsm_msg_msg_alloc' was not declared. Should it be static?

    Fixes: f4ad8f2c4076 ("LSM: Infrastructure management of the task security")
    Signed-off-by: Wei Yongjun
    Acked-by: Casey Schaufler
    Signed-off-by: James Morris

    Wei Yongjun
     
  • Since current->cred == current->real_cred when ordered_lsm_init()
    is called, and lsm_early_cred()/lsm_early_task() need to be called
    between the amount of required bytes is determined and module specific
    initialization function is called, we can move these calls from
    individual modules to ordered_lsm_init().

    Signed-off-by: Tetsuo Handa
    Acked-by: Casey Schaufler
    Signed-off-by: James Morris

    Tetsuo Handa
     

17 Jan, 2019

1 commit

  • From: Casey Schaufler

    Check that the cred security blob has been set before trying
    to clean it up. There is a case during credential initialization
    that could result in this.

    Signed-off-by: Casey Schaufler
    Acked-by: John Johansen
    Signed-off-by: James Morris
    Reported-by: syzbot+69ca07954461f189e808@syzkaller.appspotmail.com

    James Morris
     

11 Jan, 2019

1 commit

  • This patch provides a general mechanism for passing flags to the
    security_capable LSM hook. It replaces the specific 'audit' flag that is
    used to tell security_capable whether it should log an audit message for
    the given capability check. The reason for generalizing this flag
    passing is so we can add an additional flag that signifies whether
    security_capable is being called by a setid syscall (which is needed by
    the proposed SafeSetID LSM).

    Signed-off-by: Micah Morton
    Reviewed-by: Kees Cook
    Signed-off-by: James Morris

    Micah Morton
     

09 Jan, 2019

21 commits

  • Move management of the kern_ipc_perm->security and
    msg_msg->security blobs out of the individual security
    modules and into the security infrastructure. Instead
    of allocating the blobs from within the modules the modules
    tell the infrastructure how much space is required, and
    the space is allocated there.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    [kees: adjusted for ordered init series]
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • Move management of the task_struct->security blob out
    of the individual security modules and into the security
    infrastructure. Instead of allocating the blobs from within
    the modules the modules tell the infrastructure how much
    space is required, and the space is allocated there.
    The only user of this blob is AppArmor. The AppArmor use
    is abstracted to avoid future conflict.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    [kees: adjusted for ordered init series]
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • Move management of the inode->i_security blob out
    of the individual security modules and into the security
    infrastructure. Instead of allocating the blobs from within
    the modules the modules tell the infrastructure how much
    space is required, and the space is allocated there.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    [kees: adjusted for ordered init series]
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • Move management of the file->f_security blob out of the
    individual security modules and into the infrastructure.
    The modules no longer allocate or free the data, instead
    they tell the infrastructure how much space they require.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    [kees: adjusted for ordered init series]
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • Move management of the cred security blob out of the
    security modules and into the security infrastructre.
    Instead of allocating and freeing space the security
    modules tell the infrastructure how much space they
    require.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    [kees: adjusted for ordered init series]
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • Back in 2007 I made what turned out to be a rather serious
    mistake in the implementation of the Smack security module.
    The SELinux module used an interface in /proc to manipulate
    the security context on processes. Rather than use a similar
    interface, I used the same interface. The AppArmor team did
    likewise. Now /proc/.../attr/current will tell you the
    security "context" of the process, but it will be different
    depending on the security module you're using.

    This patch provides a subdirectory in /proc/.../attr for
    Smack. Smack user space can use the "current" file in
    this subdirectory and never have to worry about getting
    SELinux attributes by mistake. Programs that use the
    old interface will continue to work (or fail, as the case
    may be) as before.

    The proposed S.A.R.A security module is dependent on
    the mechanism to create its own attr subdirectory.

    The original implementation is by Kees Cook.

    Signed-off-by: Casey Schaufler
    Reviewed-by: Kees Cook
    Signed-off-by: Kees Cook

    Casey Schaufler
     
  • This converts capabilities to use the new LSM_ORDER_FIRST position.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler

    Kees Cook
     
  • In preparation for distinguishing the "capability" LSM from other LSMs, it
    must be ordered first. This introduces LSM_ORDER_MUTABLE for the general
    LSMs and LSM_ORDER_FIRST for capability. In the future LSM_ORDER_LAST
    for could be added for anything that must run last (e.g. Landlock may
    use this).

    Signed-off-by: Kees Cook

    Kees Cook
     
  • This converts Yama from being a direct "minor" LSM into an ordered LSM.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler

    Kees Cook
     
  • This converts LoadPin from being a direct "minor" LSM into an ordered LSM.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler

    Kees Cook
     
  • Since we already have to do a pass through the LSMs to figure out if
    exclusive LSMs should be disabled after the first one is seen as enabled,
    this splits the logic up a bit more cleanly. Now we do a full "prepare"
    pass through the LSMs (which also allows for later use by the blob-sharing
    code), before starting the LSM initialization pass.

    Signed-off-by: Kees Cook

    Kees Cook
     
  • This removes CONFIG_DEFAULT_SECURITY in favor of the explicit ordering
    offered by CONFIG_LSM and adds all the exclusive LSMs to the ordered
    LSM initialization. The old meaning of CONFIG_DEFAULT_SECURITY is now
    captured by which exclusive LSM is listed first in the LSM order. All
    LSMs not added to the ordered list are explicitly disabled.

    Signed-off-by: Kees Cook
    Signed-off-by: Casey Schaufler

    Casey Schaufler
     
  • In order to both support old "security=" Legacy Major LSM selection, and
    handling real exclusivity, this creates LSM_FLAG_EXCLUSIVE and updates
    the selection logic to handle them.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler

    Kees Cook
     
  • For what are marked as the Legacy Major LSMs, make them effectively
    exclusive when selected on the "security=" boot parameter, to handle
    the future case of when a previously major LSMs become non-exclusive
    (e.g. when TOMOYO starts blob-sharing).

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler

    Kees Cook
     
  • This moves the string handling for "security=" boot parameter into
    a stored pointer instead of a string duplicate. This will allow
    easier handling of the string when switching logic to use the coming
    enable/disable infrastructure.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler
    Reviewed-by: John Johansen

    Kees Cook
     
  • Until now, any LSM without an enable storage variable was considered
    enabled. This inverts the logic and sets defaults to true only if the
    LSM gets added to the ordered initialization list. (And an exception
    continues for the major LSMs until they are integrated into the ordered
    initialization in a later patch.)

    Signed-off-by: Kees Cook

    Kees Cook
     
  • Provide a way to explicitly choose LSM initialization order via the new
    "lsm=" comma-separated list of LSMs.

    Signed-off-by: Kees Cook

    Kees Cook
     
  • This provides a way to declare LSM initialization order via the new
    CONFIG_LSM. Currently only non-major LSMs are recognized. This will
    be expanded in future patches.

    Signed-off-by: Kees Cook

    Kees Cook
     
  • This constructs an ordered list of LSMs to initialize, using a hard-coded
    list of only "integrity": minor LSMs continue to have direct hook calls,
    and major LSMs continue to initialize separately.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler

    Kees Cook
     
  • As a prerequisite to adjusting LSM selection logic in the future, this
    moves the selection logic up out of the individual major LSMs, making
    their init functions only run when actually enabled. This considers all
    LSMs enabled by default unless they specified an external "enable"
    variable.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler
    Reviewed-by: John Johansen

    Kees Cook
     
  • This provides a place for ordered LSMs to be initialized, separate from
    the "major" LSMs. This is mainly a copy/paste from major_lsm_init() to
    ordered_lsm_init(), but it will change drastically in later patches.

    What is not obvious in the patch is that this change moves the integrity
    LSM from major_lsm_init() into ordered_lsm_init(), since it is not marked
    with the LSM_FLAG_LEGACY_MAJOR. As it is the only LSM in the "ordered"
    list, there is no reordering yet created.

    Signed-off-by: Kees Cook
    Reviewed-by: Casey Schaufler
    Reviewed-by: John Johansen

    Kees Cook
     

06 Jan, 2019

1 commit

  • Pull vfs mount API prep from Al Viro:
    "Mount API prereqs.

    Mostly that's LSM mount options cleanups. There are several minor
    fixes in there, but nothing earth-shattering (leaks on failure exits,
    mostly)"

    * 'mount.part1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (27 commits)
    mount_fs: suppress MAC on MS_SUBMOUNT as well as MS_KERNMOUNT
    smack: rewrite smack_sb_eat_lsm_opts()
    smack: get rid of match_token()
    smack: take the guts of smack_parse_opts_str() into a new helper
    LSM: new method: ->sb_add_mnt_opt()
    selinux: rewrite selinux_sb_eat_lsm_opts()
    selinux: regularize Opt_... names a bit
    selinux: switch away from match_token()
    selinux: new helper - selinux_add_opt()
    LSM: bury struct security_mnt_opts
    smack: switch to private smack_mnt_opts
    selinux: switch to private struct selinux_mnt_opts
    LSM: hide struct security_mnt_opts from any generic code
    selinux: kill selinux_sb_get_mnt_opts()
    LSM: turn sb_eat_lsm_opts() into a method
    nfs_remount(): don't leak, don't ignore LSM options quietly
    btrfs: sanitize security_mnt_opts use
    selinux; don't open-code a loop in sb_finish_set_opts()
    LSM: split ->sb_set_mnt_opts() out of ->sb_kern_mount()
    new helper: security_sb_eat_lsm_opts()
    ...

    Linus Torvalds
     

22 Dec, 2018

1 commit

  • Adding options to growing mnt_opts. NFS kludge with passing
    context= down into non-text-options mount switched to it, and
    with that the last use of ->sb_parse_opts_str() is gone.

    Reviewed-by: David Howells
    Signed-off-by: Al Viro

    Al Viro