07 Aug, 2020

1 commit

  • Rationale:
    Reduces attack surface on kernel devs opening the links for MITM
    as HTTPS traffic is much harder to manipulate.

    Deterministic algorithm:
    For each file:
    If not .svg:
    For each line:
    If doesn't contain `\bxmlns\b`:
    For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
    If both the HTTP and HTTPS versions
    return 200 OK and serve the same content:
    Replace HTTP with HTTPS.

    Signed-off-by: Alexander A. Klimov
    Acked-by: John Johansen
    Signed-off-by: James Morris

    Alexander A. Klimov
     

30 Mar, 2020

1 commit

  • * The hooks are initialized using the definitions in
    include/linux/lsm_hook_defs.h.
    * The LSM can be enabled / disabled with CONFIG_BPF_LSM.

    Signed-off-by: KP Singh
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Brendan Jackman
    Reviewed-by: Florent Revest
    Acked-by: Kees Cook
    Acked-by: James Morris
    Link: https://lore.kernel.org/bpf/20200329004356.27286-6-kpsingh@chromium.org

    KP Singh
     

28 Sep, 2019

1 commit

  • Pull kernel lockdown mode from James Morris:
    "This is the latest iteration of the kernel lockdown patchset, from
    Matthew Garrett, David Howells and others.

    From the original description:

    This patchset introduces an optional kernel lockdown feature,
    intended to strengthen the boundary between UID 0 and the kernel.
    When enabled, various pieces of kernel functionality are restricted.
    Applications that rely on low-level access to either hardware or the
    kernel may cease working as a result - therefore this should not be
    enabled without appropriate evaluation beforehand.

    The majority of mainstream distributions have been carrying variants
    of this patchset for many years now, so there's value in providing a
    doesn't meet every distribution requirement, but gets us much closer
    to not requiring external patches.

    There are two major changes since this was last proposed for mainline:

    - Separating lockdown from EFI secure boot. Background discussion is
    covered here: https://lwn.net/Articles/751061/

    - Implementation as an LSM, with a default stackable lockdown LSM
    module. This allows the lockdown feature to be policy-driven,
    rather than encoding an implicit policy within the mechanism.

    The new locked_down LSM hook is provided to allow LSMs to make a
    policy decision around whether kernel functionality that would allow
    tampering with or examining the runtime state of the kernel should be
    permitted.

    The included lockdown LSM provides an implementation with a simple
    policy intended for general purpose use. This policy provides a coarse
    level of granularity, controllable via the kernel command line:

    lockdown={integrity|confidentiality}

    Enable the kernel lockdown feature. If set to integrity, kernel features
    that allow userland to modify the running kernel are disabled. If set to
    confidentiality, kernel features that allow userland to extract
    confidential information from the kernel are also disabled.

    This may also be controlled via /sys/kernel/security/lockdown and
    overriden by kernel configuration.

    New or existing LSMs may implement finer-grained controls of the
    lockdown features. Refer to the lockdown_reason documentation in
    include/linux/security.h for details.

    The lockdown feature has had signficant design feedback and review
    across many subsystems. This code has been in linux-next for some
    weeks, with a few fixes applied along the way.

    Stephen Rothwell noted that commit 9d1f8be5cf42 ("bpf: Restrict bpf
    when kernel lockdown is in confidentiality mode") is missing a
    Signed-off-by from its author. Matthew responded that he is providing
    this under category (c) of the DCO"

    * 'next-lockdown' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (31 commits)
    kexec: Fix file verification on S390
    security: constify some arrays in lockdown LSM
    lockdown: Print current->comm in restriction messages
    efi: Restrict efivar_ssdt_load when the kernel is locked down
    tracefs: Restrict tracefs when the kernel is locked down
    debugfs: Restrict debugfs when the kernel is locked down
    kexec: Allow kexec_file() with appropriate IMA policy when locked down
    lockdown: Lock down perf when in confidentiality mode
    bpf: Restrict bpf when kernel lockdown is in confidentiality mode
    lockdown: Lock down tracing and perf kprobes when in confidentiality mode
    lockdown: Lock down /proc/kcore
    x86/mmiotrace: Lock down the testmmiotrace module
    lockdown: Lock down module params that specify hardware parameters (eg. ioport)
    lockdown: Lock down TIOCSSERIAL
    lockdown: Prohibit PCMCIA CIS storage when the kernel is locked down
    acpi: Disable ACPI table override if the kernel is locked down
    acpi: Ignore acpi_rsdp kernel param when the kernel has been locked down
    ACPI: Limit access to custom_method when the kernel is locked down
    x86/msr: Restrict MSR access when the kernel is locked down
    x86: Lock down IO port access when the kernel is locked down
    ...

    Linus Torvalds
     

20 Aug, 2019

1 commit

  • While existing LSMs can be extended to handle lockdown policy,
    distributions generally want to be able to apply a straightforward
    static policy. This patch adds a simple LSM that can be configured to
    reject either integrity or all lockdown queries, and can be configured
    at runtime (through securityfs), boot time (via a kernel parameter) or
    build time (via a kconfig option). Based on initial code by David
    Howells.

    Signed-off-by: Matthew Garrett
    Reviewed-by: Kees Cook
    Cc: David Howells
    Signed-off-by: James Morris

    Matthew Garrett
     

15 Jul, 2019

1 commit


15 Jun, 2019

1 commit


09 Jun, 2019

1 commit

  • Mostly due to x86 and acpi conversion, several documentation
    links are still pointing to the old file. Fix them.

    Signed-off-by: Mauro Carvalho Chehab
    Reviewed-by: Wolfram Sang
    Reviewed-by: Sven Van Asbroeck
    Reviewed-by: Bhupesh Sharma
    Acked-by: Mark Brown
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

21 May, 2019

1 commit


08 May, 2019

1 commit

  • Pull compiler-based variable initialization updates from Kees Cook:
    "This is effectively part of my gcc-plugins tree, but as this adds some
    Clang support, it felt weird to still call it "gcc-plugins". :)

    This consolidates Kconfig for the existing stack variable
    initialization (via structleak and stackleak gcc plugins) and adds
    Alexander Potapenko's support for Clang's new similar functionality.

    Summary:

    - Consolidate memory initialization Kconfigs (Kees)

    - Implement support for Clang's stack variable auto-init (Alexander)"

    * tag 'meminit-v5.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
    security: Implement Clang's stack initialization
    security: Move stackleak config to Kconfig.hardening
    security: Create "kernel hardening" config area

    Linus Torvalds
     

