crypto: x86/sm4 - fix crash with CFI enabled
[ Upstream commit2d203c46a0
] sm4_aesni_avx_ctr_enc_blk8(), sm4_aesni_avx_cbc_dec_blk8(), sm4_aesni_avx_cfb_dec_blk8(), sm4_aesni_avx2_ctr_enc_blk16(), sm4_aesni_avx2_cbc_dec_blk16(), and sm4_aesni_avx2_cfb_dec_blk16() are called via indirect function calls. Therefore they need to use SYM_TYPED_FUNC_START instead of SYM_FUNC_START to cause their type hashes to be emitted when the kernel is built with CONFIG_CFI_CLANG=y. Otherwise, the code crashes with a CFI failure. (Or at least that should be the case. For some reason the CFI checks in sm4_avx_cbc_decrypt(), sm4_avx_cfb_decrypt(), and sm4_avx_ctr_crypt() are not always being generated, using current tip-of-tree clang. Anyway, this patch is a good idea anyway.) Fixes:ccace936ee
("x86: Add types to indirectly called assembly functions") Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e6e4e281be
commit
23cf91c764
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/linkage.h>
|
||||
#include <linux/cfi_types.h>
|
||||
#include <asm/frame.h>
|
||||
|
||||
#define rRIP (%rip)
|
||||
|
@ -420,7 +421,7 @@ SYM_FUNC_END(sm4_aesni_avx_crypt8)
|
|||
* const u8 *src, u8 *iv)
|
||||
*/
|
||||
.align 8
|
||||
SYM_FUNC_START(sm4_aesni_avx_ctr_enc_blk8)
|
||||
SYM_TYPED_FUNC_START(sm4_aesni_avx_ctr_enc_blk8)
|
||||
/* input:
|
||||
* %rdi: round key array, CTX
|
||||
* %rsi: dst (8 blocks)
|
||||
|
@ -495,7 +496,7 @@ SYM_FUNC_END(sm4_aesni_avx_ctr_enc_blk8)
|
|||
* const u8 *src, u8 *iv)
|
||||
*/
|
||||
.align 8
|
||||
SYM_FUNC_START(sm4_aesni_avx_cbc_dec_blk8)
|
||||
SYM_TYPED_FUNC_START(sm4_aesni_avx_cbc_dec_blk8)
|
||||
/* input:
|
||||
* %rdi: round key array, CTX
|
||||
* %rsi: dst (8 blocks)
|
||||
|
@ -545,7 +546,7 @@ SYM_FUNC_END(sm4_aesni_avx_cbc_dec_blk8)
|
|||
* const u8 *src, u8 *iv)
|
||||
*/
|
||||
.align 8
|
||||
SYM_FUNC_START(sm4_aesni_avx_cfb_dec_blk8)
|
||||
SYM_TYPED_FUNC_START(sm4_aesni_avx_cfb_dec_blk8)
|
||||
/* input:
|
||||
* %rdi: round key array, CTX
|
||||
* %rsi: dst (8 blocks)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/linkage.h>
|
||||
#include <linux/cfi_types.h>
|
||||
#include <asm/frame.h>
|
||||
|
||||
#define rRIP (%rip)
|
||||
|
@ -282,7 +283,7 @@ SYM_FUNC_END(__sm4_crypt_blk16)
|
|||
* const u8 *src, u8 *iv)
|
||||
*/
|
||||
.align 8
|
||||
SYM_FUNC_START(sm4_aesni_avx2_ctr_enc_blk16)
|
||||
SYM_TYPED_FUNC_START(sm4_aesni_avx2_ctr_enc_blk16)
|
||||
/* input:
|
||||
* %rdi: round key array, CTX
|
||||
* %rsi: dst (16 blocks)
|
||||
|
@ -395,7 +396,7 @@ SYM_FUNC_END(sm4_aesni_avx2_ctr_enc_blk16)
|
|||
* const u8 *src, u8 *iv)
|
||||
*/
|
||||
.align 8
|
||||
SYM_FUNC_START(sm4_aesni_avx2_cbc_dec_blk16)
|
||||
SYM_TYPED_FUNC_START(sm4_aesni_avx2_cbc_dec_blk16)
|
||||
/* input:
|
||||
* %rdi: round key array, CTX
|
||||
* %rsi: dst (16 blocks)
|
||||
|
@ -449,7 +450,7 @@ SYM_FUNC_END(sm4_aesni_avx2_cbc_dec_blk16)
|
|||
* const u8 *src, u8 *iv)
|
||||
*/
|
||||
.align 8
|
||||
SYM_FUNC_START(sm4_aesni_avx2_cfb_dec_blk16)
|
||||
SYM_TYPED_FUNC_START(sm4_aesni_avx2_cfb_dec_blk16)
|
||||
/* input:
|
||||
* %rdi: round key array, CTX
|
||||
* %rsi: dst (16 blocks)
|
||||
|
|
Loading…
Reference in New Issue