Merge pull request #7211 from douzzer/20240203-linuxkm-fixes

20240203-linuxkm-fixes
pull/7217/head
Sean Parkinson 2024-02-06 07:08:40 +10:00 committed by GitHub
commit 9060da42a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 21 deletions

View File

@ -822,6 +822,11 @@
#define realloc(ptr, newsize) krealloc(ptr, WC_LINUXKM_ROUND_UP_P_OF_2(newsize), GFP_KERNEL) #define realloc(ptr, newsize) krealloc(ptr, WC_LINUXKM_ROUND_UP_P_OF_2(newsize), GFP_KERNEL)
#endif #endif
#ifndef static_assert
#define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
#define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
#endif
#include <wolfssl/wolfcrypt/memory.h> #include <wolfssl/wolfcrypt/memory.h>
#ifdef WOLFSSL_TRACK_MEMORY #ifdef WOLFSSL_TRACK_MEMORY
@ -848,7 +853,7 @@
* them to be evaluable by the preprocessor, for use in sp_int.h. * them to be evaluable by the preprocessor, for use in sp_int.h.
*/ */
#if BITS_PER_LONG == 64 #if BITS_PER_LONG == 64
_Static_assert(sizeof(ULONG_MAX) == 8, static_assert(sizeof(ULONG_MAX) == 8,
"BITS_PER_LONG is 64, but ULONG_MAX is not."); "BITS_PER_LONG is 64, but ULONG_MAX is not.");
#undef UCHAR_MAX #undef UCHAR_MAX
@ -870,7 +875,7 @@
#elif BITS_PER_LONG == 32 #elif BITS_PER_LONG == 32
_Static_assert(sizeof(ULONG_MAX) == 4, static_assert(sizeof(ULONG_MAX) == 4,
"BITS_PER_LONG is 32, but ULONG_MAX is not."); "BITS_PER_LONG is 32, but ULONG_MAX is not.");
#undef UCHAR_MAX #undef UCHAR_MAX

View File

@ -12356,32 +12356,35 @@ int wc_AesXtsSetKeyNoInit(XtsAes* aes, const byte* key, word32 len, int dir)
* conflicting _aesni status, but the AES-XTS asm implementations need * conflicting _aesni status, but the AES-XTS asm implementations need
* them to all be AESNI. If any aren't, disable AESNI on all. * them to all be AESNI. If any aren't, disable AESNI on all.
*/ */
if ((((dir == AES_ENCRYPTION) #ifdef WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS
#ifdef WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS if ((((dir == AES_ENCRYPTION) ||
|| (dir == AES_ENCRYPTION_AND_DECRYPTION) (dir == AES_ENCRYPTION_AND_DECRYPTION))
#endif && (aes->aes.use_aesni != aes->tweak.use_aesni))
) &&
(aes->aes.use_aesni != aes->tweak.use_aesni))
#ifdef WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS
|| ||
(((dir == AES_DECRYPTION) (((dir == AES_DECRYPTION) ||
|| (dir == AES_ENCRYPTION_AND_DECRYPTION)) && (dir == AES_ENCRYPTION_AND_DECRYPTION))
(aes->aes_decrypt.use_aesni != aes->tweak.use_aesni)) && (aes->aes_decrypt.use_aesni != aes->tweak.use_aesni)))
#endif
)
{ {
#ifdef WC_AES_C_DYNAMIC_FALLBACK #ifdef WC_AES_C_DYNAMIC_FALLBACK
aes->aes.use_aesni = 0; aes->aes.use_aesni = 0;
#ifdef WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS
aes->aes_decrypt.use_aesni = 0; aes->aes_decrypt.use_aesni = 0;
#endif
aes->tweak.use_aesni = 0; aes->tweak.use_aesni = 0;
#else #else
ret = SYSLIB_FAILED_E; ret = SYSLIB_FAILED_E;
#endif #endif
} }
#else /* !WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS */
if (aes->aes.use_aesni != aes->tweak.use_aesni) {
#ifdef WC_AES_C_DYNAMIC_FALLBACK
aes->aes.use_aesni = 0;
aes->tweak.use_aesni = 0;
#else
ret = SYSLIB_FAILED_E;
#endif
} }
#endif #endif /* !WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS */
}
#endif /* WOLFSSL_AESNI */
return ret; return ret;
} }