25 Apr, 2019

1 commit

  • Right now kernel hardening options are scattered around various Kconfig
    files. This can be a central place to collect these kinds of options
    going forward. This is initially populated with the memory initialization
    options from the gcc-plugins.

    Signed-off-by: Kees Cook
    Acked-by: Masahiro Yamada

    Kees Cook
     

30 Mar, 2019

1 commit

  • Commit 70b62c25665f636c ("LoadPin: Initialize as ordered LSM") removed
    CONFIG_DEFAULT_SECURITY_{SELINUX,SMACK,TOMOYO,APPARMOR,DAC} from
    security/Kconfig and changed CONFIG_LSM to provide a fixed ordering as a
    default value. That commit expected that existing users (upgrading from
    Linux 5.0 and earlier) will edit CONFIG_LSM value in accordance with
    their CONFIG_DEFAULT_SECURITY_* choice in their old kernel configs. But
    since users might forget to edit CONFIG_LSM value, this patch revives
    the choice (only for providing the default value for CONFIG_LSM) in order
    to make sure that CONFIG_LSM reflects CONFIG_DEFAULT_SECURITY_* from their
    old kernel configs.

    Note that since TOMOYO can be fully stacked against the other legacy
    major LSMs, when it is selected, it explicitly disables the other LSMs
    to avoid them also initializing since TOMOYO does not expect this
    currently.

    Reported-by: Jakub Kicinski
    Reported-by: Randy Dunlap
    Fixes: 70b62c25665f636c ("LoadPin: Initialize as ordered LSM")
    Co-developed-by: Tetsuo Handa
    Signed-off-by: Tetsuo Handa
    Signed-off-by: Kees Cook
    Acked-by: Casey Schaufler
    Signed-off-by: James Morris

    Kees Cook
     

02 Mar, 2019

1 commit


26 Jan, 2019

1 commit

  • SafeSetID gates the setid family of syscalls to restrict UID/GID
    transitions from a given UID/GID to only those approved by a
    system-wide whitelist. These restrictions also prohibit the given
    UIDs/GIDs from obtaining auxiliary privileges associated with
    CAP_SET{U/G}ID, such as allowing a user to set up user namespace UID
    mappings. For now, only gating the set*uid family of syscalls is
    supported, with support for set*gid coming in a future patch set.

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

    Micah Morton
     

