19 Mar, 2020

1 commit

  • …am_jr_enqueue function

    In commit 4d370a103695 ("crypto: caam - change return code in caam_jr_enqueue function"),
    the return code of caam_jr_enqueue function was changed
    from 0 to -EINPROGRESS, in case of success, -ENOSPC in case
    the CAAM is busy (has no space left in job ring queue),
    -EIO if it cannot map the caller's descriptor.

    Update the case for wait_for_completion in sk_job_submit
    based on the new return code from caam_jr_enqueue function.

    Fixes: 4d370a103695 ("crypto: caam - change return code in caam_jr_enqueue function")
    Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
    Reviewed-by: Horia Geantă <horia.geanta@nxp.com>

    Iuliana Prodan
     

08 Mar, 2020

1 commit

  • Merge Linux stable release v5.4.24 into imx_5.4.y

    * tag 'v5.4.24': (3306 commits)
    Linux 5.4.24
    blktrace: Protect q->blk_trace with RCU
    kvm: nVMX: VMWRITE checks unsupported field before read-only field
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    arch/arm/boot/dts/imx6sll-evk.dts
    arch/arm/boot/dts/imx7ulp.dtsi
    arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
    drivers/clk/imx/clk-composite-8m.c
    drivers/gpio/gpio-mxc.c
    drivers/irqchip/Kconfig
    drivers/mmc/host/sdhci-of-esdhc.c
    drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
    drivers/net/can/flexcan.c
    drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
    drivers/net/ethernet/mscc/ocelot.c
    drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
    drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
    drivers/net/phy/realtek.c
    drivers/pci/controller/mobiveil/pcie-mobiveil-host.c
    drivers/perf/fsl_imx8_ddr_perf.c
    drivers/tee/optee/shm_pool.c
    drivers/usb/cdns3/gadget.c
    kernel/sched/cpufreq.c
    net/core/xdp.c
    sound/soc/fsl/fsl_esai.c
    sound/soc/fsl/fsl_sai.c
    sound/soc/sof/core.c
    sound/soc/sof/imx/Kconfig
    sound/soc/sof/loader.c

    Jason Liu
     

05 Mar, 2020

1 commit

  • commit 483ec26eed42bf050931d9a5c5f9f0b5f2ad5f3b upstream.

    Keep the ima policy rules around from the beginning even if they appear
    invalid at the time of loading, as they may become active after an lsm
    policy load. However, loading a custom IMA policy with unknown LSM
    labels is only safe after we have transitioned from the "built-in"
    policy rules to a custom IMA policy.

    Patch also fixes the rule re-use during the lsm policy reload and makes
    some prints a bit more human readable.

    Changelog:
    v4:
    - Do not allow the initial policy load refer to non-existing lsm rules.
    v3:
    - Fix too wide policy rule matching for non-initialized LSMs
    v2:
    - Fix log prints

    Fixes: b16942455193 ("ima: use the lsm policy update notifier")
    Cc: Casey Schaufler
    Reported-by: Mimi Zohar
    Signed-off-by: Janne Karhunen
    Signed-off-by: Konsta Karsisto
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Janne Karhunen
     

26 Feb, 2020

1 commit


24 Feb, 2020

2 commits

  • [ Upstream commit 030b995ad9ece9fa2d218af4429c1c78c2342096 ]

    In AVC update we don't call avc_node_kill() when avc_xperms_populate()
    fails, resulting in the avc->avc_cache.active_nodes counter having a
    false value. In last patch this changes was missed , so correcting it.

    Fixes: fa1aa143ac4a ("selinux: extended permissions for ioctls")
    Signed-off-by: Jaihind Yadav
    Signed-off-by: Ravi Kumar Siddojigari
    [PM: merge fuzz, minor description cleanup]
    Signed-off-by: Paul Moore
    Signed-off-by: Sasha Levin

    Jaihind Yadav
     
  • [ Upstream commit d8db60cb23e49a92cf8cada3297395c7fa50fdf8 ]

    Fix avc_insert() to call avc_node_kill() if we've already allocated
    an AVC node and the code fails to insert the node in the cache.

    Fixes: fa1aa143ac4a ("selinux: extended permissions for ioctls")
    Reported-by: rsiddoji@codeaurora.org
    Suggested-by: Stephen Smalley
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Sasha Levin

    Paul Moore
     

