]> www.infradead.org Git - users/dwmw2/linux.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Dec 2020 12:47:06 +0000 (13:47 +0100)
commita27249e80348f4be1b94de0e2189ffeecf879392
tree77edf78103ffee5378e2aa5f9284b5134506c7b3
parentd81fd62fe45f991ead9d9fb2b26b285a9a20a069
crypto: ecdh - avoid unaligned accesses in ecdh_set_secret()

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>
crypto/ecdh.c