aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorHangbin Liu <liuhangbin@gmail.com>2021-06-03 01:53:40 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2021-06-11 12:08:36 +0200
commitdda2052f931b4b457d0ceefe4117b31c02db4ec4 (patch)
tree1fe1ae819b5b6aa1617e64a16b8af4c5bc11664f
parentwireguard: allowedips: free empty intermediate nodes when removing single node (diff)
downloadwireguard-linux-backport-5.4.y.tar.xz
wireguard-linux-backport-5.4.y.zip
crypto: x86/curve25519 - fix cpu feature checking logic in mod_exitbackport-5.4.y
commit 1b82435d17774f3eaab35dce239d354548aa9da2 upstream. In curve25519_mod_init() the curve25519_alg will be registered only when (X86_FEATURE_BMI2 && X86_FEATURE_ADX). But in curve25519_mod_exit() it still checks (X86_FEATURE_BMI2 || X86_FEATURE_ADX) when do crypto unregister. This will trigger a BUG_ON in crypto_unregister_alg() as alg->cra_refcnt is 0 if the cpu only supports one of X86_FEATURE_BMI2 and X86_FEATURE_ADX. Fixes: 07b586fe0662 ("crypto: x86/curve25519 - replace with formally verified implementation") Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--arch/x86/crypto/curve25519-x86_64.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/crypto/curve25519-x86_64.c b/arch/x86/crypto/curve25519-x86_64.c
index a9edb6f8a0ba..3fcbe873f2f5 100644
--- a/arch/x86/crypto/curve25519-x86_64.c
+++ b/arch/x86/crypto/curve25519-x86_64.c
@@ -1499,7 +1499,7 @@ static int __init curve25519_mod_init(void)
static void __exit curve25519_mod_exit(void)
{
if (IS_REACHABLE(CONFIG_CRYPTO_KPP) &&
- (boot_cpu_has(X86_FEATURE_BMI2) || boot_cpu_has(X86_FEATURE_ADX)))
+ static_branch_likely(&curve25519_use_bmi2_adx))
crypto_unregister_kpp(&curve25519_alg);
}