09 Jan, 2019

4 commits


21 Dec, 2018

1 commit

  • The Kconfig lexer supports special characters such as '.' and '/' in
    the parameter context. In my understanding, the reason is just to
    support bare file paths in the source statement.

    I do not see a good reason to complicate Kconfig for the room of
    ambiguity.

    The majority of code already surrounds file paths with double quotes,
    and it makes sense since file paths are constant string literals.

    Make it treewide consistent now.

    Signed-off-by: Masahiro Yamada
    Acked-by: Wolfram Sang
    Acked-by: Geert Uytterhoeven
    Acked-by: Ingo Molnar

    Masahiro Yamada
     

14 Sep, 2018

1 commit

  • This reverts commit 1f40a46cf47c12d93a5ad9dccd82bd36ff8f956a.

    It turned out that this patch is not sufficient to enable PTI on 32 bit
    systems with legacy 2-level page-tables. In this paging mode the huge-page
    PTEs are in the top-level page-table directory, where also the mirroring to
    the user-space page-table happens. So every huge PTE exits twice, in the
    kernel and in the user page-table.

    That means that accessed/dirty bits need to be fetched from two PTEs in
    this mode to be safe, but this is not trivial to implement because it needs
    changes to generic code just for the sake of enabling PTI with 32-bit
    legacy paging. As all systems that need PTI should support PAE anyway,
    remove support for PTI when 32-bit legacy paging is used.

    Fixes: 7757d607c6b3 ('x86/pti: Allow CONFIG_PAGE_TABLE_ISOLATION for x86_32')
    Reported-by: Meelis Roos
    Signed-off-by: Joerg Roedel
    Signed-off-by: Thomas Gleixner
    Cc: hpa@zytor.com
    Cc: linux-mm@kvack.org
    Cc: Linus Torvalds
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: Borislav Petkov
    Cc: Andrea Arcangeli
    Link: https://lkml.kernel.org/r/1536922754-31379-1-git-send-email-joro@8bytes.org

    Joerg Roedel
     

15 Aug, 2018

1 commit

  • Pull hardened usercopy updates from Kees Cook:
    "This cleans up a minor Kconfig issue and adds a kernel boot option for
    disabling hardened usercopy for distro users that may have corner-case
    performance issues (e.g. high bandwidth small-packet UDP traffic).

    Summary:

    - drop unneeded Kconfig "select BUG" (Kamal Mostafa)

    - add "hardened_usercopy=off" rare performance needs (Chris von
    Recklinghausen)"

    * tag 'hardened-usercopy-v4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
    usercopy: Allow boot cmdline disabling of hardening
    usercopy: Do not select BUG with HARDENED_USERCOPY

    Linus Torvalds
     

20 Jul, 2018

1 commit

  • Allow PTI to be compiled on x86_32.

    Signed-off-by: Joerg Roedel
    Signed-off-by: Thomas Gleixner
    Tested-by: Pavel Machek
    Cc: "H . Peter Anvin"
    Cc: linux-mm@kvack.org
    Cc: Linus Torvalds
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: Josh Poimboeuf
    Cc: Juergen Gross
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Jiri Kosina
    Cc: Boris Ostrovsky
    Cc: Brian Gerst
    Cc: David Laight
    Cc: Denys Vlasenko
    Cc: Eduardo Valentin
    Cc: Greg KH
    Cc: Will Deacon
    Cc: aliguori@amazon.com
    Cc: daniel.gruss@iaik.tugraz.at
    Cc: hughd@google.com
    Cc: keescook@google.com
    Cc: Andrea Arcangeli
    Cc: Waiman Long
    Cc: "David H . Gutteridge"
    Cc: joro@8bytes.org
    Link: https://lkml.kernel.org/r/1531906876-13451-38-git-send-email-joro@8bytes.org

    Joerg Roedel
     

03 Jul, 2018

1 commit


04 Feb, 2018

