08 Oct, 2020

1 commit

  • * tag 'v5.4.70': (3051 commits)
    Linux 5.4.70
    netfilter: ctnetlink: add a range check for l3/l4 protonum
    ep_create_wakeup_source(): dentry name can change under you...
    ...

    Conflicts:
    arch/arm/mach-imx/pm-imx6.c
    arch/arm64/boot/dts/freescale/imx8mm-evk.dts
    arch/arm64/boot/dts/freescale/imx8mn-ddr4-evk.dts
    drivers/crypto/caam/caamalg.c
    drivers/gpu/drm/imx/dw_hdmi-imx.c
    drivers/gpu/drm/imx/imx-ldb.c
    drivers/gpu/drm/imx/ipuv3/ipuv3-crtc.c
    drivers/mmc/host/sdhci-esdhc-imx.c
    drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
    drivers/net/ethernet/freescale/enetc/enetc.c
    drivers/net/ethernet/freescale/enetc/enetc_pf.c
    drivers/thermal/imx_thermal.c
    drivers/usb/cdns3/ep0.c
    drivers/xen/swiotlb-xen.c
    sound/soc/fsl/fsl_esai.c
    sound/soc/fsl/fsl_sai.c

    Signed-off-by: Jason Liu

    Jason Liu
     

01 Oct, 2020

