提交 736f8868 编写于 作者: T Tianjia Zhang 提交者: Herbert Xu

crypto: arm64/sm4 - fix possible crash with CFI enabled

The SM4 CCM/GCM assembly functions for encryption and decryption is
called via indirect function calls.  Therefore they need to use
SYM_TYPED_FUNC_START instead of SYM_FUNC_START to cause its type hash
to be emitted when the kernel is built with CONFIG_CFI_CLANG=y.
Otherwise, the code crashes with a CFI failure (if the compiler didn't
happen to optimize out the indirect call).

Fixes: 67fa3a7f ("crypto: arm64/sm4 - add CE implementation for CCM mode")
Fixes: ae1b83c7 ("crypto: arm64/sm4 - add CE implementation for GCM mode")
Signed-off-by: NTianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 a2352998
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/cfi_types.h>
#include <asm/assembler.h> #include <asm/assembler.h>
#include "sm4-ce-asm.h" #include "sm4-ce-asm.h"
...@@ -104,7 +105,7 @@ SYM_FUNC_START(sm4_ce_ccm_final) ...@@ -104,7 +105,7 @@ SYM_FUNC_START(sm4_ce_ccm_final)
SYM_FUNC_END(sm4_ce_ccm_final) SYM_FUNC_END(sm4_ce_ccm_final)
.align 3 .align 3
SYM_FUNC_START(sm4_ce_ccm_enc) SYM_TYPED_FUNC_START(sm4_ce_ccm_enc)
/* input: /* input:
* x0: round key array, CTX * x0: round key array, CTX
* x1: dst * x1: dst
...@@ -216,7 +217,7 @@ SYM_FUNC_START(sm4_ce_ccm_enc) ...@@ -216,7 +217,7 @@ SYM_FUNC_START(sm4_ce_ccm_enc)
SYM_FUNC_END(sm4_ce_ccm_enc) SYM_FUNC_END(sm4_ce_ccm_enc)
.align 3 .align 3
SYM_FUNC_START(sm4_ce_ccm_dec) SYM_TYPED_FUNC_START(sm4_ce_ccm_dec)
/* input: /* input:
* x0: round key array, CTX * x0: round key array, CTX
* x1: dst * x1: dst
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
*/ */
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/cfi_types.h>
#include <asm/assembler.h> #include <asm/assembler.h>
#include "sm4-ce-asm.h" #include "sm4-ce-asm.h"
...@@ -370,7 +371,7 @@ SYM_FUNC_START(pmull_ghash_update) ...@@ -370,7 +371,7 @@ SYM_FUNC_START(pmull_ghash_update)
SYM_FUNC_END(pmull_ghash_update) SYM_FUNC_END(pmull_ghash_update)
.align 3 .align 3
SYM_FUNC_START(sm4_ce_pmull_gcm_enc) SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_enc)
/* input: /* input:
* x0: round key array, CTX * x0: round key array, CTX
* x1: dst * x1: dst
...@@ -581,7 +582,7 @@ SYM_FUNC_END(sm4_ce_pmull_gcm_enc) ...@@ -581,7 +582,7 @@ SYM_FUNC_END(sm4_ce_pmull_gcm_enc)
#define RH3 v20 #define RH3 v20
.align 3 .align 3
SYM_FUNC_START(sm4_ce_pmull_gcm_dec) SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_dec)
/* input: /* input:
* x0: round key array, CTX * x0: round key array, CTX
* x1: dst * x1: dst
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册