1 commit

  • Pull hardened usercopy whitelisting from Kees Cook:
    "Currently, hardened usercopy performs dynamic bounds checking on slab
    cache objects. This is good, but still leaves a lot of kernel memory
    available to be copied to/from userspace in the face of bugs.

    To further restrict what memory is available for copying, this creates
    a way to whitelist specific areas of a given slab cache object for
    copying to/from userspace, allowing much finer granularity of access
    control.

    Slab caches that are never exposed to userspace can declare no
    whitelist for their objects, thereby keeping them unavailable to
    userspace via dynamic copy operations. (Note, an implicit form of
    whitelisting is the use of constant sizes in usercopy operations and
    get_user()/put_user(); these bypass all hardened usercopy checks since
    these sizes cannot change at runtime.)

    This new check is WARN-by-default, so any mistakes can be found over
    the next several releases without breaking anyone's system.

    The series has roughly the following sections:
    - remove %p and improve reporting with offset
    - prepare infrastructure and whitelist kmalloc
    - update VFS subsystem with whitelists
    - update SCSI subsystem with whitelists
    - update network subsystem with whitelists
    - update process memory with whitelists
    - update per-architecture thread_struct with whitelists
    - update KVM with whitelists and fix ioctl bug
    - mark all other allocations as not whitelisted
    - update lkdtm for more sensible test overage"

    * tag 'usercopy-v4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (38 commits)
    lkdtm: Update usercopy tests for whitelisting
    usercopy: Restrict non-usercopy caches to size 0
    kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl
    kvm: whitelist struct kvm_vcpu_arch
    arm: Implement thread_struct whitelist for hardened usercopy
    arm64: Implement thread_struct whitelist for hardened usercopy
    x86: Implement thread_struct whitelist for hardened usercopy
    fork: Provide usercopy whitelisting for task_struct
    fork: Define usercopy region in thread_stack slab caches
    fork: Define usercopy region in mm_struct slab caches
    net: Restrict unwhitelisted proto caches to size 0
    sctp: Copy struct sctp_sock.autoclose to userspace using put_user()
    sctp: Define usercopy region in SCTP proto slab cache
    caif: Define usercopy region in caif proto slab cache
    ip: Define usercopy region in IP proto slab cache
    net: Define usercopy region in struct proto slab cache
    scsi: Define usercopy region in scsi_sense_cache slab cache
    cifs: Define usercopy region in cifs_request slab cache
    vxfs: Define usercopy region in vxfs_inode slab cache
    ufs: Define usercopy region in ufs_inode_cache slab cache
    ...

    Linus Torvalds
     

02 Feb, 2018

1 commit

  • Pull char/misc driver updates from Greg KH:
    "Here is the big pull request for char/misc drivers for 4.16-rc1.

    There's a lot of stuff in here. Three new driver subsystems were added
    for various types of hardware busses:

    - siox
    - slimbus
    - soundwire

    as well as a new vboxguest subsystem for the VirtualBox hypervisor
    drivers.

    There's also big updates from the FPGA subsystem, lots of Android
    binder fixes, the usual handful of hyper-v updates, and lots of other
    smaller driver updates.

    All of these have been in linux-next for a long time, with no reported
    issues"

    * tag 'char-misc-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (155 commits)
    char: lp: use true or false for boolean values
    android: binder: use VM_ALLOC to get vm area
    android: binder: Use true and false for boolean values
    lkdtm: fix handle_irq_event symbol for INT_HW_IRQ_EN
    EISA: Delete error message for a failed memory allocation in eisa_probe()
    EISA: Whitespace cleanup
    misc: remove AVR32 dependencies
    virt: vbox: Add error mapping for VERR_INVALID_NAME and VERR_NO_MORE_FILES
    soundwire: Fix a signedness bug
    uio_hv_generic: fix new type mismatch warnings
    uio_hv_generic: fix type mismatch warnings
    auxdisplay: img-ascii-lcd: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
    uio_hv_generic: add rescind support
    uio_hv_generic: check that host supports monitor page
    uio_hv_generic: create send and receive buffers
    uio: document uio_hv_generic regions
    doc: fix documentation about uio_hv_generic
    vmbus: add monitor_id and subchannel_id to sysfs per channel
    vmbus: fix ABI documentation
    uio_hv_generic: use ISR callback method
    ...

    Linus Torvalds
     

16 Jan, 2018

