Commit 1199ee3d authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Yongqiang Liu
Browse files

crypto: ecdh - avoid unaligned accesses in ecdh_set_secret()

stable inclusion
from stable-v4.19.164
commit 85637bc064f4fd5539d4173798d8cb55dde7fc0a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I65ZD2


CVE: NA

--------------------------------

commit 17858b14 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: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarGUO Zihua <guozihua@huawei.com>
Reviewed-by: default avatarWang Weiyang <wangweiyang2@huawei.com>
Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
parent 6f52decc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment