03 Nov, 2019

1 commit


31 Oct, 2019

1 commit

  • The driver exposes EFI runtime services to user-space through an IOCTL
    interface, calling the EFI services function pointers directly without
    using the efivar API.

    Disallow access to the /dev/efi_test character device when the kernel is
    locked down to prevent arbitrary user-space to call EFI runtime services.

    Also require CAP_SYS_ADMIN to open the chardev to prevent unprivileged
    users to call the EFI runtime services, instead of just relying on the
    chardev file mode bits for this.

    The main user of this driver is the fwts [0] tool that already checks if
    the effective user ID is 0 and fails otherwise. So this change shouldn't
    cause any regression to this tool.

    [0]: https://wiki.ubuntu.com/FirmwareTestSuite/Reference/uefivarinfo

    Signed-off-by: Javier Martinez Canillas
    Signed-off-by: Ard Biesheuvel
    Acked-by: Laszlo Ersek
    Acked-by: Matthew Garrett
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-efi@vger.kernel.org
    Link: https://lkml.kernel.org/r/20191029173755.27149-7-ardb@kernel.org
    Signed-off-by: Ingo Molnar

    Javier Martinez Canillas
     

21 Oct, 2019

1 commit


09 Oct, 2019

1 commit


06 Oct, 2019

1 commit


05 Oct, 2019

