mirror of
https://github.com/torvalds/linux.git
synced 2024-12-15 15:41:58 +00:00
877ccce7cb
It turns out I had misunderstood how the x86_match_cpu() function works. It evaluates a logical OR of the matching conditions, not logical AND. This caused the CPU feature checks for AEGIS to pass even if only SSE2 (but not AES-NI) was supported (or vice versa), leading to potential crashes if something tried to use the registered algs. This patch switches the checks to a simpler method that is used e.g. in the Camellia x86 code. The patch also removes the MODULE_DEVICE_TABLE declarations which actually seem to cause the modules to be auto-loaded at boot, which is not desired. The crypto API on-demand module loading is sufficient. Fixes:1d373d4e8e
("crypto: x86 - Add optimized AEGIS implementations") Fixes:6ecc9d9ff9
("crypto: x86 - Add optimized MORUS implementations") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Tested-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
65 lines
2.2 KiB
C
65 lines
2.2 KiB
C
/*
|
|
* The MORUS-1280 Authenticated-Encryption Algorithm
|
|
* Glue for AVX2 implementation
|
|
*
|
|
* Copyright (c) 2016-2018 Ondrej Mosnacek <omosnacek@gmail.com>
|
|
* Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
* any later version.
|
|
*/
|
|
|
|
#include <crypto/internal/aead.h>
|
|
#include <crypto/morus1280_glue.h>
|
|
#include <linux/module.h>
|
|
#include <asm/fpu/api.h>
|
|
#include <asm/cpu_device_id.h>
|
|
|
|
asmlinkage void crypto_morus1280_avx2_init(void *state, const void *key,
|
|
const void *iv);
|
|
asmlinkage void crypto_morus1280_avx2_ad(void *state, const void *data,
|
|
unsigned int length);
|
|
|
|
asmlinkage void crypto_morus1280_avx2_enc(void *state, const void *src,
|
|
void *dst, unsigned int length);
|
|
asmlinkage void crypto_morus1280_avx2_dec(void *state, const void *src,
|
|
void *dst, unsigned int length);
|
|
|
|
asmlinkage void crypto_morus1280_avx2_enc_tail(void *state, const void *src,
|
|
void *dst, unsigned int length);
|
|
asmlinkage void crypto_morus1280_avx2_dec_tail(void *state, const void *src,
|
|
void *dst, unsigned int length);
|
|
|
|
asmlinkage void crypto_morus1280_avx2_final(void *state, void *tag_xor,
|
|
u64 assoclen, u64 cryptlen);
|
|
|
|
MORUS1280_DECLARE_ALGS(avx2, "morus1280-avx2", 400);
|
|
|
|
static int __init crypto_morus1280_avx2_module_init(void)
|
|
{
|
|
if (!boot_cpu_has(X86_FEATURE_AVX2) ||
|
|
!boot_cpu_has(X86_FEATURE_OSXSAVE) ||
|
|
!cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL))
|
|
return -ENODEV;
|
|
|
|
return crypto_register_aeads(crypto_morus1280_avx2_algs,
|
|
ARRAY_SIZE(crypto_morus1280_avx2_algs));
|
|
}
|
|
|
|
static void __exit crypto_morus1280_avx2_module_exit(void)
|
|
{
|
|
crypto_unregister_aeads(crypto_morus1280_avx2_algs,
|
|
ARRAY_SIZE(crypto_morus1280_avx2_algs));
|
|
}
|
|
|
|
module_init(crypto_morus1280_avx2_module_init);
|
|
module_exit(crypto_morus1280_avx2_module_exit);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("Ondrej Mosnacek <omosnacek@gmail.com>");
|
|
MODULE_DESCRIPTION("MORUS-1280 AEAD algorithm -- AVX2 implementation");
|
|
MODULE_ALIAS_CRYPTO("morus1280");
|
|
MODULE_ALIAS_CRYPTO("morus1280-avx2");
|