1 commit

  • This introduces CONFIG_HARDENED_USERCOPY_FALLBACK to control the
    behavior of hardened usercopy whitelist violations. By default, whitelist
    violations will continue to WARN() so that any bad or missing usercopy
    whitelists can be discovered without being too disruptive.

    If this config is disabled at build time or a system is booted with
    "slab_common.usercopy_fallback=0", usercopy whitelists will BUG() instead
    of WARN(). This is useful for admins that want to use usercopy whitelists
    immediately.

    Suggested-by: Matthew Garrett
    Signed-off-by: Kees Cook

    Kees Cook
     

14 Jan, 2018

1 commit

  • When the config option for PTI was added a reference to documentation was
    added as well. But the documentation did not exist at that point. The final
    documentation has a different file name.

    Fix it up to point to the proper file.

    Fixes: 385ce0ea ("x86/mm/pti: Add Kconfig")
    Signed-off-by: W. Trevor King
    Signed-off-by: Thomas Gleixner
    Cc: Dave Hansen
    Cc: linux-mm@kvack.org
    Cc: linux-security-module@vger.kernel.org
    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/3009cc8ccbddcd897ec1e0cb6dda524929de0d14.1515799398.git.wking@tremily.us

    W. Trevor King
     

03 Jan, 2018

1 commit


02 Jan, 2018

1 commit


24 Dec, 2017

1 commit

  • Finally allow CONFIG_PAGE_TABLE_ISOLATION to be enabled.

    PARAVIRT generally requires that the kernel not manage its own page tables.
    It also means that the hypervisor and kernel must agree wholeheartedly
    about what format the page tables are in and what they contain.
    PAGE_TABLE_ISOLATION, unfortunately, changes the rules and they
    can not be used together.

    I've seen conflicting feedback from maintainers lately about whether they
    want the Kconfig magic to go first or last in a patch series. It's going
    last here because the partially-applied series leads to kernels that can
    not boot in a bunch of cases. I did a run through the entire series with
    CONFIG_PAGE_TABLE_ISOLATION=y to look for build errors, though.

    [ tglx: Removed SMP and !PARAVIRT dependencies as they not longer exist ]

    Signed-off-by: Dave Hansen
    Signed-off-by: Thomas Gleixner
    Cc: Andy Lutomirski
    Cc: Boris Ostrovsky
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: David Laight
    Cc: Denys Vlasenko
    Cc: Eduardo Valentin
    Cc: Greg KH
    Cc: H. Peter Anvin
    Cc: Josh Poimboeuf
    Cc: Juergen Gross
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Will Deacon
    Cc: aliguori@amazon.com
    Cc: daniel.gruss@iaik.tugraz.at
    Cc: hughd@google.com
    Cc: keescook@google.com
    Cc: linux-mm@kvack.org
    Signed-off-by: Ingo Molnar

    Dave Hansen
     

18 Dec, 2017

1 commit

  • As done for /proc/kcore in

    commit df04abfd181a ("fs/proc/kcore.c: Add bounce buffer for ktext data")

    this adds a bounce buffer when reading memory via /dev/mem. This
    is needed to allow kernel text memory to be read out when built with
    CONFIG_HARDENED_USERCOPY (which refuses to read out kernel text) and
    without CONFIG_STRICT_DEVMEM (which would have refused to read any RAM
    contents at all).

    Since this build configuration isn't common (most systems with
    CONFIG_HARDENED_USERCOPY also have CONFIG_STRICT_DEVMEM), this also tries
    to inform Kconfig about the recommended settings.

    This patch is modified from Brad Spengler/PaX Team's changes to /dev/mem
    code in the last public patch of grsecurity/PaX based on my understanding
    of the code. Changes or omissions from the original code are mine and
    don't reflect the original grsecurity/PaX code.

    Reported-by: Michael Holzheu
    Fixes: f5509cc18daa ("mm: Hardened usercopy")
    Signed-off-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     

13 Jul, 2017

