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: x86/sm4 - fix crash with CFI enabled

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: ccace936eec7 ("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>

authored by

Eric Biggers and committed by
Herbert Xu
2d203c46 8ba490d9

+8 -6
+4 -3
arch/x86/crypto/sm4-aesni-avx-asm_64.S
··· 14 14 */ 15 15 16 16 #include <linux/linkage.h> 17 + #include <linux/cfi_types.h> 17 18 #include <asm/frame.h> 18 19 19 20 #define rRIP (%rip) ··· 421 420 * const u8 *src, u8 *iv) 422 421 */ 423 422 .align 8 424 - SYM_FUNC_START(sm4_aesni_avx_ctr_enc_blk8) 423 + SYM_TYPED_FUNC_START(sm4_aesni_avx_ctr_enc_blk8) 425 424 /* input: 426 425 * %rdi: round key array, CTX 427 426 * %rsi: dst (8 blocks) ··· 496 495 * const u8 *src, u8 *iv) 497 496 */ 498 497 .align 8 499 - SYM_FUNC_START(sm4_aesni_avx_cbc_dec_blk8) 498 + SYM_TYPED_FUNC_START(sm4_aesni_avx_cbc_dec_blk8) 500 499 /* input: 501 500 * %rdi: round key array, CTX 502 501 * %rsi: dst (8 blocks) ··· 546 545 * const u8 *src, u8 *iv) 547 546 */ 548 547 .align 8 549 - SYM_FUNC_START(sm4_aesni_avx_cfb_dec_blk8) 548 + SYM_TYPED_FUNC_START(sm4_aesni_avx_cfb_dec_blk8) 550 549 /* input: 551 550 * %rdi: round key array, CTX 552 551 * %rsi: dst (8 blocks)
+4 -3
arch/x86/crypto/sm4-aesni-avx2-asm_64.S
··· 14 14 */ 15 15 16 16 #include <linux/linkage.h> 17 + #include <linux/cfi_types.h> 17 18 #include <asm/frame.h> 18 19 19 20 #define rRIP (%rip) ··· 283 282 * const u8 *src, u8 *iv) 284 283 */ 285 284 .align 8 286 - SYM_FUNC_START(sm4_aesni_avx2_ctr_enc_blk16) 285 + SYM_TYPED_FUNC_START(sm4_aesni_avx2_ctr_enc_blk16) 287 286 /* input: 288 287 * %rdi: round key array, CTX 289 288 * %rsi: dst (16 blocks) ··· 396 395 * const u8 *src, u8 *iv) 397 396 */ 398 397 .align 8 399 - SYM_FUNC_START(sm4_aesni_avx2_cbc_dec_blk16) 398 + SYM_TYPED_FUNC_START(sm4_aesni_avx2_cbc_dec_blk16) 400 399 /* input: 401 400 * %rdi: round key array, CTX 402 401 * %rsi: dst (16 blocks) ··· 450 449 * const u8 *src, u8 *iv) 451 450 */ 452 451 .align 8 453 - SYM_FUNC_START(sm4_aesni_avx2_cfb_dec_blk16) 452 + SYM_TYPED_FUNC_START(sm4_aesni_avx2_cfb_dec_blk16) 454 453 /* input: 455 454 * %rdi: round key array, CTX 456 455 * %rsi: dst (16 blocks)