18 Oct, 2022

1 commit


27 Sep, 2022

1 commit

  • This is the 5.15.70 stable release

    * tag 'v5.15.70': (2444 commits)
    Linux 5.15.70
    ALSA: hda/sigmatel: Fix unused variable warning for beep power change
    cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all()
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    arch/arm/boot/dts/imx6ul.dtsi
    arch/arm/mm/mmu.c
    arch/arm64/boot/dts/freescale/imx8mp-evk.dts
    drivers/gpu/drm/imx/dcss/dcss-kms.c
    drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
    drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h
    drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
    drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
    drivers/soc/fsl/Kconfig
    drivers/soc/imx/gpcv2.c
    drivers/usb/dwc3/host.c
    net/dsa/slave.c
    sound/soc/fsl/imx-card.c

    Jason Liu
     

17 Aug, 2022

2 commits

  • [ Upstream commit 0815291a8fd66cdcf7db1445d4d99b0d16065829 ]

    The signature verification of SM2 needs to add the Za value and
    recalculate sig->digest, which requires the detection of the pkey_algo
    in public_key_verify_signature(). As Eric Biggers said, the pkey_algo
    field in sig is attacker-controlled and should be use pkey->pkey_algo
    instead of sig->pkey_algo, and secondly, if sig->pkey_algo is NULL, it
    will also cause signature verification failure.

    The software_key_determine_akcipher() already forces the algorithms
    are matched, so the SM3 algorithm is enforced in the SM2 signature,
    although this has been checked, we still avoid using any algorithm
    information in the signature as input.

    Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
    Reported-by: Eric Biggers
    Cc: stable@vger.kernel.org # v5.10+
    Signed-off-by: Tianjia Zhang
    Reviewed-by: Jarkko Sakkinen
    Signed-off-by: Jarkko Sakkinen
    Signed-off-by: Sasha Levin

    Tianjia Zhang
     
  • [ Upstream commit 2d16803c562ecc644803d42ba98a8e0aef9c014e ]

    BLAKE2s has no currently known use as an shash. Just remove all of this
    unnecessary plumbing. Removing this shash was something we talked about
    back when we were making BLAKE2s a built-in, but I simply never got
    around to doing it. So this completes that project.

    Importantly, this fixs a bug in which the lib code depends on
    crypto_simd_disabled_for_test, causing linker errors.

    Also add more alignment tests to the selftests and compare SIMD and
    non-SIMD compression functions, to make up for what we lose from
    testmgr.c.

    Reported-by: gaochao
    Cc: Eric Biggers
    Cc: Ard Biesheuvel
    Cc: stable@vger.kernel.org
    Fixes: 6048fdcc5f26 ("lib/crypto: blake2s: include as built-in")
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Jason A. Donenfeld
     

30 Jun, 2022

2 commits

  • This is the 5.15.50 stable release

    * tag 'v5.15.50': (1395 commits)
    Linux 5.15.50
    arm64: mm: Don't invalidate FROM_DEVICE buffers at start of DMA transfer
    serial: core: Initialize rs485 RTS polarity already on probe
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    drivers/bus/fsl-mc/fsl-mc-bus.c
    drivers/crypto/caam/ctrl.c
    drivers/pci/controller/dwc/pci-imx6.c
    drivers/spi/spi-fsl-qspi.c
    drivers/tty/serial/fsl_lpuart.c
    include/uapi/linux/dma-buf.h

    Jason Liu
     
  • This is the 5.15.41 stable release

    * tag 'v5.15.41': (1977 commits)
    Linux 5.15.41
    usb: gadget: uvc: allow for application to cleanly shutdown
    usb: gadget: uvc: rename function to be more consistent
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi
    arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi
    arch/arm64/configs/defconfig
    drivers/clk/imx/clk-imx8qxp-lpcg.c
    drivers/dma/imx-sdma.c
    drivers/gpu/drm/bridge/nwl-dsi.c
    drivers/mailbox/imx-mailbox.c
    drivers/net/phy/at803x.c
    drivers/tty/serial/fsl_lpuart.c
    security/keys/trusted-keys/trusted_core.c

    Jason Liu
     

22 Jun, 2022