2 commits

  • The ima/ and evm/ sub-directories contain built-in objects, so
    obj-$(CONFIG_...) is the correct way to descend into them.

    subdir-$(CONFIG_...) is redundant.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     
  • I guess commit 15ea0e1e3e18 ("efi: Import certificates from UEFI Secure
    Boot") attempted to add -fshort-wchar for building load_uefi.o, but it
    has never worked as intended.

    load_uefi.o is created in the platform_certs/ sub-directory. If you
    really want to add -fshort-wchar, the correct code is:

    $(obj)/platform_certs/load_uefi.o: KBUILD_CFLAGS += -fshort-wchar

    But, you do not need to fix it.

    Commit 8c97023cf051 ("Kbuild: use -fshort-wchar globally") had already
    added -fshort-wchar globally. This code was unneeded in the first place.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

04 Oct, 2019

1 commit

  • string_to_context_struct() may garble the context string, so we need to
    copy back the contents again from the old context struct to avoid
    storing the corrupted context.

    Since string_to_context_struct() tokenizes (and therefore truncates) the
    context string and we are later potentially copying it with kstrdup(),
    this may eventually cause pieces of uninitialized kernel memory to be
    disclosed to userspace (when copying to userspace based on the stored
    length and not the null character).

    How to reproduce on Fedora and similar:
    # dnf install -y memcached
    # systemctl start memcached
    # semodule -d memcached
    # load_policy
    # load_policy
    # systemctl stop memcached
    # ausearch -m AVC
    type=AVC msg=audit(1570090572.648:313): avc: denied { signal } for pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=process permissive=0 trawcon=73797374656D5F75007400000000000070BE6E847296FFFF726F6D000096FFFF76

    Cc: stable@vger.kernel.org
    Reported-by: Milos Malik
    Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
    Signed-off-by: Ondrej Mosnacek
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

02 Oct, 2019

1 commit


28 Sep, 2019

2 commits

  • 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
     
  • Pull integrity updates from Mimi Zohar:
    "The major feature in this time is IMA support for measuring and
    appraising appended file signatures. In addition are a couple of bug
    fixes and code cleanup to use struct_size().

    In addition to the PE/COFF and IMA xattr signatures, the kexec kernel
    image may be signed with an appended signature, using the same
    scripts/sign-file tool that is used to sign kernel modules.

    Similarly, the initramfs may contain an appended signature.

    This contained a lot of refactoring of the existing appended signature
    verification code, so that IMA could retain the existing framework of
    calculating the file hash once, storing it in the IMA measurement list
    and extending the TPM, verifying the file's integrity based on a file
    hash or signature (eg. xattrs), and adding an audit record containing
    the file hash, all based on policy. (The IMA support for appended
    signatures patch set was posted and reviewed 11 times.)

    The support for appended signature paves the way for adding other
    signature verification methods, such as fs-verity, based on a single
    system-wide policy. The file hash used for verifying the signature and
    the signature, itself, can be included in the IMA measurement list"

    * 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity:
    ima: ima_api: Use struct_size() in kzalloc()
    ima: use struct_size() in kzalloc()
    sefltest/ima: support appended signatures (modsig)
    ima: Fix use after free in ima_read_modsig()
    MODSIGN: make new include file self contained
    ima: fix freeing ongoing ahash_request
    ima: always return negative code for error
    ima: Store the measurement again when appraising a modsig
    ima: Define ima-modsig template
    ima: Collect modsig
    ima: Implement support for module-style appended signatures
    ima: Factor xattr_verify() out of ima_appraise_measurement()
    ima: Add modsig appraise_type option for module-style appended signatures
    integrity: Select CONFIG_KEYS instead of depending on it
    PKCS#7: Introduce pkcs7_get_digest()
    PKCS#7: Refactor verify_pkcs7_signature()
    MODSIGN: Export module signature definitions
    ima: initialize the "template" field with the default template

    Linus Torvalds
     

25 Sep, 2019

1 commit

  • Commit 0b6cf6b97b7e ("tpm: pass an array of tpm_extend_digest structures to
    tpm_pcr_extend()") modifies tpm_pcr_extend() to accept a digest for each
    PCR bank. After modification, tpm_pcr_extend() expects that digests are
    passed in the same order as the algorithms set in chip->allocated_banks.

    This patch fixes two issues introduced in the last iterations of the patch
    set: missing initialization of the TPM algorithm ID in the tpm_digest
    structures passed to tpm_pcr_extend() by the trusted key module, and
    unreleased locks in the TPM driver due to returning from tpm_pcr_extend()
    without calling tpm_put_ops().

    Cc: stable@vger.kernel.org
    Fixes: 0b6cf6b97b7e ("tpm: pass an array of tpm_extend_digest structures to tpm_pcr_extend()")
    Signed-off-by: Roberto Sassu
    Suggested-by: Jarkko Sakkinen
    Reviewed-by: Jerry Snitselaar
    Reviewed-by: Jarkko Sakkinen
    Signed-off-by: Jarkko Sakkinen

    Roberto Sassu
     

24 Sep, 2019

3 commits

  • Pull smack updates from Casey Schaufler:
    "Four patches for v5.4. Nothing is major.

    All but one are in response to mechanically detected potential issues.
    The remaining patch cleans up kernel-doc notations"

    * tag 'smack-for-5.4-rc1' of git://github.com/cschaufler/smack-next:
    smack: use GFP_NOFS while holding inode_smack::smk_lock
    security: smack: Fix possible null-pointer dereferences in smack_socket_sock_rcv_skb()
    smack: fix some kernel-doc notations
    Smack: Don't ignore other bprm->unsafe flags if LSM_UNSAFE_PTRACE is set

    Linus Torvalds
     
  • Pull SafeSetID fix from Micah Morton:
    "Jann Horn sent some patches to fix some bugs in SafeSetID for 5.3.
    After he had done his testing there were a couple small code tweaks
    that went in and caused this bug.

    From what I can see SafeSetID is broken in 5.3 and crashes the kernel
    every time during initialization if you try to use it. I came across
    this bug when backporting Jann's changes for 5.3 to older kernels
    (4.14 and 4.19). I've tested on a Chrome OS device with those kernels
    and verified that this change fixes things.

    It doesn't seem super useful to have this bake in linux-next, since it
    is completely broken in 5.3 and nobody noticed"

    * tag 'safesetid-bugfix-5.4' of git://github.com/micah-morton/linux:
    LSM: SafeSetID: Stop releasing uninitialized ruleset

    Linus Torvalds
     
  • Pull selinux updates from Paul Moore:

    - Add LSM hooks, and SELinux access control hooks, for dnotify,
    fanotify, and inotify watches. This has been discussed with both the
    LSM and fs/notify folks and everybody is good with these new hooks.

    - The LSM stacking changes missed a few calls to current_security() in
    the SELinux code; we fix those and remove current_security() for
    good.

    - Improve our network object labeling cache so that we always return
    the object's label, even when under memory pressure. Previously we
    would return an error if we couldn't allocate a new cache entry, now
    we always return the label even if we can't create a new cache entry
    for it.

    - Convert the sidtab atomic_t counter to a normal u32 with
    READ/WRITE_ONCE() and memory barrier protection.

    - A few patches to policydb.c to clean things up (remove forward
    declarations, long lines, bad variable names, etc)

    * tag 'selinux-pr-20190917' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    lsm: remove current_security()
    selinux: fix residual uses of current_security() for the SELinux blob
    selinux: avoid atomic_t usage in sidtab
    fanotify, inotify, dnotify, security: add security hook for fs notifications
    selinux: always return a secid from the network caches if we find one
    selinux: policydb - rename type_val_to_struct_array
    selinux: policydb - fix some checkpatch.pl warnings
    selinux: shuffle around policydb.c to get rid of forward declarations

    Linus Torvalds
     

18 Sep, 2019

1 commit

  • The first time a rule set is configured for SafeSetID, we shouldn't be
    trying to release the previously configured ruleset, since there isn't
    one. Currently, the pointer that would point to a previously configured
    ruleset is uninitialized on first rule set configuration, leading to a
    crash when we try to call release_ruleset with that pointer.

    Acked-by: Jann Horn
    Signed-off-by: Micah Morton

    Micah Morton
     

10 Sep, 2019

1 commit


06 Sep, 2019

1 commit

  • If a request_key authentication token key gets revoked, there's a window in
    which request_key_auth_describe() can see it with a NULL payload - but it
    makes no check for this and something like the following oops may occur:

    BUG: Kernel NULL pointer dereference at 0x00000038
    Faulting instruction address: 0xc0000000004ddf30
    Oops: Kernel access of bad area, sig: 11 [#1]
    ...
    NIP [...] request_key_auth_describe+0x90/0xd0
    LR [...] request_key_auth_describe+0x54/0xd0
    Call Trace:
    [...] request_key_auth_describe+0x54/0xd0 (unreliable)
    [...] proc_keys_show+0x308/0x4c0
    [...] seq_read+0x3d0/0x540
    [...] proc_reg_read+0x90/0x110
    [...] __vfs_read+0x3c/0x70
    [...] vfs_read+0xb4/0x1b0
    [...] ksys_read+0x7c/0x130
    [...] system_call+0x5c/0x70

    Fix this by checking for a NULL pointer when describing such a key.

    Also make the read routine check for a NULL pointer to be on the safe side.

    [DH: Modified to not take already-held rcu lock and modified to also check
    in the read routine]

    Fixes: 04c567d9313e ("[PATCH] Keys: Fix race between two instantiators of a key")
    Reported-by: Sachin Sant
    Signed-off-by: Hillf Danton
    Signed-off-by: David Howells
    Tested-by: Sachin Sant
    Signed-off-by: Linus Torvalds

    Hillf Danton
     

05 Sep, 2019

5 commits

  • We need to use selinux_cred() to fetch the SELinux cred blob instead
    of directly using current->security or current_security(). There
    were a couple of lingering uses of current_security() in the SELinux code
    that were apparently missed during the earlier conversions. IIUC, this
    would only manifest as a bug if multiple security modules including
    SELinux are enabled and SELinux is not first in the lsm order. After
    this change, there appear to be no other users of current_security()
    in-tree; perhaps we should remove it altogether.

    Fixes: bbd3662a8348 ("Infrastructure management of the cred security blob")
    Signed-off-by: Stephen Smalley
    Acked-by: Casey Schaufler
    Reviewed-by: James Morris
    Signed-off-by: Paul Moore

    Stephen Smalley
     
  • inode_smack::smk_lock is taken during smack_d_instantiate(), which is
    called during a filesystem transaction when creating a file on ext4.
    Therefore to avoid a deadlock, all code that takes this lock must use
    GFP_NOFS, to prevent memory reclaim from waiting for the filesystem
    transaction to complete.

    Reported-by: syzbot+0eefc1e06a77d327a056@syzkaller.appspotmail.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers
    Signed-off-by: Casey Schaufler

    Eric Biggers
     
  • In smack_socket_sock_rcv_skb(), there is an if statement
    on line 3920 to check whether skb is NULL:
    if (skb && skb->secmark != 0)

    This check indicates skb can be NULL in some cases.

    But on lines 3931 and 3932, skb is used:
    ad.a.u.net->netif = skb->skb_iif;
    ipv6_skb_to_auditdata(skb, &ad.a, NULL);

    Thus, possible null-pointer dereferences may occur when skb is NULL.

    To fix these possible bugs, an if statement is added to check skb.

    These bugs are found by a static analysis tool STCheck written by us.

    Signed-off-by: Jia-Ju Bai
    Signed-off-by: Casey Schaufler

    Jia-Ju Bai
     
  • Fix/add kernel-doc notation and fix typos in security/smack/.

    Signed-off-by: Liguang Zhang
    Signed-off-by: Casey Schaufler

    luanshi
     
  • There is a logic bug in the current smack_bprm_set_creds():
    If LSM_UNSAFE_PTRACE is set, but the ptrace state is deemed to be
    acceptable (e.g. because the ptracer detached in the meantime), the other
    ->unsafe flags aren't checked. As far as I can tell, this means that
    something like the following could work (but I haven't tested it):

    - task A: create task B with fork()
    - task B: set NO_NEW_PRIVS
    - task B: install a seccomp filter that makes open() return 0 under some
    conditions
    - task B: replace fd 0 with a malicious library
    - task A: attach to task B with PTRACE_ATTACH
    - task B: execve() a file with an SMACK64EXEC extended attribute
    - task A: while task B is still in the middle of execve(), exit (which
    destroys the ptrace relationship)

    Make sure that if any flags other than LSM_UNSAFE_PTRACE are set in
    bprm->unsafe, we reject the execve().

    Cc: stable@vger.kernel.org
    Fixes: 5663884caab1 ("Smack: unify all ptrace accesses in the smack")
    Signed-off-by: Jann Horn
    Signed-off-by: Casey Schaufler

    Jann Horn
     

31 Aug, 2019

1 commit


30 Aug, 2019

2 commits

  • One of the more common cases of allocation size calculations is finding
    the size of a structure that has a zero-sized array at the end, along
    with memory for some number of elements for that array. For example:

    struct ima_template_entry {
    ...
    struct ima_field_data template_data[0]; /* template related data */
    };

    instance = kzalloc(sizeof(struct ima_template_entry) + count * sizeof(struct ima_field_data), GFP_NOFS);

    Instead of leaving these open-coded and prone to type mistakes, we can
    now use the new struct_size() helper:

    instance = kzalloc(struct_size(instance, entry, count), GFP_NOFS);

    This code was detected with the help of Coccinelle.

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Mimi Zohar

    Gustavo A. R. Silva
     
  • One of the more common cases of allocation size calculations is finding
    the size of a structure that has a zero-sized array at the end, along
    with memory for some number of elements for that array. For example:

    struct foo {
    int stuff;
    struct boo entry[];
    };

    instance = kzalloc(sizeof(struct foo) + count * sizeof(struct boo), GFP_KERNEL);

    Instead of leaving these open-coded and prone to type mistakes, we can
    now use the new struct_size() helper:

    instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);

    This code was detected with the help of Coccinelle.

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Mimi Zohar

    Gustavo A. R. Silva
     

29 Aug, 2019

1 commit

  • If we can't parse the PKCS7 in the appended modsig, we will free the modsig
    structure and then access one of its members to determine the error value.

    Fixes: 39b07096364a ("ima: Implement support for module-style appended signatures")
    Reported-by: kbuild test robot
    Reported-by: Julia Lawall
    Reported-by: Dan Carpenter
    Signed-off-by: Thiago Jung Bauermann
    Reviewed-by: Gustavo A. R. Silva
    Signed-off-by: Mimi Zohar

    Thiago Jung Bauermann
     

28 Aug, 2019

1 commit

  • As noted in Documentation/atomic_t.txt, if we don't need the RMW atomic
    operations, we should only use READ_ONCE()/WRITE_ONCE() +
    smp_rmb()/smp_wmb() where necessary (or the combined variants
    smp_load_acquire()/smp_store_release()).

    This patch converts the sidtab code to use regular u32 for the counter
    and reverse lookup cache and use the appropriate operations instead of
    atomic_get()/atomic_set(). Note that when reading/updating the reverse
    lookup cache we don't need memory barriers as it doesn't need to be
    consistent or accurate. We can now also replace some atomic ops with
    regular loads (when under spinlock) and stores (for conversion target
    fields that are always accessed under the master table's spinlock).

    We can now also bump SIDTAB_MAX to U32_MAX as we can use the full u32
    range again.

    Suggested-by: Jann Horn
    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Jann Horn
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

20 Aug, 2019

12 commits

  • Print the content of current->comm in messages generated by lockdown to
    indicate a restriction that was hit. This makes it a bit easier to find
    out what caused the message.

    The message now patterned something like:

    Lockdown: : is restricted; see man kernel_lockdown.7

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

    Matthew Garrett
     
  • Tracefs may release more information about the kernel than desirable, so
    restrict it when the kernel is locked down in confidentiality mode by
    preventing open().

    (Fixed by Ben Hutchings to avoid a null dereference in
    default_file_open())

    Signed-off-by: Matthew Garrett
    Reviewed-by: Steven Rostedt (VMware)
    Cc: Ben Hutchings
    Signed-off-by: James Morris

    Matthew Garrett
     
  • Disallow opening of debugfs files that might be used to muck around when
    the kernel is locked down as various drivers give raw access to hardware
    through debugfs. Given the effort of auditing all 2000 or so files and
    manually fixing each one as necessary, I've chosen to apply a heuristic
    instead. The following changes are made:

    (1) chmod and chown are disallowed on debugfs objects (though the root dir
    can be modified by mount and remount, but I'm not worried about that).

    (2) When the kernel is locked down, only files with the following criteria
    are permitted to be opened:

    - The file must have mode 00444
    - The file must not have ioctl methods
    - The file must not have mmap

    (3) When the kernel is locked down, files may only be opened for reading.

    Normal device interaction should be done through configfs, sysfs or a
    miscdev, not debugfs.

    Note that this makes it unnecessary to specifically lock down show_dsts(),
    show_devs() and show_call() in the asus-wmi driver.

    I would actually prefer to lock down all files by default and have the
    the files unlocked by the creator. This is tricky to manage correctly,
    though, as there are 19 creation functions and ~1600 call sites (some of
    them in loops scanning tables).

    Signed-off-by: David Howells
    cc: Andy Shevchenko
    cc: acpi4asus-user@lists.sourceforge.net
    cc: platform-driver-x86@vger.kernel.org
    cc: Matthew Garrett
    cc: Thomas Gleixner
    Cc: Greg KH
    Cc: Rafael J. Wysocki
    Signed-off-by: Matthew Garrett
    Signed-off-by: James Morris

    David Howells
     
  • Systems in lockdown mode should block the kexec of untrusted kernels.
    For x86 and ARM we can ensure that a kernel is trustworthy by validating
    a PE signature, but this isn't possible on other architectures. On those
    platforms we can use IMA digital signatures instead. Add a function to
    determine whether IMA has or will verify signatures for a given event type,
    and if so permit kexec_file() even if the kernel is otherwise locked down.
    This is restricted to cases where CONFIG_INTEGRITY_TRUSTED_KEYRING is set
    in order to prevent an attacker from loading additional keys at runtime.

    Signed-off-by: Matthew Garrett
    Acked-by: Mimi Zohar
    Cc: Dmitry Kasatkin
    Cc: linux-integrity@vger.kernel.org
    Signed-off-by: James Morris

    Matthew Garrett
     
  • Disallow the use of certain perf facilities that might allow userspace to
    access kernel data.

    Signed-off-by: David Howells
    Signed-off-by: Matthew Garrett
    Reviewed-by: Kees Cook
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: James Morris

    David Howells
     
  • bpf_read() and bpf_read_str() could potentially be abused to (eg) allow
    private keys in kernel memory to be leaked. Disable them if the kernel
    has been locked down in confidentiality mode.

    Suggested-by: Alexei Starovoitov
    Signed-off-by: Matthew Garrett
    Reviewed-by: Kees Cook
    cc: netdev@vger.kernel.org
    cc: Chun-Yi Lee
    cc: Alexei Starovoitov
    Cc: Daniel Borkmann
    Signed-off-by: James Morris

    David Howells
     
  • Disallow the creation of perf and ftrace kprobes when the kernel is
    locked down in confidentiality mode by preventing their registration.
    This prevents kprobes from being used to access kernel memory to steal
    crypto data, but continues to allow the use of kprobes from signed
    modules.

    Reported-by: Alexei Starovoitov
    Signed-off-by: David Howells
    Signed-off-by: Matthew Garrett
    Acked-by: Masami Hiramatsu
    Reviewed-by: Kees Cook
    Cc: Naveen N. Rao
    Cc: Anil S Keshavamurthy
    Cc: davem@davemloft.net
    Cc: Masami Hiramatsu
    Signed-off-by: James Morris

    David Howells
     
  • Disallow access to /proc/kcore when the kernel is locked down to prevent
    access to cryptographic data. This is limited to lockdown
    confidentiality mode and is still permitted in integrity mode.

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

    David Howells
     
  • The testmmiotrace module shouldn't be permitted when the kernel is locked
    down as it can be used to arbitrarily read and write MMIO space. This is
    a runtime check rather than buildtime in order to allow configurations
    where the same kernel may be run in both locked down or permissive modes
    depending on local policy.

    Suggested-by: Thomas Gleixner
    Signed-off-by: David Howells
    Acked-by: Steven Rostedt (VMware)
    Reviewed-by: Kees Cook
    cc: Thomas Gleixner
    cc: Steven Rostedt
    cc: Ingo Molnar
    cc: "H. Peter Anvin"
    cc: x86@kernel.org
    Signed-off-by: James Morris

    David Howells
     
  • Provided an annotation for module parameters that specify hardware
    parameters (such as io ports, iomem addresses, irqs, dma channels, fixed
    dma buffers and other types).

    Suggested-by: Alan Cox
    Signed-off-by: David Howells
    Signed-off-by: Matthew Garrett
    Reviewed-by: Kees Cook
    Cc: Jessica Yu
    Signed-off-by: James Morris

    David Howells
     
  • Lock down TIOCSSERIAL as that can be used to change the ioport and irq
    settings on a serial port. This only appears to be an issue for the serial
    drivers that use the core serial code. All other drivers seem to either
    ignore attempts to change port/irq or give an error.

    Reported-by: Greg Kroah-Hartman
    Signed-off-by: David Howells
    Signed-off-by: Matthew Garrett
    Reviewed-by: Kees Cook
    cc: Jiri Slaby
    Cc: linux-serial@vger.kernel.org
    Signed-off-by: James Morris

    David Howells
     
  • Prohibit replacement of the PCMCIA Card Information Structure when the
    kernel is locked down.

    Suggested-by: Dominik Brodowski
    Signed-off-by: David Howells
    Signed-off-by: Matthew Garrett
    Reviewed-by: Kees Cook
    Signed-off-by: James Morris

    David Howells