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
     

03 Sep, 2020

1 commit

  • commit c195d66a8a75c60515819b101975f38b7ec6577f upstream.

    The iwd daemon uses libell which sets up the skcipher operation with
    two separate control messages. As the first control message is sent
    without MSG_MORE, it is interpreted as an empty request.

    While libell should be fixed to use MSG_MORE where appropriate, this
    patch works around the bug in the kernel so that existing binaries
    continue to work.

    We will print a warning however.

    A separate issue is that the new kernel code no longer allows the
    control message to be sent twice within the same request. This
    restriction is obviously incompatible with what iwd was doing (first
    setting an IV and then sending the real control message). This
    patch changes the kernel so that this is explicitly allowed.

    Reported-by: Caleb Jorden
    Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when...")
    Cc:
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     

21 Aug, 2020

3 commits

  • [ Upstream commit 21dfbcd1f5cbff9cf2f9e7e43475aed8d072b0dd ]

    In skcipher_accept_parent_nokey() the whole af_alg_ctx structure is
    cleared by memset() after allocation, so add such memset() also to
    aead_accept_parent_nokey() so that the new "init" field is also
    initialized to zero. Without that the initial ctx->init checks might
    randomly return true and cause errors.

    While there, also remove the redundant zero assignments in both
    functions.

    Found via libkcapi testsuite.

    Cc: Stephan Mueller
    Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when ctx->more is zero")
    Suggested-by: Herbert Xu
    Signed-off-by: Ondrej Mosnacek
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Ondrej Mosnacek
     
  • [ Upstream commit 662bb52f50bca16a74fe92b487a14d7dccb85e1a ]

    Some user-space programs rely on crypto requests that have no
    control metadata. This broke when a check was added to require
    the presence of control metadata with the ctx->init flag.

    This patch fixes the regression by setting ctx->init as long as
    one sendmsg(2) has been made, with or without a control message.

    Reported-by: Sachin Sant
    Reported-by: Naresh Kamboju
    Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when...")
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Herbert Xu
     
  • [ Upstream commit f3c802a1f30013f8f723b62d7fa49eb9e991da23 ]

    AEAD does not support partial requests so we must not wake up
    while ctx->more is set. In order to distinguish between the
    case of no data sent yet and a zero-length request, a new init
    flag has been added to ctx.

    SKCIPHER has also been modified to ensure that at least a block
    of data is available if there is more data to come.

    Fixes: 2d97591ef43d ("crypto: af_alg - consolidation of...")
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Herbert Xu
     

22 Jul, 2020

1 commit

  • [ Upstream commit 6cbba1f9114a8134cff9138c79add15012fd52b9 ]

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

    Fixes: f1774cb8956a ("X.509: parse public key parameters from x509 for akcipher")
    Signed-off-by: Wei Yongjun
    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Wei Yongjun
     

09 Jul, 2020

1 commit

  • commit 34c86f4c4a7be3b3e35aa48bd18299d4c756064d upstream.

    The locking in af_alg_release_parent is broken as the BH socket
    lock can only be taken if there is a code-path to handle the case
    where the lock is owned by process-context. Instead of adding
    such handling, we can fix this by changing the ref counts to
    atomic_t.

    This patch also modifies the main refcnt to include both normal
    and nokey sockets. This way we don't have to fudge the nokey
    ref count when a socket changes from nokey to normal.

    Credits go to Mauricio Faria de Oliveira who diagnosed this bug
    and sent a patch for it:

    https://lore.kernel.org/linux-crypto/20200605161657.535043-1-mfo@canonical.com/

    Reported-by: Brian Moyles
    Reported-by: Mauricio Faria de Oliveira
    Fixes: 37f96694cf73 ("crypto: af_alg - Use bh_lock_sock in...")
    Cc:
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     

24 Jun, 2020

