Skip to content

Commit 736f886

Browse files
uudiinherbertx
authored andcommitted
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: 67fa3a7 ("crypto: arm64/sm4 - add CE implementation for CCM mode") Fixes: ae1b83c ("crypto: arm64/sm4 - add CE implementation for GCM mode") Signed-off-by: Tianjia Zhang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent a235299 commit 736f886

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

arch/arm64/crypto/sm4-ce-ccm-core.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <linux/linkage.h>
11+
#include <linux/cfi_types.h>
1112
#include <asm/assembler.h>
1213
#include "sm4-ce-asm.h"
1314

@@ -104,7 +105,7 @@ SYM_FUNC_START(sm4_ce_ccm_final)
104105
SYM_FUNC_END(sm4_ce_ccm_final)
105106

106107
.align 3
107-
SYM_FUNC_START(sm4_ce_ccm_enc)
108+
SYM_TYPED_FUNC_START(sm4_ce_ccm_enc)
108109
/* input:
109110
* x0: round key array, CTX
110111
* x1: dst
@@ -216,7 +217,7 @@ SYM_FUNC_START(sm4_ce_ccm_enc)
216217
SYM_FUNC_END(sm4_ce_ccm_enc)
217218

218219
.align 3
219-
SYM_FUNC_START(sm4_ce_ccm_dec)
220+
SYM_TYPED_FUNC_START(sm4_ce_ccm_dec)
220221
/* input:
221222
* x0: round key array, CTX
222223
* x1: dst

arch/arm64/crypto/sm4-ce-gcm-core.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <linux/linkage.h>
12+
#include <linux/cfi_types.h>
1213
#include <asm/assembler.h>
1314
#include "sm4-ce-asm.h"
1415

@@ -370,7 +371,7 @@ SYM_FUNC_START(pmull_ghash_update)
370371
SYM_FUNC_END(pmull_ghash_update)
371372

372373
.align 3
373-
SYM_FUNC_START(sm4_ce_pmull_gcm_enc)
374+
SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_enc)
374375
/* input:
375376
* x0: round key array, CTX
376377
* x1: dst
@@ -581,7 +582,7 @@ SYM_FUNC_END(sm4_ce_pmull_gcm_enc)
581582
#define RH3 v20
582583

583584
.align 3
584-
SYM_FUNC_START(sm4_ce_pmull_gcm_dec)
585+
SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_dec)
585586
/* input:
586587
* x0: round key array, CTX
587588
* x1: dst

0 commit comments

Comments
 (0)