]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
crypto: ecdh - avoid unaligned accesses in ecdh_set_secret()
authorArd Biesheuvel <ardb@kernel.org>
Tue, 24 Nov 2020 10:47:19 +0000 (11:47 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 20 Jan 2021 13:26:22 +0000 (14:26 +0100)
commit43d54b83ccd09cf0b06d1aae845872d3f799d10a
treeb66f27f127c4ca8a06969d1a9e536fdb14f58559
parent4dc6dc9e00df1c876b890d8a623ca8fbbdbb6493
crypto: ecdh - avoid unaligned accesses in ecdh_set_secret()

BugLink: https://bugs.launchpad.net/bugs/1910822
commit 17858b140bf49961b71d4e73f1c3ea9bc8e7dda0 upstream.

ecdh_set_secret() casts a void* pointer to a const u64* in order to
feed it into ecc_is_key_valid(). This is not generally permitted by
the C standard, and leads to actual misalignment faults on ARMv6
cores. In some cases, these are fixed up in software, but this still
leads to performance hits that are entirely avoidable.

So let's copy the key into the ctx buffer first, which we will do
anyway in the common case, and which guarantees correct alignment.

Cc: <stable@vger.kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
crypto/ecdh.c