From a18dc7f10a3474cacc74a0212a0d16965ee8651d Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Wed, 17 May 2023 01:07:47 -0500 Subject: [PATCH] wolfcrypt/src/aes.c: in wc_AesSetKeyLocal(), add an alignment check in the haveAESNI path for WOLFSSL_LINUXKM, because the failure mode is module crash. --- wolfcrypt/src/aes.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 3dc391c5f..317d094d9 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -3129,6 +3129,12 @@ static WARN_UNUSED_RESULT int wc_AesDecrypt( checkAESNI = 1; } if (haveAESNI) { + #ifdef WOLFSSL_LINUXKM + /* runtime alignment check */ + if ((unsigned long)&aes->key & 0xf) { + return BAD_ALIGN_E; + } + #endif aes->use_aesni = 1; if (iv) XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);