15 Feb, 2020

3 commits

  • commit 0188d5c025ca8fe756ba3193bd7d150139af5a88 upstream.

    commit bda0be7ad994 ("security: make inode_follow_link RCU-walk aware")
    passed down the rcu flag to the SELinux AVC, but failed to adjust the
    test in slow_avc_audit() to also return -ECHILD on LSM_AUDIT_DATA_DENTRY.
    Previously, we only returned -ECHILD if generating an audit record with
    LSM_AUDIT_DATA_INODE since this was only relevant from inode_permission.
    Move the handling of MAY_NOT_BLOCK to avc_audit() and its inlined
    equivalent in selinux_inode_permission() immediately after we determine
    that audit is required, and always fall back to ref-walk in this case.

    Fixes: bda0be7ad994 ("security: make inode_follow_link RCU-walk aware")
    Reported-by: Will Deacon
    Suggested-by: Al Viro
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Stephen Smalley
     
  • commit 98aa00345de54b8340dc2ddcd87f446d33387b5e upstream.

    commit 2db154b3ea8e ("vfs: syscall: Add move_mount(2) to move mounts around")
    introduced a new move_mount(2) system call and a corresponding new LSM
    security_move_mount hook but did not implement this hook for any existing
    LSM. This creates a regression for SELinux with respect to consistent
    checking of mounts; the existing selinux_mount hook checks mounton
    permission to the mount point path. Provide a SELinux hook
    implementation for move_mount that applies this same check for
    consistency. In the future we may wish to add a new move_mount
    filesystem permission and check as well, but this addresses
    the immediate regression.

    Fixes: 2db154b3ea8e ("vfs: syscall: Add move_mount(2) to move mounts around")
    Signed-off-by: Stephen Smalley
    Reviewed-by: Ondrej Mosnacek
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Stephen Smalley
     
  • commit 1a37079c236d55fb31ebbf4b59945dab8ec8764c upstream.

    This reverts commit e46e01eebbbc ("selinux: stop passing MAY_NOT_BLOCK
    to the AVC upon follow_link"). The correct fix is to instead fall
    back to ref-walk if audit is required irrespective of the specific
    audit data type. This is done in the next commit.

    Fixes: e46e01eebbbc ("selinux: stop passing MAY_NOT_BLOCK to the AVC upon follow_link")
    Reported-by: Will Deacon
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Stephen Smalley
     

11 Feb, 2020

1 commit

  • commit 87fbfffcc89b92a4281b0aa53bd06af714087889 upstream.

    I am seeing ping failures to IPv6 linklocal addresses with Debian
    buster. Easiest example to reproduce is:

    $ ping -c1 -w1 ff02::1%eth1
    connect: Invalid argument

    $ ping -c1 -w1 ff02::1%eth1
    PING ff02::01%eth1(ff02::1%eth1) 56 data bytes
    64 bytes from fe80::e0:f9ff:fe0c:37%eth1: icmp_seq=1 ttl=64 time=0.059 ms

    git bisect traced the failure to
    commit b9ef5513c99b ("smack: Check address length before reading address family")

    Arguably ping is being stupid since the buster version is not setting
    the address family properly (ping on stretch for example does):

    $ strace -e connect ping6 -c1 -w1 ff02::1%eth1
    connect(5, {sa_family=AF_UNSPEC,
    sa_data="\4\1\0\0\0\0\377\2\0\0\0\0\0\0\0\0\0\0\0\0\0\1\3\0\0\0"}, 28)
    = -1 EINVAL (Invalid argument)

    but the command works fine on kernels prior to this commit, so this is
    breakage which goes against the Linux paradigm of "don't break userspace"

    Cc: stable@vger.kernel.org
    Reported-by: David Ahern
    Suggested-by: Tetsuo Handa
    Signed-off-by: Casey Schaufler
    Signed-off-by: Greg Kroah-Hartman

     security/smack/smack_lsm.c | 41 +++++++++++++++++++----------------------
    security/smack/smack_lsm.c | 41 +++++++++++++++++++----------------------
    1 file changed, 19 insertions(+), 22 deletions(-)

    Casey Schaufler
     

06 Feb, 2020

1 commit

  • commit a8772fad0172aeae339144598b809fd8d4823331 upstream.

    syzbot is reporting that there is a race at tomoyo_stat_update() [1].
    Although it is acceptable to fail to track exact number of times policy
    was updated, convert to atomic_t because this is not a hot path.

    [1] https://syzkaller.appspot.com/bug?id=a4d7b973972eeed410596e6604580e0133b0fc04

    Reported-by: syzbot
    Signed-off-by: Tetsuo Handa
    Signed-off-by: Greg Kroah-Hartman

    Tetsuo Handa
     

18 Jan, 2020

1 commit

  • [ Upstream commit 6bd5ce6089b561f5392460bfb654dea89356ab1b ]

    John Garry has reported that allmodconfig kernel on arm64 causes flood of
    "RCU-list traversed in non-reader section!!" warning. I don't know what
    change caused this warning, but this warning is safe because TOMOYO uses
    SRCU lock instead. Let's suppress this warning by explicitly telling that
    the caller is holding SRCU lock.

    Reported-and-tested-by: John Garry
    Signed-off-by: Tetsuo Handa
    Signed-off-by: Sasha Levin

    Tetsuo Handa
     

09 Jan, 2020

1 commit

  • commit 8c62ed27a12c00e3db1c9f04bc0f272bdbb06734 upstream.

    aa_xattrs_match() is unfortunately calling vfs_getxattr_alloc() from a
    context protected by an rcu_read_lock. This can not be done as
    vfs_getxattr_alloc() may sleep regardles of the gfp_t value being
    passed to it.

    Fix this by breaking the rcu_read_lock on the policy search when the
    xattr match feature is requested and restarting the search if a policy
    changes occur.

    Fixes: 8e51f9087f40 ("apparmor: Add support for attaching profiles via xattr, presence and value")
    Reported-by: Jia-Ju Bai
    Reported-by: Al Viro
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    John Johansen
     

05 Jan, 2020

2 commits

  • commit 6f7c41374b62fd80bbd8aae3536c43688c54d95e upstream.

    syzbot is reporting that use of SOCKET_I()->sk from open() can result in
    use after free problem [1], for socket's inode is still reachable via
    /proc/pid/fd/n despite destruction of SOCKET_I()->sk already completed.

    At first I thought that this race condition applies to only open/getattr
    permission checks. But James Morris has pointed out that there are more
    permission checks where this race condition applies to. Thus, get rid of
    tomoyo_get_socket_name() instead of conditionally bypassing permission
    checks on sockets. As a side effect of this patch,
    "socket:[family=\$:type=\$:protocol=\$]" in the policy files has to be
    rewritten to "socket:[\$]".

    [1] https://syzkaller.appspot.com/bug?id=73d590010454403d55164cca23bd0565b1eb3b74

    Signed-off-by: Tetsuo Handa
    Reported-by: syzbot
    Reported-by: James Morris
    Signed-off-by: Greg Kroah-Hartman

    Tetsuo Handa
     
  • [ Upstream commit 00e0590dbaec6f1bcaa36a85467d7e3497ced522 ]

    The sanity check in macro update_for_len checks to see if len
    is less than zero, however, len is a size_t so it can never be
    less than zero, so this sanity check is a no-op. Fix this by
    making len a ssize_t so the comparison will work and add ulen
    that is a size_t copy of len so that the min() macro won't
    throw warnings about comparing different types.

    Addresses-Coverity: ("Macro compares unsigned to 0")
    Fixes: f1bd904175e8 ("apparmor: add the base fns() for domain labels")
    Signed-off-by: Colin Ian King
    Signed-off-by: John Johansen
    Signed-off-by: Sasha Levin

    Colin Ian King
     

25 Nov, 2019

2 commits


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
     

09 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
     

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