07 Apr, 2020

1 commit

  • Fix the following warning:

    crypto/testmgr.c: In function ‘__test_tls’:
    crypto/testmgr.c:2648:12: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
    if (!ret == template[i].fail) {
    ^~

    Fixes: 8abdaaeda43 ("crypto: add support for TLS 1.0 record encryption")
    Signed-off-by: Iuliana Prodan
    Reviewed-by: Horia Geantă
    Reviewed-by: Valentin Ciocoi R?dulescu

    Iuliana Prodan
     

31 Mar, 2020

1 commit

  • This is a temporary workround for the case when:
    -SWIOTLB is used for DMA bounce buffering AND
    -data to be DMA-ed is mapped DMA_FROM_DEVICE and device only partially
    overwrites the "original" data AND
    -it's expected that the "original" data that was not overwritten
    by the device to be untouched

    As discussed in upstream, the proper fix should be:
    -either an extension of the DMA API OR
    -a workaround in the device driver (considering these cases are rarely
    met in practice)

    Since both alternatives are not trivial (to say the least),
    add a workaround for the few cases matching the error conditions
    listed above.

    Link: https://lore.kernel.org/lkml/VI1PR0402MB348537CB86926B3E6D1DBE0A98070@VI1PR0402MB3485.eurprd04.prod.outlook.com/
    Link: https://lore.kernel.org/lkml/20190522072018.10660-1-horia.geanta@nxp.com/
    Signed-off-by: Horia Geantă
    Reviewed-by: Valentin Ciocoi Radulescu
    Reviewed-by: Iuliana Prodan

    Horia Geantă
     

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
     

29 Feb, 2020

1 commit

  • commit 6a30e1b1dcad0ba94fae757f797812d7d8dcb72c upstream.

    The name sm3-256 is defined in hash_algo_name in hash_info, but the
    algorithm name implemented in sm3_generic.c is sm3, which will cause
    the sm3-256 algorithm to be not found in some application scenarios of
    the hash algorithm, and an ENOENT error will occur. For example,
    IMA, keys, and other subsystems that reference hash_algo_name all use
    the hash algorithm of sm3.

    Fixes: 5ca4c20cfd37 ("keys, trusted: select hash algorithm for TPM2 chips")
    Signed-off-by: Tianjia Zhang
    Reviewed-by: Pascal van Leeuwen
    Signed-off-by: Mimi Zohar
    Signed-off-by: Greg Kroah-Hartman

    Tianjia Zhang
     

27 Feb, 2020

1 commit

  • tls module lacks an alias, thus cannot be auto-loaded.

    Note that all crypto modules have to be "protected" under the namespace
    created by the "crypto-" prefix:
    commit 5d26a105b5a7 ("crypto: prefix module autoloading with "crypto-"")

    Fixes: a61cc4776299 ("crypto: add support for TLS 1.0 record encryption")
    Signed-off-by: Horia Geantă
    Reviewed-by: Valentin Ciocoi Radulescu

    Horia Geantă
     

24 Feb, 2020

1 commit


15 Feb, 2020

1 commit

  • commit eb455dbd02cb1074b37872ffca30a81cb2a18eaa upstream.

    Currently if the comparison fuzz tests encounter an encryption error
    when generating an skcipher or AEAD test vector, they will still test
    the decryption side (passing it the uninitialized ciphertext buffer)
    and expect it to fail with the same error.

    This is sort of broken because it's not well-defined usage of the API to
    pass an uninitialized buffer, and furthermore in the AEAD case it's
    acceptable for the decryption error to be EBADMSG (meaning "inauthentic
    input") even if the encryption error was something else like EINVAL.

    Fix this for skcipher by explicitly initializing the ciphertext buffer
    on error, and for AEAD by skipping the decryption test on error.

    Reported-by: Pascal Van Leeuwen
    Fixes: d435e10e67be ("crypto: testmgr - fuzz skciphers against their generic implementation")
    Fixes: 40153b10d91c ("crypto: testmgr - fuzz AEADs against their generic implementation")
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     

11 Feb, 2020

5 commits

  • commit 73669cc556462f4e50376538d77ee312142e8a8a upstream.

    The function crypto_spawn_alg is racy because it drops the lock
    before shooting the dying algorithm. The algorithm could disappear
    altogether before we shoot it.

    This patch fixes it by moving the shooting into the locked section.

    Fixes: 6bfd48096ff8 ("[CRYPTO] api: Added spawns")
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     
  • commit e8d998264bffade3cfe0536559f712ab9058d654 upstream.

    We should not be modifying the original request's MAY_SLEEP flag
    upon completion. It makes no sense to do so anyway.

    Reported-by: Eric Biggers
    Fixes: 5068c7a883d1 ("crypto: pcrypt - Add pcrypt crypto...")
    Signed-off-by: Herbert Xu
    Tested-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     
  • commit 2bbb3375d967155bccc86a5887d4a6e29c56b683 upstream.

    When CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y, the first lookup of an
    algorithm that needs to be instantiated using a template will always get
    the generic implementation, even when an accelerated one is available.

    This happens because the extra self-tests for the accelerated
    implementation allocate the generic implementation for comparison
    purposes, and then crypto_alg_tested() for the generic implementation
    "fulfills" the original request (i.e. sets crypto_larval::adult).

    This patch fixes this by only fulfilling the original request if
    we are currently the best outstanding larval as judged by the
    priority. If we're not the best then we will ask all waiters on
    that larval request to retry the lookup.

    Note that this patch introduces a behaviour change when the module
    providing the new algorithm is unregistered during the process.
    Previously we would have failed with ENOENT, after the patch we
    will instead redo the lookup.

    Fixes: 9a8a6b3f0950 ("crypto: testmgr - fuzz hashes against...")
    Fixes: d435e10e67be ("crypto: testmgr - fuzz skciphers against...")
    Fixes: 40153b10d91c ("crypto: testmgr - fuzz AEADs against...")
    Reported-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Reviewed-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     
  • commit bbefa1dd6a6d53537c11624752219e39959d04fb upstream.

    If the pcrypt template is used multiple times in an algorithm, then a
    deadlock occurs because all pcrypt instances share the same
    padata_instance, which completes requests in the order submitted. That
    is, the inner pcrypt request waits for the outer pcrypt request while
    the outer request is already waiting for the inner.

    This patch fixes this by allocating a set of queues for each pcrypt
    instance instead of using two global queues. In order to maintain
    the existing user-space interface, the pinst structure remains global
    so any sysfs modifications will apply to every pcrypt instance.

    Note that when an update occurs we have to allocate memory for
    every pcrypt instance. Should one of the allocations fail we
    will abort the update without rolling back changes already made.

    The new per-instance data structure is called padata_shell and is
    essentially a wrapper around parallel_data.

    Reproducer:

    #include
    #include
    #include

    int main()
    {
    struct sockaddr_alg addr = {
    .salg_type = "aead",
    .salg_name = "pcrypt(pcrypt(rfc4106-gcm-aesni))"
    };
    int algfd, reqfd;
    char buf[32] = { 0 };

    algfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
    bind(algfd, (void *)&addr, sizeof(addr));
    setsockopt(algfd, SOL_ALG, ALG_SET_KEY, buf, 20);
    reqfd = accept(algfd, 0, 0);
    write(reqfd, buf, 32);
    read(reqfd, buf, 16);
    }

    Reported-by: syzbot+56c7151cad94eec37c521f0e47d2eee53f9361c4@syzkaller.appspotmail.com
    Fixes: 5068c7a883d1 ("crypto: pcrypt - Add pcrypt crypto parallelization wrapper")
    Signed-off-by: Herbert Xu
    Tested-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     
  • commit 7db3b61b6bba4310f454588c2ca6faf2958ad79f upstream.

    We need to check whether spawn->alg is NULL under lock as otherwise
    the algorithm could be removed from under us after we have checked
    it and found it to be non-NULL. This could cause us to remove the
    spawn from a non-existent list.

    Fixes: 7ede5a5ba55a ("crypto: api - Fix crypto_drop_spawn crash...")
    Cc:
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     

01 Feb, 2020

2 commits

  • commit 07bfd9bdf568a38d9440c607b72342036011f727 upstream.

    On module unload of pcrypt we must unregister the crypto algorithms
    first and then tear down the padata structure. As otherwise the
    crypto algorithms are still alive and can be used while the padata
    structure is being freed.

    Fixes: 5068c7a883d1 ("crypto: pcrypt - Add pcrypt crypto...")
    Cc:
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     
  • commit 37f96694cf73ba116993a9d2d99ad6a75fa7fdb0 upstream.

    As af_alg_release_parent may be called from BH context (most notably
    due to an async request that only completes after socket closure,
    or as reported here because of an RCU-delayed sk_destruct call), we
    must use bh_lock_sock instead of lock_sock.

    Reported-by: syzbot+c2f1558d49e25cc36e5e@syzkaller.appspotmail.com
    Reported-by: Eric Dumazet
    Fixes: c840ac6af3f8 ("crypto: af_alg - Disallow bind/setkey/...")
    Cc:
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     

18 Jan, 2020

1 commit

  • commit 5b0fe9552336338acb52756daf65dd7a4eeca73f upstream.

    When algif_skcipher does a partial operation it always process data
    that is a multiple of blocksize. However, for algorithms such as
    CTR this is wrong because even though it can process any number of
    bytes overall, the partial block must come at the very end and not
    in the middle.

    This is exactly what chunksize is meant to describe so this patch
    changes blocksize to chunksize.

    Fixes: 8ff590903d5f ("crypto: algif_skcipher - User-space...")
    Signed-off-by: Herbert Xu
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     

31 Dec, 2019

3 commits

  • commit bea37414453eb08d4ceffeb60a9d490dbc930cea upstream.

    No error code was being set on this error path.

    Cc: stable@vger.kernel.org
    Fixes: ad4b1eb5fb33 ("KEYS: asym_tpm: Implement encryption operation [ver #2]")
    Fixes: c08fed737126 ("KEYS: Implement encrypt, decrypt and sign for software asymmetric key [ver #2]")
    Reviewed-by: James Morris
    Signed-off-by: Eric Biggers
    Reviewed-by: Jarkko Sakkinen
    Signed-off-by: Jarkko Sakkinen
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     
  • [ Upstream commit 830536770f968ab33ece123b317e252c269098db ]

    Now that the Clang compiler has taken it upon itself to police the
    compiler command line, and reject combinations for arguments it views
    as incompatible, the AEGIS128 no longer builds correctly, and errors
    out like this:

    clang-10: warning: ignoring extension 'crypto' because the 'armv7-a'
    architecture does not support it [-Winvalid-command-line-argument]

    So let's switch to armv8-a instead, which matches the crypto-neon-fp-armv8
    FPU profile we specify. Since neither were actually supported by GCC
    versions before 4.8, let's tighten the Kconfig dependencies as well so
    we won't run into errors when building with an ancient compiler.

    Signed-off-by: Ard Biesheuvel
    Reviewed-by: Nathan Chancellor
    Tested-by: Nathan Chancellor
    Reviewed-by: Nick Desaulniers
    Tested-by: Nick Desaulniers
    Reported-by:
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Ard Biesheuvel
     
  • [ Upstream commit 2eb2d198bd6cd0083a5363ce66272fb34a19928f ]

    The next version of Clang will start policing compiler command line
    options, and will reject combinations of -march and -mfpu that it
    thinks are incompatible.

    This results in errors like

    clang-10: warning: ignoring extension 'crypto' because the 'armv7-a'
    architecture does not support it [-Winvalid-command-line-argument]
    /tmp/aegis128-neon-inner-5ee428.s: Assembler messages:
    /tmp/aegis128-neon-inner-5ee428.s:73: Error: selected
    processor does not support `aese.8 q2,q14' in ARM mode

    when buiding the SIMD aegis128 code for 32-bit ARM, given that the
    'armv7-a' -march argument is considered to be compatible with the
    ARM crypto extensions. Instead, we should use armv8-a, which does
    allow the crypto extensions to be enabled.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Ard Biesheuvel
     

16 Dec, 2019

1 commit

  • This is the 5.4.3 stable release

    Conflicts:
    drivers/cpufreq/imx-cpufreq-dt.c
    drivers/spi/spi-fsl-qspi.c

    The conflict is very minor, fixed it when do the merge. The imx-cpufreq-dt.c
    is just one line code-style change, using upstream one, no any function change.

    The spi-fsl-qspi.c has minor conflicts when merge upstream fixes: c69b17da53b2
    spi: spi-fsl-qspi: Clear TDH bits in FLSHCR register

    After merge, basic boot sanity test and basic qspi test been done on i.mx

    Signed-off-by: Jason Liu

    Jason Liu
     

13 Dec, 2019

4 commits

  • commit c03b04dcdba1da39903e23cc4d072abf8f68f2dd upstream.

    In crypto_reportstat, a new skb is created by nlmsg_new(). This skb is
    leaked if crypto_reportstat_alg() fails. Required release for skb is
    added.

    Fixes: cac5818c25d0 ("crypto: user - Implement a generic crypto statistics")
    Cc:
    Signed-off-by: Navid Emamdoost
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Navid Emamdoost
     
  • commit ffdde5932042600c6807d46c1550b28b0db6a3bc upstream.

    In crypto_report, a new skb is created via nlmsg_new(). This skb should
    be released if crypto_report_alg() fails.

    Fixes: a38f7907b926 ("crypto: Add userspace configuration API")
    Cc:
    Signed-off-by: Navid Emamdoost
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Navid Emamdoost
     
  • commit f398243e9fd6a3a059c1ea7b380c40628dbf0c61 upstream.

    The elliptic curve arithmetic library used by the EC-DH KPP implementation
    assumes big endian byte order, and unconditionally reverses the byte
    and word order of multi-limb quantities. On big endian systems, the byte
    reordering is not necessary, while the word ordering needs to be retained.

    So replace the __swab64() invocation with a call to be64_to_cpu() which
    should do the right thing for both little and big endian builds.

    Fixes: 3c4b23901a0c ("crypto: ecdh - Add ECDH software support")
    Cc: # v4.9+
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     
  • commit 64e7f852c47ce99f6c324c46d6a299a5a7ebead9 upstream.

    when libkcapi test is executed using HW accelerator, cipher operation
    return -74.Since af_alg_async_cb->ki_complete treat err as unsigned int,
    libkcapi receive 429467222 even though it expect -ve value.

    Hence its required to cast resultlen to int so that proper
    error is returned to libkcapi.

    AEAD one shot non-aligned test 2(libkcapi test)
    ./../bin/kcapi -x 10 -c "gcm(aes)" -i 7815d4b06ae50c9c56e87bd7
    -k ea38ac0c9b9998c80e28fb496a2b88d9 -a
    "853f98a750098bec1aa7497e979e78098155c877879556bb51ddeb6374cbaefc"
    -t "c4ce58985b7203094be1d134c1b8ab0b" -q
    "b03692f86d1b8b39baf2abb255197c98"

    Fixes: d887c52d6ae4 ("crypto: algif_aead - overhaul memory management")
    Cc:
    Signed-off-by: Ayush Sawal
    Signed-off-by: Atul Gupta
    Signed-off-by: Herbert Xu
    Signed-off-by: Ayush Sawal
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Ayush Sawal
     

02 Dec, 2019

2 commits

  • Signed-off-by: Radu Alexe
    Signed-off-by: Tudor Ambarus

    Radu Alexe
     
  • This patch adds kernel support for encryption/decryption of TLS 1.0
    records using block ciphers. Implementation is similar to authenc in the
    sense that the base algorithms (AES, SHA1) are combined in a template to
    produce TLS encapsulation frames. The composite algorithm will be called
    "tls10(hmac(),cbc())". The cipher and hmac keys are
    wrapped in the same format used by authenc.c.

    Signed-off-by: Radu Alexe
    Signed-off-by: Cristian Stoica
    Signed-off-by: Horia Geantă

    Radu Alexe
     

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
     

22 Sep, 2019

1 commit

  • …device-mapper/linux-dm

    Pull device mapper updates from Mike Snitzer:

    - crypto and DM crypt advances that allow the crypto API to reclaim
    implementation details that do not belong in DM crypt. The wrapper
    template for ESSIV generation that was factored out will also be used
    by fscrypt in the future.

    - Add root hash pkcs#7 signature verification to the DM verity target.

    - Add a new "clone" DM target that allows for efficient remote
    replication of a device.

    - Enhance DM bufio's cache to be tailored to each client based on use.
    Clients that make heavy use of the cache get more of it, and those
    that use less have reduced cache usage.

    - Add a new DM_GET_TARGET_VERSION ioctl to allow userspace to query the
    version number of a DM target (even if the associated module isn't
    yet loaded).

    - Fix invalid memory access in DM zoned target.

    - Fix the max_discard_sectors limit advertised by the DM raid target;
    it was mistakenly storing the limit in bytes rather than sectors.

    - Small optimizations and cleanups in DM writecache target.

    - Various fixes and cleanups in DM core, DM raid1 and space map portion
    of DM persistent data library.

    * tag 'for-5.4/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: (22 commits)
    dm: introduce DM_GET_TARGET_VERSION
    dm bufio: introduce a global cache replacement
    dm bufio: remove old-style buffer cleanup
    dm bufio: introduce a global queue
    dm bufio: refactor adjust_total_allocated
    dm bufio: call adjust_total_allocated from __link_buffer and __unlink_buffer
    dm: add clone target
    dm raid: fix updating of max_discard_sectors limit
    dm writecache: skip writecache_wait for pmem mode
    dm stats: use struct_size() helper
    dm crypt: omit parsing of the encapsulated cipher
    dm crypt: switch to ESSIV crypto API template
    crypto: essiv - create wrapper template for ESSIV generation
    dm space map common: remove check for impossible sm_find_free() return value
    dm raid1: use struct_size() with kzalloc()
    dm writecache: optimize performance by sorting the blocks for writeback_all
    dm writecache: add unlikely for getting two block with same LBA
    dm writecache: remove unused member pointer in writeback_struct
    dm zoned: fix invalid memory access
    dm verity: add root hash pkcs#7 signature verification
    ...

    Linus Torvalds
     

13 Sep, 2019

4 commits

  • With pcrypt's cpumask no longer used, take the CPU hotplug lock inside
    padata_alloc_possible.

    Useful later in the series for avoiding nested acquisition of the CPU
    hotplug lock in padata when padata_alloc_possible is allocating an
    unbound workqueue.

    Without this patch, this nested acquisition would happen later in the
    series:

    pcrypt_init_padata
    get_online_cpus
    alloc_padata_possible
    alloc_padata
    alloc_workqueue(WQ_UNBOUND) // later in the series
    alloc_and_link_pwqs
    apply_wqattrs_lock
    get_online_cpus // recursive rwsem acquisition

    Signed-off-by: Daniel Jordan
    Acked-by: Steffen Klassert
    Cc: Herbert Xu
    Cc: Lai Jiangshan
    Cc: Peter Zijlstra
    Cc: Tejun Heo
    Cc: linux-crypto@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Herbert Xu

    Daniel Jordan
     
  • Now that padata_do_parallel takes care of finding an alternate callback
    CPU, there's no need for pcrypt's callback cpumask, so remove it and the
    notifier callback that keeps it in sync.

    Signed-off-by: Daniel Jordan
    Acked-by: Steffen Klassert
    Cc: Herbert Xu
    Cc: Lai Jiangshan
    Cc: Peter Zijlstra
    Cc: Tejun Heo
    Cc: linux-crypto@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Herbert Xu

    Daniel Jordan
     
  • padata_do_parallel currently returns -EINVAL if the callback CPU isn't
    in the callback cpumask.

    pcrypt tries to prevent this situation by keeping its own callback
    cpumask in sync with padata's and checks that the callback CPU it passes
    to padata is valid. Make padata handle this instead.

    padata_do_parallel now takes a pointer to the callback CPU and updates
    it for the caller if an alternate CPU is used. Overall behavior in
    terms of which callback CPUs are chosen stays the same.

    Prepares for removal of the padata cpumask notifier in pcrypt, which
    will fix a lockdep complaint about nested acquisition of the CPU hotplug
    lock later in the series.

    Signed-off-by: Daniel Jordan
    Acked-by: Steffen Klassert
    Cc: Herbert Xu
    Cc: Lai Jiangshan
    Cc: Peter Zijlstra
    Cc: Tejun Heo
    Cc: linux-crypto@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Herbert Xu

    Daniel Jordan
     
  • Move workqueue allocation inside of padata to prepare for further
    changes to how padata uses workqueues.

    Guarantees the workqueue is created with max_active=1, which padata
    relies on to work correctly. No functional change.

    Signed-off-by: Daniel Jordan
    Acked-by: Steffen Klassert
    Cc: Herbert Xu
    Cc: Jonathan Corbet
    Cc: Lai Jiangshan
    Cc: Peter Zijlstra
    Cc: Tejun Heo
    Cc: linux-crypto@vger.kernel.org
    Cc: linux-doc@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Herbert Xu

    Daniel Jordan
     

09 Sep, 2019

1 commit

  • skcipher_walk_done may be called with an error by internal or
    external callers. For those internal callers we shouldn't unmap
    pages but for external callers we must unmap any pages that are
    in use.

    This patch distinguishes between the two cases by checking whether
    walk->nbytes is zero or not. For internal callers, we now set
    walk->nbytes to zero prior to the call. For external callers,
    walk->nbytes has always been non-zero (as zero is used to indicate
    the termination of a walk).

    Reported-by: Ard Biesheuvel
    Fixes: 5cde0af2a982 ("[CRYPTO] cipher: Added block cipher type")
    Cc:
    Signed-off-by: Herbert Xu
    Tested-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Herbert Xu
     

05 Sep, 2019

1 commit


04 Sep, 2019

1 commit

  • Implement a template that wraps a (skcipher,shash) or (aead,shash) tuple
    so that we can consolidate the ESSIV handling in fscrypt and dm-crypt and
    move it into the crypto API. This will result in better test coverage, and
    will allow future changes to make the bare cipher interface internal to the
    crypto subsystem, in order to increase robustness of the API against misuse.

    Signed-off-by: Ard Biesheuvel
    Acked-by: Herbert Xu
    Tested-by: Milan Broz
    Signed-off-by: Mike Snitzer

    Ard Biesheuvel
     

30 Aug, 2019

3 commits

  • crypto/aegis.h:27:32: warning:
    crypto_aegis_const defined but not used [-Wunused-const-variable=]

    crypto_aegis_const is only used in aegis128-core.c,
    just move the definition over there.

    Reported-by: Hulk Robot
    Signed-off-by: YueHaibing
    Signed-off-by: Herbert Xu

    YueHaibing
     
  • Add a test vector for the ESSIV mode that is the most widely used,
    i.e., using cbc(aes) and sha256, in both skcipher and AEAD modes
    (the latter is used by tcrypt to encapsulate the authenc template
    or h/w instantiations of the same)

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • When building the new aegis128 NEON code in big endian mode, Clang
    complains about the const uint8x16_t permute vectors in the following
    way:

    crypto/aegis128-neon-inner.c:58:40: warning: vector initializers are not
    compatible with NEON intrinsics in big endian mode
    [-Wnonportable-vector-initialization]
    static const uint8x16_t shift_rows = {
    ^
    crypto/aegis128-neon-inner.c:58:40: note: consider using vld1q_u8() to
    initialize a vector from memory, or vcombine_u8(vcreate_u8(), vcreate_u8())
    to initialize from integer constants

    Since the same issue applies to the uint8x16x4_t loads of the AES Sbox,
    update those references as well. However, since GCC does not implement
    the vld1q_u8_x4() intrinsic, switch from IS_ENABLED() to a preprocessor
    conditional to conditionally include this code.

    Reported-by: Nathan Chancellor
    Signed-off-by: Ard Biesheuvel
    Tested-by: Nathan Chancellor
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     

22 Aug, 2019

2 commits

  • Drop the duplicate generic sha256 (and sha224) implementation from
    crypto/sha256_generic.c and use the implementation from
    lib/crypto/sha256.c instead.

    "diff -u lib/crypto/sha256.c sha256_generic.c" shows that the core
    sha256_transform function from both implementations is identical and
    the other code is functionally identical too.

    Suggested-by: Eric Biggers
    Signed-off-by: Hans de Goede
    Signed-off-by: Herbert Xu

    Hans de Goede
     
  • Before this commit lib/crypto/sha256.c has only been used in the s390 and
    x86 purgatory code, make it suitable for generic use:

    * Export interesting symbols
    * Add -D__DISABLE_EXPORTS to CFLAGS_sha256.o for purgatory builds to
    avoid the exports for the purgatory builds
    * Add to lib/crypto/Makefile and crypto/Kconfig

    Signed-off-by: Hans de Goede
    Signed-off-by: Herbert Xu

    Hans de Goede