Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 67fa3a7fdf80 ("crypto: arm64/sm4 - add CE implementation for CCM mode")
Fixes: ae1b83c7d572 ("crypto: arm64/sm4 - add CE implementation for GCM mode")
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Tianjia Zhang and committed by
Herbert Xu
736f8868 a2352998

+6 -4
+3 -2
arch/arm64/crypto/sm4-ce-ccm-core.S
··· 8 8 */ 9 9 10 10 #include <linux/linkage.h> 11 + #include <linux/cfi_types.h> 11 12 #include <asm/assembler.h> 12 13 #include "sm4-ce-asm.h" 13 14 ··· 105 104 SYM_FUNC_END(sm4_ce_ccm_final) 106 105 107 106 .align 3 108 - SYM_FUNC_START(sm4_ce_ccm_enc) 107 + SYM_TYPED_FUNC_START(sm4_ce_ccm_enc) 109 108 /* input: 110 109 * x0: round key array, CTX 111 110 * x1: dst ··· 217 216 SYM_FUNC_END(sm4_ce_ccm_enc) 218 217 219 218 .align 3 220 - SYM_FUNC_START(sm4_ce_ccm_dec) 219 + SYM_TYPED_FUNC_START(sm4_ce_ccm_dec) 221 220 /* input: 222 221 * x0: round key array, CTX 223 222 * x1: dst
+3 -2
arch/arm64/crypto/sm4-ce-gcm-core.S
··· 9 9 */ 10 10 11 11 #include <linux/linkage.h> 12 + #include <linux/cfi_types.h> 12 13 #include <asm/assembler.h> 13 14 #include "sm4-ce-asm.h" 14 15 ··· 371 370 SYM_FUNC_END(pmull_ghash_update) 372 371 373 372 .align 3 374 - SYM_FUNC_START(sm4_ce_pmull_gcm_enc) 373 + SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_enc) 375 374 /* input: 376 375 * x0: round key array, CTX 377 376 * x1: dst ··· 582 581 #define RH3 v20 583 582 584 583 .align 3 585 - SYM_FUNC_START(sm4_ce_pmull_gcm_dec) 584 + SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_dec) 586 585 /* input: 587 586 * x0: round key array, CTX 588 587 * x1: dst