1 commit

  • This adds support for compiling with a rough equivalent to the glibc
    _FORTIFY_SOURCE=1 feature, providing compile-time and runtime buffer
    overflow checks for string.h functions when the compiler determines the
    size of the source or destination buffer at compile-time. Unlike glibc,
    it covers buffer reads in addition to writes.

    GNU C __builtin_*_chk intrinsics are avoided because they would force a
    much more complex implementation. They aren't designed to detect read
    overflows and offer no real benefit when using an implementation based
    on inline checks. Inline checks don't add up to much code size and
    allow full use of the regular string intrinsics while avoiding the need
    for a bunch of _chk functions and per-arch assembly to avoid wrapper
    overhead.

    This detects various overflows at compile-time in various drivers and
    some non-x86 core kernel code. There will likely be issues caught in
    regular use at runtime too.

    Future improvements left out of initial implementation for simplicity,
    as it's all quite optional and can be done incrementally:

    * Some of the fortified string functions (strncpy, strcat), don't yet
    place a limit on reads from the source based on __builtin_object_size of
    the source buffer.

    * Extending coverage to more string functions like strlcat.

    * It should be possible to optionally use __builtin_object_size(x, 1) for
    some functions (C strings) to detect intra-object overflows (like
    glibc's _FORTIFY_SOURCE=2), but for now this takes the conservative
    approach to avoid likely compatibility issues.

    * The compile-time checks should be made available via a separate config
    option which can be enabled by default (or always enabled) once enough
    time has passed to get the issues it catches fixed.

    Kees said:
    "This is great to have. While it was out-of-tree code, it would have
    blocked at least CVE-2016-3858 from being exploitable (improper size
    argument to strlcpy()). I've sent a number of fixes for
    out-of-bounds-reads that this detected upstream already"

    [arnd@arndb.de: x86: fix fortified memcpy]
    Link: http://lkml.kernel.org/r/20170627150047.660360-1-arnd@arndb.de
    [keescook@chromium.org: avoid panic() in favor of BUG()]
    Link: http://lkml.kernel.org/r/20170626235122.GA25261@beast
    [keescook@chromium.org: move from -mm, add ARCH_HAS_FORTIFY_SOURCE, tweak Kconfig help]
    Link: http://lkml.kernel.org/r/20170526095404.20439-1-danielmicay@gmail.com
    Link: http://lkml.kernel.org/r/1497903987-21002-8-git-send-email-keescook@chromium.org
    Signed-off-by: Daniel Micay
    Signed-off-by: Kees Cook
    Signed-off-by: Arnd Bergmann
    Acked-by: Kees Cook
    Cc: Mark Rutland
    Cc: Daniel Axtens
    Cc: Rasmus Villemoes
    Cc: Andy Shevchenko
    Cc: Chris Metcalf
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Daniel Micay
     

24 May, 2017

1 commit

  • Add new LSM hooks to allocate and free security contexts and check for
    permission to access a PKey.

    Allocate and free a security context when creating and destroying a QP.
    This context is used for controlling access to PKeys.

    When a request is made to modify a QP that changes the port, PKey index,
    or alternate path, check that the QP has permission for the PKey in the
    PKey table index on the subnet prefix of the port. If the QP is shared
    make sure all handles to the QP also have access.

    Store which port and PKey index a QP is using. After the reset to init
    transition the user can modify the port, PKey index and alternate path
    independently. So port and PKey settings changes can be a merge of the
    previous settings and the new ones.

    In order to maintain access control if there are PKey table or subnet
    prefix change keep a list of all QPs are using each PKey index on
    each port. If a change occurs all QPs using that device and port must
    have access enforced for the new cache settings.

    These changes add a transaction to the QP modify process. Association
    with the old port and PKey index must be maintained if the modify fails,
    and must be removed if it succeeds. Association with the new port and
    PKey index must be established prior to the modify and removed if the
    modify fails.

    1. When a QP is modified to a particular Port, PKey index or alternate
    path insert that QP into the appropriate lists.

    2. Check permission to access the new settings.

    3. If step 2 grants access attempt to modify the QP.

    4a. If steps 2 and 3 succeed remove any prior associations.

    4b. If ether fails remove the new setting associations.

    If a PKey table or subnet prefix changes walk the list of QPs and
    check that they have permission. If not send the QP to the error state
    and raise a fatal error event. If it's a shared QP make sure all the
    QPs that share the real_qp have permission as well. If the QP that
    owns a security structure is denied access the security structure is
    marked as such and the QP is added to an error_list. Once the moving
    the QP to error is complete the security structure mark is cleared.

    Maintaining the lists correctly turns QP destroy into a transaction.
    The hardware driver for the device frees the ib_qp structure, so while
    the destroy is in progress the ib_qp pointer in the ib_qp_security
    struct is undefined. When the destroy process begins the ib_qp_security
    structure is marked as destroying. This prevents any action from being
    taken on the QP pointer. After the QP is destroyed successfully it
    could still listed on an error_list wait for it to be processed by that
    flow before cleaning up the structure.

    If the destroy fails the QPs port and PKey settings are reinserted into
    the appropriate lists, the destroying flag is cleared, and access control
    is enforced, in case there were any cache changes during the destroy
    flow.

    To keep the security changes isolated a new file is used to hold security
    related functionality.

    Signed-off-by: Daniel Jurgens
    Acked-by: Doug Ledford
    [PM: merge fixup in ib_verbs.h and uverbs_cmd.c]
    Signed-off-by: Paul Moore

    Daniel Jurgens
     

22 May, 2017

1 commit


15 May, 2017

1 commit


03 May, 2017

1 commit

  • Pull security subsystem updates from James Morris:
    "Highlights:

    IMA:
    - provide ">" and " of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (98 commits)
    tpm: Fix reference count to main device
    tpm_tis: convert to using locality callbacks
    tpm: fix handling of the TPM 2.0 event logs
    tpm_crb: remove a cruft constant
    keys: select CONFIG_CRYPTO when selecting DH / KDF
    apparmor: Make path_max parameter readonly
    apparmor: fix parameters so that the permission test is bypassed at boot
    apparmor: fix invalid reference to index variable of iterator line 836
    apparmor: use SHASH_DESC_ON_STACK
    security/apparmor/lsm.c: set debug messages
    apparmor: fix boolreturn.cocci warnings
    Smack: Use GFP_KERNEL for smk_netlbl_mls().
    smack: fix double free in smack_parse_opts_str()
    KEYS: add SP800-56A KDF support for DH
    KEYS: Keyring asymmetric key restrict method with chaining
    KEYS: Restrict asymmetric key linkage using a specific keychain
    KEYS: Add a lookup_restriction function for the asymmetric key type
    KEYS: Add KEYCTL_RESTRICT_KEYRING
    KEYS: Consistent ordering for __key_link_begin and restrict check
    KEYS: Add an optional lookup_restriction hook to key_type
    ...

    Linus Torvalds
     

27 Apr, 2017

1 commit


06 Mar, 2017

1 commit

  • Subsequent patches will add RO hardening to LSM hooks, however, SELinux
    still needs to be able to perform runtime disablement after init to handle
    architectures where init-time disablement via boot parameters is not feasible.

    Introduce a new kernel configuration parameter CONFIG_SECURITY_WRITABLE_HOOKS,
    and a helper macro __lsm_ro_after_init, to handle this case.

    Signed-off-by: James Morris
    Acked-by: Stephen Smalley
    Acked-by: Casey Schaufler
    Acked-by: Kees Cook

    James Morris
     

19 Jan, 2017

1 commit

  • Some usermode helper applications are defined at kernel build time, while
    others can be changed at runtime. To provide a sane way to filter these, add a
    new kernel option "STATIC_USERMODEHELPER". This option routes all
    call_usermodehelper() calls through this binary, no matter what the caller
    wishes to have called.

    The new binary (by default set to /sbin/usermode-helper, but can be changed
    through the STATIC_USERMODEHELPER_PATH option) can properly filter the
    requested programs to be run by the kernel by looking at the first argument
    that is passed to it. All other options should then be passed onto the proper
    program if so desired.

    To disable all call_usermodehelper() calls by the kernel, set
    STATIC_USERMODEHELPER_PATH to an empty string.

    Thanks to Neil Brown for the idea of this feature.

    Cc: NeilBrown
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

08 Sep, 2016

2 commits

  • Pull more hardened usercopyfixes from Kees Cook:

    - force check_object_size() to be inline too

    - move page-spanning check behind a CONFIG since it's triggering false
    positives

    [ Changed the page-spanning config option to depend on EXPERT in the
    merge. That way it still gets build testing, and you can enable it if
    you want to, but is never enabled for "normal" configurations ]

    * tag 'usercopy-v4.8-rc6-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
    usercopy: remove page-spanning test for now
    usercopy: force check_object_size() inline

    Linus Torvalds
     
  • A custom allocator without __GFP_COMP that copies to userspace has been
    found in vmw_execbuf_process[1], so this disables the page-span checker
    by placing it behind a CONFIG for future work where such things can be
    tracked down later.

    [1] https://bugzilla.redhat.com/show_bug.cgi?id=1373326

    Reported-by: Vinson Lee
    Fixes: f5509cc18daa ("mm: Hardened usercopy")
    Signed-off-by: Kees Cook

    Kees Cook