2 commits

  • commit 77251e41f89a813b4090f5199442f217bbf11297 upstream.

    When a crypto template needs to be instantiated, CRYPTO_MSG_ALG_REQUEST
    is sent to crypto_chain. cryptomgr_schedule_probe() handles this by
    starting a thread to instantiate the template, then waiting for this
    thread to complete via crypto_larval::completion.

    This can deadlock because instantiating the template may require loading
    modules, and this (apparently depending on userspace) may need to wait
    for the crc-t10dif module (lib/crc-t10dif.c) to be loaded. But
    crc-t10dif's module_init function uses crypto_register_notifier() and
    therefore takes crypto_chain.rwsem for write. That can't proceed until
    the notifier callback has finished, as it holds this semaphore for read.

    Fix this by removing the wait on crypto_larval::completion from within
    cryptomgr_schedule_probe(). It's actually unnecessary because
    crypto_alg_mod_lookup() calls crypto_larval_wait() itself after sending
    CRYPTO_MSG_ALG_REQUEST.

    This only actually became a problem in v4.20 due to commit b76377543b73
    ("crc-t10dif: Pick better transform if one becomes available"), but the
    unnecessary wait was much older.

    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207159
    Reported-by: Mike Gerow
    Fixes: 398710379f51 ("crypto: algapi - Move larval completion into algboss")
    Cc: # v3.6+
    Cc: Martin K. Petersen
    Signed-off-by: Eric Biggers
    Reported-by: Kai Lüke
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     
  • commit 7cf81954705b7e5b057f7dc39a7ded54422ab6e1 upstream.

    Somewhere along the line the cap on the SG list length for receive
    was lost. This patch restores it and removes the subsequent test
    which is now redundant.

    Fixes: 2d97591ef43d ("crypto: af_alg - consolidation of...")
    Cc:
    Signed-off-by: Herbert Xu
    Reviewed-by: Stephan Mueller
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     

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

2 commits

  • commit e0664ebcea6ac5e16da703409fb4bd61f8cd37d9 upstream.

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

    Reported-by: Xiumei Mu
    Fixes: db07cd26ac6a ("crypto: drbg - add FIPS 140-2 CTRNG for noise source")
    Cc:
    Signed-off-by: Wei Yongjun
    Reviewed-by: Stephan Mueller
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Wei Yongjun
     
  • commit beeb460cd12ac9b91640b484b6a52dcba9d9fc8f upstream.

    Currently after any algorithm is registered and tested, there's an
    unnecessary request_module("cryptomgr") even if it's already loaded.
    Also, CRYPTO_MSG_ALG_LOADED is sent twice, and thus if the algorithm is
    "crct10dif", lib/crc-t10dif.c replaces the tfm twice rather than once.

    This occurs because CRYPTO_MSG_ALG_LOADED is sent using
    crypto_probing_notify(), which tries to load "cryptomgr" if the
    notification is not handled (NOTIFY_DONE). This doesn't make sense
    because "cryptomgr" doesn't handle this notification.

    Fix this by using crypto_notify() instead of crypto_probing_notify().

    Fixes: dd8b083f9a5e ("crypto: api - Introduce notifier for new crypto algorithms")
    Cc: # v4.20+
    Cc: Martin K. Petersen
    Signed-off-by: Eric Biggers
    Reviewed-by: Martin K. Petersen
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     

20 May, 2020

1 commit

  • commit 1a263ae60b04de959d9ce9caea4889385eefcc7b upstream.

    gcc-10 has started warning about conflicting types for a few new
    built-in functions, particularly 'free()'.

    This results in warnings like:

    crypto/xts.c:325:13: warning: conflicting types for built-in function ‘free’; expected ‘void(void *)’ [-Wbuiltin-declaration-mismatch]

    because the crypto layer had its local freeing functions called
    'free()'.

    Gcc-10 is in the wrong here, since that function is marked 'static', and
    thus there is no chance of confusion with any standard library function
    namespace.

    But the simplest thing to do is to just use a different name here, and
    avoid this gcc mis-feature.

    [ Side note: gcc knowing about 'free()' is in itself not the
    mis-feature: the semantics of 'free()' are special enough that a
    compiler can validly do special things when seeing it.

    So the mis-feature here is that gcc thinks that 'free()' is some
    restricted name, and you can't shadow it as a local static function.

    Making the special 'free()' semantics be a function attribute rather
    than tied to the name would be the much better model ]

    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Linus Torvalds
     

17 Apr, 2020

1 commit


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

1 commit

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

    From the original description:

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

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

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

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

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

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

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

    lockdown={integrity|confidentiality}

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

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

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

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

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

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

    Linus Torvalds