3 commits

  • [ Upstream commit bc62d68e2a0a69fcdcf28aca8edb01abf306b698 ]

    exceptions may be traversed using list_for_each_entry_rcu()
    outside of an RCU read side critical section BUT under the
    protection of decgroup_mutex. Hence add the corresponding
    lockdep expression to fix the following false-positive
    warning:

    [ 2.304417] =============================
    [ 2.304418] WARNING: suspicious RCU usage
    [ 2.304420] 5.5.4-stable #17 Tainted: G E
    [ 2.304422] -----------------------------
    [ 2.304424] security/device_cgroup.c:355 RCU-list traversed in non-reader section!!

    Signed-off-by: Amol Grover
    Signed-off-by: James Morris
    Signed-off-by: Sasha Levin

    Amol Grover
     
  • [ Upstream commit 8d269a8e2a8f0bca89022f4ec98de460acb90365 ]

    If seq_file .next function does not change position index,
    read after some lseek can generate unexpected output.

    $ dd if=/sys/fs/selinux/avc/cache_stats # usual output
    lookups hits misses allocations reclaims frees
    817223 810034 7189 7189 6992 7037
    1934894 1926896 7998 7998 7632 7683
    1322812 1317176 5636 5636 5456 5507
    1560571 1551548 9023 9023 9056 9115
    0+1 records in
    0+1 records out
    189 bytes copied, 5,1564e-05 s, 3,7 MB/s

    $# read after lseek to midle of last line
    $ dd if=/sys/fs/selinux/avc/cache_stats bs=180 skip=1
    dd: /sys/fs/selinux/avc/cache_stats: cannot skip to specified offset
    056 9115 <<<< end of last line
    1560571 1551548 9023 9023 9056 9115 <<< whole last line once again
    0+1 records in
    0+1 records out
    45 bytes copied, 8,7221e-05 s, 516 kB/s

    $# read after lseek beyond end of of file
    $ dd if=/sys/fs/selinux/avc/cache_stats bs=1000 skip=1
    dd: /sys/fs/selinux/avc/cache_stats: cannot skip to specified offset
    1560571 1551548 9023 9023 9056 9115 <<<< generates whole last line
    0+1 records in
    0+1 records out
    36 bytes copied, 9,0934e-05 s, 396 kB/s

    https://bugzilla.kernel.org/show_bug.cgi?id=206283

    Signed-off-by: Vasily Averin
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Sasha Levin

    Vasily Averin
     
  • [ Upstream commit 3e3e24b42043eceb97ed834102c2d094dfd7aaa6 ]

    Currently, the SELinux LSM prevents one from setting the
    `security.selinux` xattr on an inode without a policy first being
    loaded. However, this restriction is problematic: it makes it impossible
    to have newly created files with the correct label before actually
    loading the policy.

    This is relevant in distributions like Fedora, where the policy is
    loaded by systemd shortly after pivoting out of the initrd. In such
    instances, all files created prior to pivoting will be unlabeled. One
    then has to relabel them after pivoting, an operation which inherently
    races with other processes trying to access those same files.

    Going further, there are use cases for creating the entire root
    filesystem on first boot from the initrd (e.g. Container Linux supports
    this today[1], and we'd like to support it in Fedora CoreOS as well[2]).
    One can imagine doing this in two ways: at the block device level (e.g.
    laying down a disk image), or at the filesystem level. In the former,
    labeling can simply be part of the image. But even in the latter
    scenario, one still really wants to be able to set the right labels when
    populating the new filesystem.

    This patch enables this by changing behaviour in the following two ways:
    1. allow `setxattr` if we're not initialized
    2. don't try to set the in-core inode SID if we're not initialized;
    instead leave it as `LABEL_INVALID` so that revalidation may be
    attempted at a later time

    Note the first hunk of this patch is mostly the same as a previously
    discussed one[3], though it was part of a larger series which wasn't
    accepted.

    [1] https://coreos.com/os/docs/latest/root-filesystem-placement.html
    [2] https://github.com/coreos/fedora-coreos-tracker/issues/94
    [3] https://www.spinics.net/lists/linux-initramfs/msg04593.html

    Co-developed-by: Victor Kamensky
    Signed-off-by: Victor Kamensky
    Signed-off-by: Jonathan Lebon
    Signed-off-by: Paul Moore
    Signed-off-by: Sasha Levin

    Jonathan Lebon
     

19 Aug, 2020

3 commits

  • [ Upstream commit 42a2df3e829f3c5562090391b33714b2e2e5ad4a ]

    We have an upper bound on "maplevel" but forgot to check for negative
    values.

    Fixes: e114e473771c ("Smack: Simplified Mandatory Access Control Kernel")
    Signed-off-by: Dan Carpenter
    Signed-off-by: Casey Schaufler
    Signed-off-by: Sasha Levin

    Dan Carpenter
     
  • [ Upstream commit a6bd4f6d9b07452b0b19842044a6c3ea384b0b88 ]

    This is similar to commit 84e99e58e8d1 ("Smack: slab-out-of-bounds in
    vsscanf") where we added a bounds check on "rule".

    Reported-by: syzbot+a22c6092d003d6fe1122@syzkaller.appspotmail.com
    Fixes: f7112e6c9abf ("Smack: allow for significantly longer Smack labels v4")
    Signed-off-by: Dan Carpenter
    Signed-off-by: Casey Schaufler
    Signed-off-by: Sasha Levin

    Dan Carpenter
     
  • [ Upstream commit 9ff8a616dfab96a4fa0ddd36190907dc68886d9b ]

    Ask the LSM to free its audit rule rather than directly calling kfree().
    Both AppArmor and SELinux do additional work in their audit_rule_free()
    hooks. Fix memory leaks by allowing the LSMs to perform necessary work.

    Fixes: b16942455193 ("ima: use the lsm policy update notifier")
    Signed-off-by: Tyler Hicks
    Cc: Janne Karhunen
    Cc: Casey Schaufler
    Reviewed-by: Mimi Zohar
    Signed-off-by: Mimi Zohar
    Signed-off-by: Sasha Levin

    Tyler Hicks
     

11 Aug, 2020

2 commits

  • commit 311aa6aafea446c2f954cc19d66425bfed8c4b0b upstream.

    The IMA_APPRAISE_BOOTPARAM config allows enabling different "ima_appraise="
    modes - log, fix, enforce - at run time, but not when IMA architecture
    specific policies are enabled.  This prevents properly labeling the
    filesystem on systems where secure boot is supported, but not enabled on the
    platform.  Only when secure boot is actually enabled should these IMA
    appraise modes be disabled.

    This patch removes the compile time dependency and makes it a runtime
    decision, based on the secure boot state of that platform.

    Test results as follows:

    -> x86-64 with secure boot enabled

    [ 0.015637] Kernel command line: ima_policy=appraise_tcb ima_appraise=fix
    [ 0.015668] ima: Secure boot enabled: ignoring ima_appraise=fix boot parameter option

    -> powerpc with secure boot disabled

    [ 0.000000] Kernel command line: ima_policy=appraise_tcb ima_appraise=fix
    [ 0.000000] Secure boot mode disabled

    -> Running the system without secure boot and with both options set:

    CONFIG_IMA_APPRAISE_BOOTPARAM=y
    CONFIG_IMA_ARCH_POLICY=y

    Audit prompts "missing-hash" but still allow execution and, consequently,
    filesystem labeling:

    type=INTEGRITY_DATA msg=audit(07/09/2020 12:30:27.778:1691) : pid=4976
    uid=root auid=root ses=2
    subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 op=appraise_data
    cause=missing-hash comm=bash name=/usr/bin/evmctl dev="dm-0" ino=493150
    res=no

    Cc: stable@vger.kernel.org
    Fixes: d958083a8f64 ("x86/ima: define arch_get_ima_policy() for x86")
    Signed-off-by: Bruno Meneguele
    Cc: stable@vger.kernel.org # 5.0
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Bruno Meneguele
     
  • commit beb4ee6770a89646659e6a2178538d2b13e2654e upstream.

    smk_write_relabel_self() frees memory from the task's credentials with
    no locking, which can easily cause a use-after-free because multiple
    tasks can share the same credentials structure.

    Fix this by using prepare_creds() and commit_creds() to correctly modify
    the task's credentials.

    Reproducer for "BUG: KASAN: use-after-free in smk_write_relabel_self":

    #include
    #include
    #include

    static void *thrproc(void *arg)
    {
    int fd = open("/sys/fs/smackfs/relabel-self", O_WRONLY);
    for (;;) write(fd, "foo", 3);
    }

    int main()
    {
    pthread_t t;
    pthread_create(&t, NULL, thrproc, NULL);
    thrproc(NULL);
    }

    Reported-by: syzbot+e6416dabb497a650da40@syzkaller.appspotmail.com
    Fixes: 38416e53936e ("Smack: limited capability for changing process label")
    Cc: # v4.4+
    Signed-off-by: Eric Biggers
    Signed-off-by: Casey Schaufler
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     

22 Jul, 2020

1 commit

  • commit c27c6bd2c4d6b6bb779f9b722d5607993e1d5e5c upstream.

    Currently it is possible to specify a state machine table with 0 length,
    this is not valid as optional tables are specified by not defining
    the table as present. Further this allows by-passing the base tables
    range check against the next/check tables.

    Fixes: d901d6a298dc ("apparmor: dfa split verification of table headers")
    Reported-by: Mike Salvatore
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    John Johansen
     

24 Jun, 2020

4 commits


22 Jun, 2020

11 commits

  • [ Upstream commit b59fda449cf07f2db3be3a67142e6c000f5e8d79 ]

    After adding the new add_rule() function in commit c52657d93b05
    ("ima: refactor ima_init_policy()"), all appraisal flags are added to the
    temp_ima_appraise variable. Revert to the previous behavior instead of
    removing build_ima_appraise, to benefit from the protection offered by
    __ro_after_init.

    The mentioned commit introduced a bug, as it makes all the flags
    modifiable, while build_ima_appraise flags can be protected with
    __ro_after_init.

    Cc: stable@vger.kernel.org # 5.0.x
    Fixes: c52657d93b05 ("ima: refactor ima_init_policy()")
    Co-developed-by: Roberto Sassu
    Signed-off-by: Roberto Sassu
    Signed-off-by: Krzysztof Struczynski
    Signed-off-by: Mimi Zohar
    Signed-off-by: Sasha Levin

    Krzysztof Struczynski
     
  • [ Upstream commit 6ee28442a465ab4c4be45e3b15015af24b1ba906 ]

    Function ima_appraise_flag() returns the flag to be set in
    temp_ima_appraise depending on the hook identifier passed as an argument.
    It is not necessary to set the flag again for the POLICY_CHECK hook.

    Signed-off-by: Krzysztof Struczynski
    Signed-off-by: Mimi Zohar
    Signed-off-by: Sasha Levin

    Krzysztof Struczynski
     
  • commit 0c4395fb2aa77341269ea619c5419ea48171883f upstream.

    Don't immediately return if the signature is portable and security.ima is
    not present. Just set error so that memory allocated is freed before
    returning from evm_calc_hmac_or_hash().

    Fixes: 50b977481fce9 ("EVM: Add support for portable signature format")
    Signed-off-by: Roberto Sassu
    Cc: stable@vger.kernel.org
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Roberto Sassu
     
  • commit 8b8c704d913b0fe490af370631a4200e26334ec0 upstream.

    Commit 6cc7c266e5b4 ("ima: Call ima_calc_boot_aggregate() in
    ima_eventdigest_init()") added a call to ima_calc_boot_aggregate() so that
    the digest can be recalculated for the boot_aggregate measurement entry if
    the 'd' template field has been requested. For the 'd' field, only SHA1 and
    MD5 digests are accepted.

    Given that ima_eventdigest_init() does not have the __init annotation, all
    functions called should not have it. This patch removes __init from
    ima_pcrread().

    Cc: stable@vger.kernel.org
    Fixes: 6cc7c266e5b4 ("ima: Call ima_calc_boot_aggregate() in ima_eventdigest_init()")
    Reported-by: Linus Torvalds
    Signed-off-by: Roberto Sassu
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Roberto Sassu
     
  • commit 6cc7c266e5b47d3cd2b5bb7fd3aac4e6bb2dd1d2 upstream.

    If the template field 'd' is chosen and the digest to be added to the
    measurement entry was not calculated with SHA1 or MD5, it is
    recalculated with SHA1, by using the passed file descriptor. However, this
    cannot be done for boot_aggregate, because there is no file descriptor.

    This patch adds a call to ima_calc_boot_aggregate() in
    ima_eventdigest_init(), so that the digest can be recalculated also for the
    boot_aggregate entry.

    Cc: stable@vger.kernel.org # 3.13.x
    Fixes: 3ce1217d6cd5d ("ima: define template fields library and new helpers")
    Reported-by: Takashi Iwai
    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Roberto Sassu
     
  • commit 067a436b1b0aafa593344fddd711a755a58afb3b upstream.

    This patch prevents the following oops:

    [ 10.771813] BUG: kernel NULL pointer dereference, address: 0000000000000
    [...]
    [ 10.779790] RIP: 0010:ima_match_policy+0xf7/0xb80
    [...]
    [ 10.798576] Call Trace:
    [ 10.798993] ? ima_lsm_policy_change+0x2b0/0x2b0
    [ 10.799753] ? inode_init_owner+0x1a0/0x1a0
    [ 10.800484] ? _raw_spin_lock+0x7a/0xd0
    [ 10.801592] ima_must_appraise.part.0+0xb6/0xf0
    [ 10.802313] ? ima_fix_xattr.isra.0+0xd0/0xd0
    [ 10.803167] ima_must_appraise+0x4f/0x70
    [ 10.804004] ima_post_path_mknod+0x2e/0x80
    [ 10.804800] do_mknodat+0x396/0x3c0

    It occurs when there is a failure during IMA initialization, and
    ima_init_policy() is not called. IMA hooks still call ima_match_policy()
    but ima_rules is NULL. This patch prevents the crash by directly assigning
    the ima_default_policy pointer to ima_rules when ima_rules is defined. This
    wouldn't alter the existing behavior, as ima_rules is always set at the end
    of ima_init_policy().

    Cc: stable@vger.kernel.org # 3.7.x
    Fixes: 07f6a79415d7d ("ima: add appraise action keywords and default rules")
    Reported-by: Takashi Iwai
    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Roberto Sassu
     
  • commit e144d6b265415ddbdc54b3f17f4f95133effa5a8 upstream.

    Evaluate error in init_ima() before register_blocking_lsm_notifier() and
    return if not zero.

    Cc: stable@vger.kernel.org # 5.3.x
    Fixes: b16942455193 ("ima: use the lsm policy update notifier")
    Signed-off-by: Roberto Sassu
    Reviewed-by: James Morris
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Roberto Sassu
     
  • commit 6f1a1d103b48b1533a9c804e7a069e2c8e937ce7 upstream.

    boot_aggregate is the first entry of IMA measurement list. Its purpose is
    to link pre-boot measurements to IMA measurements. As IMA was designed to
    work with a TPM 1.2, the SHA1 PCR bank was always selected even if a
    TPM 2.0 with support for stronger hash algorithms is available.

    This patch first tries to find a PCR bank with the IMA default hash
    algorithm. If it does not find it, it selects the SHA256 PCR bank for
    TPM 2.0 and SHA1 for TPM 1.2. Ultimately, it selects SHA1 also for TPM 2.0
    if the SHA256 PCR bank is not found.

    If none of the PCR banks above can be found, boot_aggregate file digest is
    filled with zeros, as for TPM bypass, making it impossible to perform a
    remote attestation of the system.

    Cc: stable@vger.kernel.org # 5.1.x
    Fixes: 879b589210a9 ("tpm: retrieve digest size of unknown algorithms with PCR read")
    Reported-by: Jerry Snitselaar
    Suggested-by: James Bottomley
    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Roberto Sassu
     
  • commit 1129d31b55d509f15e72dc68e4b5c3a4d7b4da8d upstream.

    Function hash_long() accepts unsigned long, while currently only one byte
    is passed from ima_hash_key(), which calculates a key for ima_htable.

    Given that hashing the digest does not give clear benefits compared to
    using the digest itself, remove hash_long() and return the modulus
    calculated on the first two bytes of the digest with the number of slots.
    Also reduce the depth of the hash table by doubling the number of slots.

    Cc: stable@vger.kernel.org
    Fixes: 3323eec921ef ("integrity: IMA as an integrity service provider")
    Co-developed-by: Roberto Sassu
    Signed-off-by: Roberto Sassu
    Signed-off-by: Krzysztof Struczynski
    Acked-by: David.Laight@aculab.com (big endian system concerns)
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Krzysztof Struczynski
     
  • [ Upstream commit 4c09f8b6913a779ca0c70ea8058bf21537eebb3b ]

    Fix to return negative error code -ENOMEM from the kvcalloc() error
    handling case instead of 0, as done elsewhere in this function.

    Fixes: acdf52d97f82 ("selinux: convert to kvmalloc")
    Signed-off-by: Wei Yongjun
    Signed-off-by: Paul Moore
    Signed-off-by: Sasha Levin

    Wei Yongjun
     
  • [ Upstream commit 60cf7c5ed5f7087c4de87a7676b8c82d96fd166c ]

    A number of userspace tools, such as systemtap, need a way to see the
    current lockdown state so they can gracefully deal with the kernel being
    locked down. The state is already exposed in
    /sys/kernel/security/lockdown, but is only readable by root. Adjust the
    permissions so unprivileged users can read the state.

    Fixes: 000d388ed3bb ("security: Add a static lockdown policy LSM")
    Cc: Frank Ch. Eigler
    Signed-off-by: Jeremy Cline
    Signed-off-by: James Morris
    Signed-off-by: Sasha Levin

    Jeremy Cline
     

19 Jun, 2020

1 commit

  • * tag 'v5.4.47': (2193 commits)
    Linux 5.4.47
    KVM: arm64: Save the host's PtrAuth keys in non-preemptible context
    KVM: arm64: Synchronize sysreg state on injecting an AArch32 exception
    ...

    Conflicts:
    arch/arm/boot/dts/imx6qdl.dtsi
    arch/arm/mach-imx/Kconfig
    arch/arm/mach-imx/common.h
    arch/arm/mach-imx/suspend-imx6.S
    arch/arm64/boot/dts/freescale/imx8qxp-mek.dts
    arch/powerpc/include/asm/cacheflush.h
    drivers/cpufreq/imx6q-cpufreq.c
    drivers/dma/imx-sdma.c
    drivers/edac/synopsys_edac.c
    drivers/firmware/imx/imx-scu.c
    drivers/net/ethernet/freescale/fec.h
    drivers/net/ethernet/freescale/fec_main.c
    drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
    drivers/net/phy/phy_device.c
    drivers/perf/fsl_imx8_ddr_perf.c
    drivers/usb/cdns3/gadget.c
    drivers/usb/dwc3/gadget.c
    include/uapi/linux/dma-buf.h

    Signed-off-by: Jason Liu

    Jason Liu
     

17 Jun, 2020

3 commits

  • commit 84e99e58e8d1e26f04c097f4266e431a33987f36 upstream.

    Add barrier to soob. Return -EOVERFLOW if the buffer
    is exceeded.

    Suggested-by: Hillf Danton
    Reported-by: syzbot+bfdd4a2f07be52351350@syzkaller.appspotmail.com
    Signed-off-by: Casey Schaufler
    Signed-off-by: Greg Kroah-Hartman

    Casey Schaufler
     
  • [ Upstream commit d4eaa2837851db2bfed572898bfc17f9a9f9151e ]

    For kvmalloc'ed data object that contains sensitive information like
    cryptographic keys, we need to make sure that the buffer is always cleared
    before freeing it. Using memset() alone for buffer clearing may not
    provide certainty as the compiler may compile it away. To be sure, the
    special memzero_explicit() has to be used.

    This patch introduces a new kvfree_sensitive() for freeing those sensitive
    data objects allocated by kvmalloc(). The relevant places where
    kvfree_sensitive() can be used are modified to use it.

    Fixes: 4f0882491a14 ("KEYS: Avoid false positive ENOMEM error on key read")
    Suggested-by: Linus Torvalds
    Signed-off-by: Waiman Long
    Signed-off-by: Andrew Morton
    Reviewed-by: Eric Biggers
    Acked-by: David Howells
    Cc: Jarkko Sakkinen
    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc: Joe Perches
    Cc: Matthew Wilcox
    Cc: David Rientjes
    Cc: Uladzislau Rezki
    Link: http://lkml.kernel.org/r/20200407200318.11711-1-longman@redhat.com
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Waiman Long
     
  • [ Upstream commit 00720f0e7f288d29681d265c23b22bb0f0f4e5b4 ]

    The mix of IS_ENABLED() and #ifdef checks has left a combination
    that causes a warning about an unused variable:

    security/smack/smack_lsm.c: In function 'smack_socket_connect':
    security/smack/smack_lsm.c:2838:24: error: unused variable 'sip' [-Werror=unused-variable]
    2838 | struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap;

    Change the code to use C-style checks consistently so the compiler
    can handle it correctly.

    Fixes: 87fbfffcc89b ("broken ping to ipv6 linklocal addresses on debian buster")
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Casey Schaufler
    Signed-off-by: Sasha Levin

    Arnd Bergmann
     

07 Jun, 2020

2 commits

  • [ Upstream commit 770f60586d2af0590be263f55fd079226313922c ]

    This patch fixes the following warning and few other instances of
    traversal of evm_config_xattrnames list:

    [ 32.848432] =============================
    [ 32.848707] WARNING: suspicious RCU usage
    [ 32.848966] 5.7.0-rc1-00006-ga8d5875ce5f0b #1 Not tainted
    [ 32.849308] -----------------------------
    [ 32.849567] security/integrity/evm/evm_main.c:231 RCU-list traversed in non-reader section!!

    Since entries are only added to the list and never deleted, use
    list_for_each_entry_lockless() instead of list_for_each_entry_rcu for
    traversing the list. Also, add a relevant comment in evm_secfs.c to
    indicate this fact.

    Reported-by: kernel test robot
    Suggested-by: Paul E. McKenney
    Signed-off-by: Madhuparna Bhowmik
    Acked-by: Paul E. McKenney (RCU viewpoint)
    Signed-off-by: Mimi Zohar
    Signed-off-by: Sasha Levin

    Madhuparna Bhowmik
     
  • [ Upstream commit 69393cb03ccdf29f3b452d3482ef918469d1c098 ]

    Xmon should be either fully or partially disabled depending on the
    kernel lockdown state.

    Put xmon into read-only mode for lockdown=integrity and prevent user
    entry into xmon when lockdown=confidentiality. Xmon checks the lockdown
    state on every attempted entry:

    (1) during early xmon'ing

    (2) when triggered via sysrq

    (3) when toggled via debugfs

    (4) when triggered via a previously enabled breakpoint

    The following lockdown state transitions are handled:

    (1) lockdown=none -> lockdown=integrity
    set xmon read-only mode

    (2) lockdown=none -> lockdown=confidentiality
    clear all breakpoints, set xmon read-only mode,
    prevent user re-entry into xmon

    (3) lockdown=integrity -> lockdown=confidentiality
    clear all breakpoints, set xmon read-only mode,
    prevent user re-entry into xmon

    Suggested-by: Andrew Donnellan
    Signed-off-by: Christopher M. Riedl
    Signed-off-by: Michael Ellerman
    Link: https://lore.kernel.org/r/20190907061124.1947-3-cmr@informatik.wtf
    Signed-off-by: Sasha Levin

    Christopher M. Riedl
     

03 Jun, 2020

1 commit

  • [ Upstream commit a4ae32c71fe90794127b32d26d7ad795813b502e ]

    An invariant of cap_bprm_set_creds is that every field in the new cred
    structure that cap_bprm_set_creds might set, needs to be set every
    time to ensure the fields does not get a stale value.

    The field cap_ambient is not set every time cap_bprm_set_creds is
    called, which means that if there is a suid or sgid script with an
    interpreter that has neither the suid nor the sgid bits set the
    interpreter should be able to accept ambient credentials.
    Unfortuantely because cap_ambient is not reset to it's original value
    the interpreter can not accept ambient credentials.

    Given that the ambient capability set is expected to be controlled by
    the caller, I don't think this is particularly serious. But it is
    definitely worth fixing so the code works correctly.

    I have tested to verify my reading of the code is correct and the
    interpreter of a sgid can receive ambient capabilities with this
    change and cannot receive ambient capabilities without this change.

    Cc: stable@vger.kernel.org
    Cc: Andy Lutomirski
    Fixes: 58319057b784 ("capabilities: ambient capabilities")
    Signed-off-by: "Eric W. Biederman"
    Signed-off-by: Sasha Levin

    Eric W. Biederman
     

27 May, 2020

7 commits

  • commit c6b39f070722ea9963ffe756bfe94e89218c5e63 upstream.

    policy_update() invokes begin_current_label_crit_section(), which
    returns a reference of the updated aa_label object to "label" with
    increased refcount.

    When policy_update() returns, "label" becomes invalid, so the refcount
    should be decreased to keep refcount balanced.

    The reference counting issue happens in one exception handling path of
    policy_update(). When aa_may_manage_policy() returns not NULL, the
    refcnt increased by begin_current_label_crit_section() is not decreased,
    causing a refcnt leak.

    Fix this issue by jumping to "end_section" label when
    aa_may_manage_policy() returns not NULL.

    Fixes: 5ac8c355ae00 ("apparmor: allow introspecting the loaded policy pre internal transform")
    Signed-off-by: Xiyu Yang
    Signed-off-by: Xin Tan
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    Xiyu Yang
     
  • commit a0b845ffa0d91855532b50fc040aeb2d8338dca4 upstream.

    aa_change_profile() invokes aa_get_current_label(), which returns
    a reference of the current task's label.

    According to the comment of aa_get_current_label(), the returned
    reference must be put with aa_put_label().
    However, when the original object pointed by "label" becomes
    unreachable because aa_change_profile() returns or a new object
    is assigned to "label", reference count increased by
    aa_get_current_label() is not decreased, causing a refcnt leak.

    Fix this by calling aa_put_label() before aa_change_profile() return
    and dropping unnecessary aa_get_current_label().

    Fixes: 9fcf78cca198 ("apparmor: update domain transitions that are subsets of confinement at nnp")
    Signed-off-by: Xiyu Yang
    Signed-off-by: Xin Tan
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    Xiyu Yang
     
  • commit c54d481d71c6849e044690d3960aaebc730224cc upstream.

    In the implementation of aa_audit_rule_init(), when aa_label_parse()
    fails the allocated memory for rule is released using
    aa_audit_rule_free(). But after this release, the return statement
    tries to access the label field of the rule which results in
    use-after-free. Before releasing the rule, copy errNo and return it
    after release.

    Fixes: 52e8c38001d8 ("apparmor: Fix memory leak of rule on error exit path")
    Signed-off-by: Navid Emamdoost
    Signed-off-by: John Johansen
    Signed-off-by: Greg Kroah-Hartman

    Navid Emamdoost
     
  • [ Upstream commit 8433856947217ebb5697a8ff9c4c9cad4639a2cf ]

    The IS_ERR_OR_NULL() function has two conditions and if we got really
    unlucky we could hit a race where "ptr" started as an error pointer and
    then was set to NULL. Both conditions would be false even though the
    pointer at the end was NULL.

    This patch fixes the problem by ensuring that "*tfm" can only be NULL
    or valid. I have introduced a "tmp_tfm" variable to make that work. I
    also reversed a condition and pulled the code in one tab.

    Reported-by: Roberto Sassu
    Fixes: 53de3b080d5e ("evm: Check also if *tfm is an error pointer in init_desc()")
    Signed-off-by: Dan Carpenter
    Acked-by: Roberto Sassu
    Acked-by: Krzysztof Struczynski
    Signed-off-by: Mimi Zohar
    Signed-off-by: Sasha Levin

    Dan Carpenter
     
  • [ Upstream commit 2e3a34e9f409ebe83d1af7cd2f49fca7af97dfac ]

    This patch fixes the return value of ima_write_policy() when a new policy
    is directly passed to IMA and the current policy requires appraisal of the
    file containing the policy. Currently, if appraisal is not in ENFORCE mode,
    ima_write_policy() returns 0 and leads user space applications to an
    endless loop. Fix this issue by denying the operation regardless of the
    appraisal mode.

    Cc: stable@vger.kernel.org # 4.10.x
    Fixes: 19f8a84713edc ("ima: measure and appraise the IMA policy itself")
    Signed-off-by: Roberto Sassu
    Reviewed-by: Krzysztof Struczynski
    Signed-off-by: Mimi Zohar
    Signed-off-by: Sasha Levin

    Roberto Sassu
     
  • [ Upstream commit 53de3b080d5eae31d0de219617155dcc34e7d698 ]

    This patch avoids a kernel panic due to accessing an error pointer set by
    crypto_alloc_shash(). It occurs especially when there are many files that
    require an unsupported algorithm, as it would increase the likelihood of
    the following race condition:

    Task A: *tfm = crypto_alloc_shash()
    Signed-off-by: Krzysztof Struczynski
    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar
    Signed-off-by: Sasha Levin

    Roberto Sassu
     
  • [ Upstream commit 0014cc04e8ec077dc482f00c87dfd949cfe2b98f ]

    Commit a408e4a86b36 ("ima: open a new file instance if no read
    permissions") tries to create a new file descriptor to calculate a file
    digest if the file has not been opened with O_RDONLY flag. However, if a
    new file descriptor cannot be obtained, it sets the FMODE_READ flag to
    file->f_flags instead of file->f_mode.

    This patch fixes this issue by replacing f_flags with f_mode as it was
    before that commit.

    Cc: stable@vger.kernel.org # 4.20.x
    Fixes: a408e4a86b36 ("ima: open a new file instance if no read permissions")
    Signed-off-by: Roberto Sassu
    Reviewed-by: Goldwyn Rodrigues
    Signed-off-by: Mimi Zohar
    Signed-off-by: Sasha Levin

    Roberto Sassu
     

06 May, 2020

1 commit

  • commit fb73974172ffaaf57a7c42f35424d9aece1a5af6 upstream.

    Fix the SELinux netlink_send hook to properly handle multiple netlink
    messages in a single sk_buff; each message is parsed and subject to
    SELinux access control. Prior to this patch, SELinux only inspected
    the first message in the sk_buff.

    Cc: stable@vger.kernel.org
    Reported-by: Dmitry Vyukov
    Reviewed-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Paul Moore