1 commit

  • commit abfed87e2a12bd246047d78c01d81eb9529f1d06 upstream.

    This is used by code that doesn't need CONFIG_CRYPTO, so move this into
    lib/ with a Kconfig option so that it can be selected by whatever needs
    it.

    This fixes a linker error Zheng pointed out when
    CRYPTO_MANAGER_DISABLE_TESTS!=y and CRYPTO=m:

    lib/crypto/curve25519-selftest.o: In function `curve25519_selftest':
    curve25519-selftest.c:(.init.text+0x60): undefined reference to `__crypto_memneq'
    curve25519-selftest.c:(.init.text+0xec): undefined reference to `__crypto_memneq'
    curve25519-selftest.c:(.init.text+0x114): undefined reference to `__crypto_memneq'
    curve25519-selftest.c:(.init.text+0x154): undefined reference to `__crypto_memneq'

    Reported-by: Zheng Bin
    Cc: Eric Biggers
    Cc: stable@vger.kernel.org
    Fixes: aa127963f1ca ("crypto: lib/curve25519 - re-add selftests")
    Signed-off-by: Jason A. Donenfeld
    Reviewed-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Jason A. Donenfeld
     

09 Jun, 2022

1 commit

  • [ Upstream commit 91e8bcd7b4da182e09ea19a2c73167345fe14c98 ]

    The access to cryptd_queue::cpu_queue is synchronized by disabling
    preemption in cryptd_enqueue_request() and disabling BH in
    cryptd_queue_worker(). This implies that access is allowed from BH.

    If cryptd_enqueue_request() is invoked from preemptible context _and_
    soft interrupt then this can lead to list corruption since
    cryptd_enqueue_request() is not protected against access from
    soft interrupt.

    Replace get_cpu() in cryptd_enqueue_request() with local_bh_disable()
    to ensure BH is always disabled.
    Remove preempt_disable() from cryptd_queue_worker() since it is not
    needed because local_bh_disable() ensures synchronisation.

    Fixes: 254eff771441 ("crypto: cryptd - Per-CPU thread implementation...")
    Signed-off-by: Sebastian Andrzej Siewior
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Sebastian Andrzej Siewior
     

06 Jun, 2022

6 commits

  • commit 7cc7ab73f83ee6d50dc9536bc3355495d8600fad upstream.

    Correctly compare values that shall be greater-or-equal and not just
    greater.

    Fixes: 0d7a78643f69 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm")
    Cc:
    Signed-off-by: Vitaly Chikunov
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Chikunov
     
  • commit 074bcd4000e0d812bc253f86fedc40f81ed59ccc upstream.

    get_random_bytes() usually hasn't full entropy available by the time DRBG
    instances are first getting seeded from it during boot. Thus, the DRBG
    implementation registers random_ready_callbacks which would in turn
    schedule some work for reseeding the DRBGs once get_random_bytes() has
    sufficient entropy available.

    For reference, the relevant history around handling DRBG (re)seeding in
    the context of a not yet fully seeded get_random_bytes() is:

    commit 16b369a91d0d ("random: Blocking API for accessing
    nonblocking_pool")
    commit 4c7879907edd ("crypto: drbg - add async seeding operation")

    commit 205a525c3342 ("random: Add callback API for random pool
    readiness")
    commit 57225e679788 ("crypto: drbg - Use callback API for random
    readiness")
    commit c2719503f5e1 ("random: Remove kernel blocking API")

    However, some time later, the initialization state of get_random_bytes()
    has been made queryable via rng_is_initialized() introduced with commit
    9a47249d444d ("random: Make crng state queryable"). This primitive now
    allows for streamlining the DRBG reseeding from get_random_bytes() by
    replacing that aforementioned asynchronous work scheduling from
    random_ready_callbacks with some simpler, synchronous code in
    drbg_generate() next to the related logic already present therein. Apart
    from improving overall code readability, this change will also enable DRBG
    users to rely on wait_for_random_bytes() for ensuring that the initial
    seeding has completed, if desired.

    The previous patches already laid the grounds by making drbg_seed() to
    record at each DRBG instance whether it was being seeded at a time when
    rng_is_initialized() still had been false as indicated by
    ->seeded == DRBG_SEED_STATE_PARTIAL.

    All that remains to be done now is to make drbg_generate() check for this
    condition, determine whether rng_is_initialized() has flipped to true in
    the meanwhile and invoke a reseed from get_random_bytes() if so.

    Make this move:
    - rename the former drbg_async_seed() work handler, i.e. the one in charge
    of reseeding a DRBG instance from get_random_bytes(), to
    "drbg_seed_from_random()",
    - change its signature as appropriate, i.e. make it take a struct
    drbg_state rather than a work_struct and change its return type from
    "void" to "int" in order to allow for passing error information from
    e.g. its __drbg_seed() invocation onwards to callers,
    - make drbg_generate() invoke this drbg_seed_from_random() once it
    encounters a DRBG instance with ->seeded == DRBG_SEED_STATE_PARTIAL by
    the time rng_is_initialized() has flipped to true and
    - prune everything related to the former, random_ready_callback based
    mechanism.

    As drbg_seed_from_random() is now getting invoked from drbg_generate() with
    the ->drbg_mutex being held, it must not attempt to recursively grab it
    once again. Remove the corresponding mutex operations from what is now
    drbg_seed_from_random(). Furthermore, as drbg_seed_from_random() can now
    report errors directly to its caller, there's no need for it to temporarily
    switch the DRBG's ->seeded state to DRBG_SEED_STATE_UNSEEDED so that a
    failure of the subsequently invoked __drbg_seed() will get signaled to
    drbg_generate(). Don't do it then.

    Signed-off-by: Nicolai Stange
    Signed-off-by: Herbert Xu
    [Jason: for stable, undid the modifications for the backport of 5acd3548.]
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Greg Kroah-Hartman

    Nicolai Stange
     
  • commit 262d83a4290c331cd4f617a457408bdb82fbb738 upstream.

    Since commit 42ea507fae1a ("crypto: drbg - reseed often if seedsource is
    degraded"), the maximum seed lifetime represented by ->reseed_threshold
    gets temporarily lowered if the get_random_bytes() source cannot provide
    sufficient entropy yet, as is common during boot, and restored back to
    the original value again once that has changed.

    More specifically, if the add_random_ready_callback() invoked from
    drbg_prepare_hrng() in the course of DRBG instantiation does not return
    -EALREADY, that is, if get_random_bytes() has not been fully initialized
    at this point yet, drbg_prepare_hrng() will lower ->reseed_threshold
    to a value of 50. The drbg_async_seed() scheduled from said
    random_ready_callback will eventually restore the original value.

    A future patch will replace the random_ready_callback based notification
    mechanism and thus, there will be no add_random_ready_callback() return
    value anymore which could get compared to -EALREADY.

    However, there's __drbg_seed() which gets invoked in the course of both,
    the DRBG instantiation as well as the eventual reseeding from
    get_random_bytes() in aforementioned drbg_async_seed(), if any. Moreover,
    it knows about the get_random_bytes() initialization state by the time the
    seed data had been obtained from it: the new_seed_state argument introduced
    with the previous patch would get set to DRBG_SEED_STATE_PARTIAL in case
    get_random_bytes() had not been fully initialized yet and to
    DRBG_SEED_STATE_FULL otherwise. Thus, __drbg_seed() provides a convenient
    alternative for managing that ->reseed_threshold lowering and restoring at
    a central place.

    Move all ->reseed_threshold adjustment code from drbg_prepare_hrng() and
    drbg_async_seed() respectively to __drbg_seed(). Make __drbg_seed()
    lower the ->reseed_threshold to 50 in case its new_seed_state argument
    equals DRBG_SEED_STATE_PARTIAL and let it restore the original value
    otherwise.

    There is no change in behaviour.

    Signed-off-by: Nicolai Stange
    Reviewed-by: Stephan Müller
    Signed-off-by: Herbert Xu
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Greg Kroah-Hartman

    Nicolai Stange
     
  • commit 2bcd25443868aa8863779a6ebc6c9319633025d2 upstream.

    Currently, the DRBG implementation schedules asynchronous works from
    random_ready_callbacks for reseeding the DRBG instances with output from
    get_random_bytes() once the latter has sufficient entropy available.

    However, as the get_random_bytes() initialization state can get queried by
    means of rng_is_initialized() now, there is no real need for this
    asynchronous reseeding logic anymore and it's better to keep things simple
    by doing it synchronously when needed instead, i.e. from drbg_generate()
    once rng_is_initialized() has flipped to true.

    Of course, for this to work, drbg_generate() would need some means by which
    it can tell whether or not rng_is_initialized() has flipped to true since
    the last seeding from get_random_bytes(). Or equivalently, whether or not
    the last seed from get_random_bytes() has happened when
    rng_is_initialized() was still evaluating to false.

    As it currently stands, enum drbg_seed_state allows for the representation
    of two different DRBG seeding states: DRBG_SEED_STATE_UNSEEDED and
    DRBG_SEED_STATE_FULL. The former makes drbg_generate() to invoke a full
    reseeding operation involving both, the rather expensive jitterentropy as
    well as the get_random_bytes() randomness sources. The DRBG_SEED_STATE_FULL
    state on the other hand implies that no reseeding at all is required for a
    !->pr DRBG variant.

    Introduce the new DRBG_SEED_STATE_PARTIAL state to enum drbg_seed_state for
    representing the condition that a DRBG was being seeded when
    rng_is_initialized() had still been false. In particular, this new state
    implies that
    - the given DRBG instance has been fully seeded from the jitterentropy
    source (if enabled)
    - and drbg_generate() is supposed to reseed from get_random_bytes()
    *only* once rng_is_initialized() turns to true.

    Up to now, the __drbg_seed() helper used to set the given DRBG instance's
    ->seeded state to constant DRBG_SEED_STATE_FULL. Introduce a new argument
    allowing for the specification of the to be written ->seeded value instead.
    Make the first of its two callers, drbg_seed(), determine the appropriate
    value based on rng_is_initialized(). The remaining caller,
    drbg_async_seed(), is known to get invoked only once rng_is_initialized()
    is true, hence let it pass constant DRBG_SEED_STATE_FULL for the new
    argument to __drbg_seed().

    There is no change in behaviour, except for that the pr_devel() in
    drbg_generate() would now report "unseeded" for ->pr DRBG instances which
    had last been seeded when rng_is_initialized() was still evaluating to
    false.

    Signed-off-by: Nicolai Stange
    Reviewed-by: Stephan Müller
    Signed-off-by: Herbert Xu
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Greg Kroah-Hartman

    Nicolai Stange
     
  • commit ce8ce31b2c5c8b18667784b8c515650c65d57b4e upstream.

    There are two different randomness sources the DRBGs are getting seeded
    from, namely the jitterentropy source (if enabled) and get_random_bytes().
    At initial DRBG seeding time during boot, the latter might not have
    collected sufficient entropy for seeding itself yet and thus, the DRBG
    implementation schedules a reseed work from a random_ready_callback once
    that has happened. This is particularly important for the !->pr DRBG
    instances, for which (almost) no further reseeds are getting triggered
    during their lifetime.

    Because collecting data from the jitterentropy source is a rather expensive
    operation, the aforementioned asynchronously scheduled reseed work
    restricts itself to get_random_bytes() only. That is, it in some sense
    amends the initial DRBG seed derived from jitterentropy output at full
    (estimated) entropy with fresh randomness obtained from get_random_bytes()
    once that has been seeded with sufficient entropy itself.

    With the advent of rng_is_initialized(), there is no real need for doing
    the reseed operation from an asynchronously scheduled work anymore and a
    subsequent patch will make it synchronous by moving it next to related
    logic already present in drbg_generate().

    However, for tracking whether a full reseed including the jitterentropy
    source is required or a "partial" reseed involving only get_random_bytes()
    would be sufficient already, the boolean struct drbg_state's ->seeded
    member must become a tristate value.

    Prepare for this by introducing the new enum drbg_seed_state and change
    struct drbg_state's ->seeded member's type from bool to that type.

    For facilitating review, enum drbg_seed_state is made to only contain
    two members corresponding to the former ->seeded values of false and true
    resp. at this point: DRBG_SEED_STATE_UNSEEDED and DRBG_SEED_STATE_FULL. A
    third one for tracking the intermediate state of "seeded from jitterentropy
    only" will be introduced with a subsequent patch.

    There is no change in behaviour at this point.

    Signed-off-by: Nicolai Stange
    Reviewed-by: Stephan Müller
    Signed-off-by: Herbert Xu
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Greg Kroah-Hartman

    Nicolai Stange
     
  • commit e56e18985596617ae426ed5997fb2e737cffb58b upstream.

    Commit 6048fdcc5f269 ("lib/crypto: blake2s: include as built-in") took
    away a number of prompt texts from other crypto libraries. This makes
    values flip from built-in to module when oldconfig runs, and causes
    problems when these crypto libs need to be built in for thingslike
    BIG_KEYS.

    Fixes: 6048fdcc5f269 ("lib/crypto: blake2s: include as built-in")
    Cc: Herbert Xu
    Cc: linux-crypto@vger.kernel.org
    Signed-off-by: Justin M. Forbes
    [Jason: - moved menu into submenu of lib/ instead of root menu
    - fixed chacha sub-dependencies for CONFIG_CRYPTO]
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Greg Kroah-Hartman

    Justin M. Forbes
     

30 May, 2022

3 commits

  • commit 5acd35487dc911541672b3ffc322851769c32a56 upstream.

    We previously rolled our own randomness readiness notifier, which only
    has two users in the whole kernel. Replace this with a more standard
    atomic notifier block that serves the same purpose with less code. Also
    unexport the symbols, because no modules use it, only unconditional
    builtins. The only drawback is that it's possible for a notification
    handler returning the "stop" code to prevent further processing, but
    given that there are only two users, and that we're unexporting this
    anyway, that doesn't seem like a significant drawback for the
    simplification we receive here.

    Cc: Greg Kroah-Hartman
    Cc: Theodore Ts'o
    Reviewed-by: Dominik Brodowski
    [Jason: for stable, also backported to crypto/drbg.c, not unexporting.]
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Greg Kroah-Hartman

    Jason A. Donenfeld
     
  • commit d2a02e3c8bb6b347818518edff5a4b40ff52d6d8 upstream.

    blake2s_compress_generic is weakly aliased by blake2s_compress. The
    current harness for function selection uses a function pointer, which is
    ordinarily inlined and resolved at compile time. But when Clang's CFI is
    enabled, CFI still triggers when making an indirect call via a weak
    symbol. This seems like a bug in Clang's CFI, as though it's bucketing
    weak symbols and strong symbols differently. It also only seems to
    trigger when "full LTO" mode is used, rather than "thin LTO".

    [ 0.000000][ T0] Kernel panic - not syncing: CFI failure (target: blake2s_compress_generic+0x0/0x1444)
    [ 0.000000][ T0] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.16.0-mainline-06981-g076c855b846e #1
    [ 0.000000][ T0] Hardware name: MT6873 (DT)
    [ 0.000000][ T0] Call trace:
    [ 0.000000][ T0] dump_backtrace+0xfc/0x1dc
    [ 0.000000][ T0] dump_stack_lvl+0xa8/0x11c
    [ 0.000000][ T0] panic+0x194/0x464
    [ 0.000000][ T0] __cfi_check_fail+0x54/0x58
    [ 0.000000][ T0] __cfi_slowpath_diag+0x354/0x4b0
    [ 0.000000][ T0] blake2s_update+0x14c/0x178
    [ 0.000000][ T0] _extract_entropy+0xf4/0x29c
    [ 0.000000][ T0] crng_initialize_primary+0x24/0x94
    [ 0.000000][ T0] rand_initialize+0x2c/0x6c
    [ 0.000000][ T0] start_kernel+0x2f8/0x65c
    [ 0.000000][ T0] __primary_switched+0xc4/0x7be4
    [ 0.000000][ T0] Rebooting in 5 seconds..

    Nonetheless, the function pointer method isn't so terrific anyway, so
    this patch replaces it with a simple boolean, which also gets inlined
    away. This successfully works around the Clang bug.

    In general, I'm not too keen on all of the indirection involved here; it
    clearly does more harm than good. Hopefully the whole thing can get
    cleaned up down the road when lib/crypto is overhauled more
    comprehensively. But for now, we go with a simple bandaid.

    Fixes: 6048fdcc5f26 ("lib/crypto: blake2s: include as built-in")
    Link: https://github.com/ClangBuiltLinux/linux/issues/1567
    Reported-by: Miles Chen
    Tested-by: Miles Chen
    Tested-by: Nathan Chancellor
    Tested-by: John Stultz
    Acked-by: Nick Desaulniers
    Reviewed-by: Eric Biggers
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Greg Kroah-Hartman

    Jason A. Donenfeld
     
  • commit 6048fdcc5f269c7f31d774c295ce59081b36e6f9 upstream.

    In preparation for using blake2s in the RNG, we change the way that it
    is wired-in to the build system. Instead of using ifdefs to select the
    right symbol, we use weak symbols. And because ARM doesn't need the
    generic implementation, we make the generic one default only if an arch
    library doesn't need it already, and then have arch libraries that do
    need it opt-in. So that the arch libraries can remain tristate rather
    than bool, we then split the shash part from the glue code.

    Acked-by: Herbert Xu
    Acked-by: Ard Biesheuvel
    Acked-by: Greg Kroah-Hartman
    Cc: Masahiro Yamada
    Cc: linux-kbuild@vger.kernel.org
    Cc: linux-crypto@vger.kernel.org
    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Greg Kroah-Hartman

    Jason A. Donenfeld
     

08 Apr, 2022

8 commits

  • [ Upstream commit dfe085d8dcd0bb1fe20cc2327e81c8064cead441 ]

    The xts module needs ecb to be present as it's meant to work
    on top of ecb. This patch adds a softdep so ecb can be included
    automatically into the initramfs.

    Reported-by: rftc
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Herbert Xu
     
  • [ Upstream commit 66eae850333d639fc278d6f915c6fc01499ea893 ]

    The function crypto_authenc_decrypt_tail discards its flags
    argument and always relies on the flags from the original request
    when starting its sub-request.

    This is clearly wrong as it may cause the SLEEPABLE flag to be
    set when it shouldn't.

    Fixes: 92d95ba91772 ("crypto: authenc - Convert to new AEAD interface")
    Reported-by: Corentin Labbe
    Signed-off-by: Herbert Xu
    Tested-by: Corentin Labbe
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Herbert Xu
     
  • commit a24611ea356c7f3f0ec926da11b9482ac1f414fd upstream.

    Before checking whether the expected digest_info is present, we need to
    check that there are enough bytes remaining.

    Fixes: a49de377e051 ("crypto: Add hash param to pkcs1pad")
    Cc: # v4.6+
    Cc: Tadeusz Struk
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     
  • commit d3481accd974541e6a5d6a1fb588924a3519c36e upstream.

    RSA PKCS#1 v1.5 signatures are required to be the same length as the RSA
    key size. RFC8017 specifically requires the verifier to check this
    (https://datatracker.ietf.org/doc/html/rfc8017#section-8.2.2).

    Commit a49de377e051 ("crypto: Add hash param to pkcs1pad") changed the
    kernel to allow longer signatures, but didn't explain this part of the
    change; it seems to be unrelated to the rest of the commit.

    Revert this change, since it doesn't appear to be correct.

    We can be pretty sure that no one is relying on overly-long signatures
    (which would have to be front-padded with zeroes) being supported, given
    that they would have been broken since commit c7381b012872
    ("crypto: akcipher - new verify API for public key algorithms").

    Fixes: a49de377e051 ("crypto: Add hash param to pkcs1pad")
    Cc: # v4.6+
    Cc: Tadeusz Struk
    Suggested-by: Vitaly Chikunov
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     
  • commit e316f7179be22912281ce6331d96d7c121fb2b17 upstream.

    Commit c7381b012872 ("crypto: akcipher - new verify API for public key
    algorithms") changed akcipher_alg::verify to take in both the signature
    and the actual hash and do the signature verification, rather than just
    return the hash expected by the signature as was the case before. To do
    this, it implemented a hack where the signature and hash are
    concatenated with each other in one scatterlist.

    Obviously, for this to work correctly, akcipher_alg::verify needs to
    correctly extract the two items from the scatterlist it is given.
    Unfortunately, it doesn't correctly extract the hash in the case where
    the signature is longer than the RSA key size, as it assumes that the
    signature's length is equal to the RSA key size. This causes a prefix
    of the hash, or even the entire hash, to be taken from the *signature*.

    (Note, the case of a signature longer than the RSA key size should not
    be allowed in the first place; a separate patch will fix that.)

    It is unclear whether the resulting scheme has any useful security
    properties.

    Fix this by correctly extracting the hash from the scatterlist.

    Fixes: c7381b012872 ("crypto: akcipher - new verify API for public key algorithms")
    Cc: # v5.2+
    Reviewed-by: Vitaly Chikunov
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     
  • commit 9b30430ea356f237945e52f8a3a42158877bd5a9 upstream.

    The pkcs1pad template can be instantiated with an arbitrary akcipher
    algorithm, which doesn't make sense; it is specifically an RSA padding
    scheme. Make it check that the underlying algorithm really is RSA.

    Fixes: 3d5b1ecdea6f ("crypto: rsa - RSA padding algorithm")
    Cc: # v4.5+
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     
  • commit 590bfb57b2328951d5833979e7ca1d5fde2e609a upstream.

    It is insecure to allow arbitrary hash algorithms and signature
    encodings to be used with arbitrary signature algorithms. Notably,
    ECDSA, ECRDSA, and SM2 all sign/verify raw hash values and don't
    disambiguate between different hash algorithms like RSA PKCS#1 v1.5
    padding does. Therefore, they need to be restricted to certain sets of
    hash algorithms (ideally just one, but in practice small sets are used).
    Additionally, the encoding is an integral part of modern signature
    algorithms, and is not supposed to vary.

    Therefore, tighten the checks of hash_algo and encoding done by
    software_key_determine_akcipher().

    Also rearrange the parameters to software_key_determine_akcipher() to
    put the public_key first, as this is the most important parameter and it
    often determines everything else.

    Fixes: 299f561a6693 ("x509: Add support for parsing x509 certs with ECDSA keys")
    Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
    Fixes: 0d7a78643f69 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm")
    Cc: stable@vger.kernel.org
    Tested-by: Stefan Berger
    Tested-by: Tianjia Zhang
    Signed-off-by: Eric Biggers
    Reviewed-by: Vitaly Chikunov
    Reviewed-by: Jarkko Sakkinen
    Signed-off-by: Jarkko Sakkinen
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     
  • commit 2abc9c246e0548e52985b10440c9ea3e9f65f793 upstream.

    Most callers of public_key_verify_signature(), including most indirect
    callers via verify_signature() as well as pkcs7_verify_sig_chain(),
    don't check that public_key_signature::pkey_algo matches
    public_key::pkey_algo. These should always match. However, a malicious
    signature could intentionally declare an unintended algorithm. It is
    essential that such signatures be rejected outright, or that the
    algorithm of the *key* be used -- not the algorithm of the signature as
    that would allow attackers to choose the algorithm used.

    Currently, public_key_verify_signature() correctly uses the key's
    algorithm when deciding which akcipher to allocate. That's good.
    However, it uses the signature's algorithm when deciding whether to do
    the first step of SM2, which is incorrect. Also, v4.19 and older
    kernels used the signature's algorithm for the entire process.

    Prevent such errors by making public_key_verify_signature() enforce that
    the signature's algorithm (if given) matches the key's algorithm.

    Also remove two checks of this done by callers, which are now redundant.

    Cc: stable@vger.kernel.org
    Tested-by: Stefan Berger
    Tested-by: Tianjia Zhang
    Signed-off-by: Eric Biggers
    Reviewed-by: Vitaly Chikunov
    Reviewed-by: Jarkko Sakkinen
    Signed-off-by: Jarkko Sakkinen
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     

11 Mar, 2022

1 commit

  • This is the 5.15.27 stable release

    * tag 'v5.15.27': (3069 commits)
    Linux 5.15.27
    hamradio: fix macro redefine warning
    KVM: x86/mmu: Passing up the error state of mmu_alloc_shadow_roots()
    ...

    Signed-off-by: Jason Liu

    Conflicts:
    arch/arm/boot/dts/imx7ulp.dtsi
    arch/arm64/boot/dts/freescale/fsl-ls1028a-qds.dts
    arch/arm64/boot/dts/freescale/imx8mq.dtsi
    drivers/dma-buf/heaps/cma_heap.c
    drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
    drivers/gpu/drm/mxsfb/mxsfb_kms.c
    drivers/mmc/host/sdhci-esdhc-imx.c
    drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
    drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
    drivers/rpmsg/rpmsg_char.c
    drivers/soc/imx/gpcv2.c
    drivers/thermal/imx_thermal.c

    Jason Liu
     

11 Feb, 2022

1 commit

  • commit c6ce9c5831cae515d375a01b97ae1778689acf19 upstream.

    The soft dependency on cryptomgr is only needed in algapi because
    if algapi isn't present then no algorithms can be loaded. This
    also fixes the case where api is built-in but algapi is built as
    a module as the soft dependency would otherwise get lost.

    Fixes: 8ab23d547f65 ("crypto: api - Add softdep on cryptomgr")
    Reported-by: Jan Beulich
    Signed-off-by: Herbert Xu
    Tested-by: Jan Beulich
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Herbert Xu
     

27 Jan, 2022

1 commit

  • [ Upstream commit 552d03a223eda3df84526ab2c1f4d82e15eaee7a ]

    The APT compares the current time stamp with a pre-set value. The
    current code only considered the 4 LSB only. Yet, after reviews by
    mathematicians of the user space Jitter RNG version >= 3.1.0, it was
    concluded that the APT can be calculated on the 32 LSB of the time
    delta. Thi change is applied to the kernel.

    This fixes a bug where an AMD EPYC fails this test as its RDTSC value
    contains zeros in the LSB. The most appropriate fix would have been to
    apply a GCD calculation and divide the time stamp by the GCD. Yet, this
    is a significant code change that will be considered for a future
    update. Note, tests showed that constantly the GCD always was 32 on
    these systems, i.e. the 5 LSB were always zero (thus failing the APT
    since it only considered the 4 LSB for its calculation).

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Stephan Müller
     

26 Jan, 2022

1 commit

  • Fix the following compilation warning
    that shows up due to implicit switch case fall-through.

    crypto/testmgr.c: In function ‘__test_tls’:
    crypto/testmgr.c:2693:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    2693 | if (template[i].novrfy)
    | ^
    crypto/testmgr.c:2696:3: note: here
    2696 | default:
    | ^~~~~~~

    Fixes: 922c229d9f78c ("crypto: add support for TLS 1.0 record encryption")
    Link: https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
    Signed-off-by: Horia Geantă
    Reviewed-by: Dong Aisheng

    Horia Geantă
     

21 Jan, 2022

1 commit

  • Fix the typo in tls11 and tls12 tests:
    -tls11 uses tls12 test vectors
    -tls12 uses tls11 test vectors

    Fixes: d6299c231b2e ("Added the self-test for the TLS1.2 algorithms offload")
    Reviewed-by: Pankaj Gupta
    Tested-by: Pankaj Gupta
    Reviewed-by: Gaurav Jain
    Signed-off-by: Horia Geantă

    Horia Geantă
     

01 Dec, 2021

1 commit

  • This is the 5.15.5 stable release

    * tag 'v5.15.5': (1261 commits)
    Linux 5.15.5
    ALSA: hda: hdac_stream: fix potential locking issue in snd_hdac_stream_assign()
    ALSA: hda: hdac_ext_stream: fix potential locking issues
    ...

    Conflicts:
    arch/powerpc/platforms/85xx/Makefile
    drivers/crypto/caam/caampkc.c
    drivers/gpu/drm/bridge/nwl-dsi.c
    drivers/gpu/drm/imx/imx-drm-core.c
    drivers/remoteproc/imx_rproc.c
    drivers/soc/imx/gpcv2.c
    include/linux/rpmsg.h

    Jason Liu
     

19 Nov, 2021

3 commits

  • [ Upstream commit 68b6dea802cea0dbdd8bd7ccc60716b5a32a5d8a ]

    These three events can race when pcrypt is used multiple times in a
    template ("pcrypt(pcrypt(...))"):

    1. [taskA] The caller makes the crypto request via crypto_aead_encrypt()
    2. [kworkerB] padata serializes the inner pcrypt request
    3. [kworkerC] padata serializes the outer pcrypt request

    3 might finish before the call to crypto_aead_encrypt() returns in 1,
    resulting in two possible issues.

    First, a use-after-free of the crypto request's memory when, for
    example, taskA writes to the outer pcrypt request's padata->info in
    pcrypt_aead_enc() after kworkerC completes the request.

    Second, the outer pcrypt request overwrites the inner pcrypt request's
    return code with -EINPROGRESS, making a successful request appear to
    fail. For instance, kworkerB writes the outer pcrypt request's
    padata->info in pcrypt_aead_done() and then taskA overwrites it
    in pcrypt_aead_enc().

    Avoid both situations by delaying the write of padata->info until after
    the inner crypto request's return code is checked. This prevents the
    use-after-free by not touching the crypto request's memory after the
    next-inner crypto request is made, and stops padata->info from being
    overwritten.

    Fixes: 5068c7a883d16 ("crypto: pcrypt - Add pcrypt crypto parallelization wrapper")
    Reported-by: syzbot+b187b77c8474f9648fae@syzkaller.appspotmail.com
    Signed-off-by: Daniel Jordan
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Daniel Jordan
     
  • [ Upstream commit 3ae88f676aa63366ffa9eebb8ae787c7e19f0c57 ]

    Commit ad6d66bcac77e ("crypto: tcrypt - include 1420 byte blocks in aead and skcipher benchmarks")
    mentions:
    > power-of-2 block size. So let's add 1420 bytes explicitly, and round
    > it up to the next blocksize multiple of the algo in question if it
    > does not support 1420 byte blocks.
    but misses updating skcipher multi-buffer tests.

    Fix this by using the proper (rounded) input size.

    Fixes: ad6d66bcac77e ("crypto: tcrypt - include 1420 byte blocks in aead and skcipher benchmarks")
    Signed-off-by: Horia Geantă
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Horia Geantă
     
  • [ Upstream commit 38aa192a05f22f9778f9420e630f0322525ef12e ]

    The ecc.c file started out as part of the ECDH algorithm but got
    moved out into a standalone module later. It does not build without
    CRYPTO_DEFAULT_RNG, so now that other modules are using it as well we
    can run into this link error:

    aarch64-linux-ld: ecc.c:(.text+0xfc8): undefined reference to `crypto_default_rng'
    aarch64-linux-ld: ecc.c:(.text+0xff4): undefined reference to `crypto_put_default_rng'

    Move the 'select CRYPTO_DEFAULT_RNG' statement into the correct symbol.

    Fixes: 0d7a78643f69 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm")
    Fixes: 4e6602916bc6 ("crypto: ecdsa - Add support for ECDSA signature verification")
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Stefan Berger
    Signed-off-by: Herbert Xu
    Signed-off-by: Sasha Levin

    Arnd Bergmann
     

02 Nov, 2021

6 commits

  • - aes-128-cbc-hmac-sha256
    - aes-256-cbc-hmac-sha256

    Signed-off-by: Pankaj Gupta

    Pankaj Gupta
     
  • Commit ad6d66bcac77e ("crypto: tcrypt - include 1420 byte blocks in aead and skcipher benchmarks")
    mentions:
    > power-of-2 block size. So let's add 1420 bytes explicitly, and round
    > it up to the next blocksize multiple of the algo in question if it
    > does not support 1420 byte blocks.
    but misses updating skcipher multi-buffer tests.

    Fix this by using the proper (rounded) input size.

    Fixes: ad6d66bcac77e ("crypto: tcrypt - include 1420 byte blocks in aead and skcipher benchmarks")
    Signed-off-by: Horia Geantă
    Reviewed-by: Gaurav Jain

    Horia Geantă
     
  • Signed-off-by: Radu Alexe

    Radu Alexe
     
  • 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

    Horia Geantă
     
  • 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ă

    Merged LF commit (rebase-20200703/crypto/core):
    856fb52acc28 ("crypto: tls - fix logical-not-parentheses compile warning")

    Merged LF commit (next-nxp-20200811):
    0f90a0618247 ("crypto: tls: fix build issue")

    Signed-off-by: Horia Geantă

    Radu Alexe