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

x86,kcfi: Fix EXPORT_SYMBOL vs kCFI

The expectation is that all EXPORT'ed symbols are free to have their
address taken and called indirectly. The majority of the assembly
defined functions currently violate this expectation.

Make then all use SYM_TYPED_FUNC_START() in order to emit the proper
kCFI preamble.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Link: https://lore.kernel.org/r/20250207122546.302679189@infradead.org

+32 -21
+4 -3
arch/x86/crypto/camellia-aesni-avx-asm_64.S
··· 16 16 */ 17 17 18 18 #include <linux/linkage.h> 19 + #include <linux/cfi_types.h> 19 20 #include <asm/frame.h> 20 21 21 22 #define CAMELLIA_TABLE_BYTE_LEN 272 ··· 883 882 jmp .Ldec_max24; 884 883 SYM_FUNC_END(__camellia_dec_blk16) 885 884 886 - SYM_FUNC_START(camellia_ecb_enc_16way) 885 + SYM_TYPED_FUNC_START(camellia_ecb_enc_16way) 887 886 /* input: 888 887 * %rdi: ctx, CTX 889 888 * %rsi: dst (16 blocks) ··· 908 907 RET; 909 908 SYM_FUNC_END(camellia_ecb_enc_16way) 910 909 911 - SYM_FUNC_START(camellia_ecb_dec_16way) 910 + SYM_TYPED_FUNC_START(camellia_ecb_dec_16way) 912 911 /* input: 913 912 * %rdi: ctx, CTX 914 913 * %rsi: dst (16 blocks) ··· 938 937 RET; 939 938 SYM_FUNC_END(camellia_ecb_dec_16way) 940 939 941 - SYM_FUNC_START(camellia_cbc_dec_16way) 940 + SYM_TYPED_FUNC_START(camellia_cbc_dec_16way) 942 941 /* input: 943 942 * %rdi: ctx, CTX 944 943 * %rsi: dst (16 blocks)
+1
arch/x86/crypto/camellia-aesni-avx2-asm_64.S
··· 6 6 */ 7 7 8 8 #include <linux/linkage.h> 9 + #include <linux/cfi_types.h> 9 10 #include <asm/frame.h> 10 11 11 12 #define CAMELLIA_TABLE_BYTE_LEN 272
+5 -4
arch/x86/crypto/camellia-x86_64-asm_64.S
··· 6 6 */ 7 7 8 8 #include <linux/linkage.h> 9 + #include <linux/cfi_types.h> 9 10 10 11 .file "camellia-x86_64-asm_64.S" 11 12 .text ··· 178 177 bswapq RAB0; \ 179 178 movq RAB0, 4*2(RIO); 180 179 181 - SYM_FUNC_START(__camellia_enc_blk) 180 + SYM_TYPED_FUNC_START(__camellia_enc_blk) 182 181 /* input: 183 182 * %rdi: ctx, CTX 184 183 * %rsi: dst ··· 225 224 RET; 226 225 SYM_FUNC_END(__camellia_enc_blk) 227 226 228 - SYM_FUNC_START(camellia_dec_blk) 227 + SYM_TYPED_FUNC_START(camellia_dec_blk) 229 228 /* input: 230 229 * %rdi: ctx, CTX 231 230 * %rsi: dst ··· 412 411 bswapq RAB1; \ 413 412 movq RAB1, 12*2(RIO); 414 413 415 - SYM_FUNC_START(__camellia_enc_blk_2way) 414 + SYM_TYPED_FUNC_START(__camellia_enc_blk_2way) 416 415 /* input: 417 416 * %rdi: ctx, CTX 418 417 * %rsi: dst ··· 461 460 RET; 462 461 SYM_FUNC_END(__camellia_enc_blk_2way) 463 462 464 - SYM_FUNC_START(camellia_dec_blk_2way) 463 + SYM_TYPED_FUNC_START(camellia_dec_blk_2way) 465 464 /* input: 466 465 * %rdi: ctx, CTX 467 466 * %rsi: dst
+4 -3
arch/x86/crypto/serpent-avx-x86_64-asm_64.S
··· 9 9 */ 10 10 11 11 #include <linux/linkage.h> 12 + #include <linux/cfi_types.h> 12 13 #include <asm/frame.h> 13 14 #include "glue_helper-asm-avx.S" 14 15 ··· 657 656 RET; 658 657 SYM_FUNC_END(__serpent_dec_blk8_avx) 659 658 660 - SYM_FUNC_START(serpent_ecb_enc_8way_avx) 659 + SYM_TYPED_FUNC_START(serpent_ecb_enc_8way_avx) 661 660 /* input: 662 661 * %rdi: ctx, CTX 663 662 * %rsi: dst ··· 675 674 RET; 676 675 SYM_FUNC_END(serpent_ecb_enc_8way_avx) 677 676 678 - SYM_FUNC_START(serpent_ecb_dec_8way_avx) 677 + SYM_TYPED_FUNC_START(serpent_ecb_dec_8way_avx) 679 678 /* input: 680 679 * %rdi: ctx, CTX 681 680 * %rsi: dst ··· 693 692 RET; 694 693 SYM_FUNC_END(serpent_ecb_dec_8way_avx) 695 694 696 - SYM_FUNC_START(serpent_cbc_dec_8way_avx) 695 + SYM_TYPED_FUNC_START(serpent_cbc_dec_8way_avx) 697 696 /* input: 698 697 * %rdi: ctx, CTX 699 698 * %rsi: dst
+3 -2
arch/x86/crypto/twofish-x86_64-asm_64-3way.S
··· 6 6 */ 7 7 8 8 #include <linux/linkage.h> 9 + #include <linux/cfi_types.h> 9 10 10 11 .file "twofish-x86_64-asm-3way.S" 11 12 .text ··· 221 220 rorq $32, RAB2; \ 222 221 outunpack3(mov, RIO, 2, RAB, 2); 223 222 224 - SYM_FUNC_START(__twofish_enc_blk_3way) 223 + SYM_TYPED_FUNC_START(__twofish_enc_blk_3way) 225 224 /* input: 226 225 * %rdi: ctx, CTX 227 226 * %rsi: dst ··· 270 269 RET; 271 270 SYM_FUNC_END(__twofish_enc_blk_3way) 272 271 273 - SYM_FUNC_START(twofish_dec_blk_3way) 272 + SYM_TYPED_FUNC_START(twofish_dec_blk_3way) 274 273 /* input: 275 274 * %rdi: ctx, CTX 276 275 * %rsi: dst
+3 -2
arch/x86/crypto/twofish-x86_64-asm_64.S
··· 8 8 .text 9 9 10 10 #include <linux/linkage.h> 11 + #include <linux/cfi_types.h> 11 12 #include <asm/asm-offsets.h> 12 13 13 14 #define a_offset 0 ··· 203 202 xor %r8d, d ## D;\ 204 203 ror $1, d ## D; 205 204 206 - SYM_FUNC_START(twofish_enc_blk) 205 + SYM_TYPED_FUNC_START(twofish_enc_blk) 207 206 pushq R1 208 207 209 208 /* %rdi contains the ctx address */ ··· 256 255 RET 257 256 SYM_FUNC_END(twofish_enc_blk) 258 257 259 - SYM_FUNC_START(twofish_dec_blk) 258 + SYM_TYPED_FUNC_START(twofish_dec_blk) 260 259 pushq R1 261 260 262 261 /* %rdi contains the ctx address */
+4 -3
arch/x86/lib/clear_page_64.S
··· 1 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 2 #include <linux/export.h> 3 3 #include <linux/linkage.h> 4 + #include <linux/cfi_types.h> 4 5 #include <asm/asm.h> 5 6 6 7 /* ··· 15 14 * Zero a page. 16 15 * %rdi - page 17 16 */ 18 - SYM_FUNC_START(clear_page_rep) 17 + SYM_TYPED_FUNC_START(clear_page_rep) 19 18 movl $4096/8,%ecx 20 19 xorl %eax,%eax 21 20 rep stosq ··· 23 22 SYM_FUNC_END(clear_page_rep) 24 23 EXPORT_SYMBOL_GPL(clear_page_rep) 25 24 26 - SYM_FUNC_START(clear_page_orig) 25 + SYM_TYPED_FUNC_START(clear_page_orig) 27 26 xorl %eax,%eax 28 27 movl $4096/64,%ecx 29 28 .p2align 4 ··· 45 44 SYM_FUNC_END(clear_page_orig) 46 45 EXPORT_SYMBOL_GPL(clear_page_orig) 47 46 48 - SYM_FUNC_START(clear_page_erms) 47 + SYM_TYPED_FUNC_START(clear_page_erms) 49 48 movl $4096,%ecx 50 49 xorl %eax,%eax 51 50 rep stosb
+2 -1
arch/x86/lib/copy_page_64.S
··· 3 3 4 4 #include <linux/export.h> 5 5 #include <linux/linkage.h> 6 + #include <linux/cfi_types.h> 6 7 #include <asm/cpufeatures.h> 7 8 #include <asm/alternative.h> 8 9 ··· 14 13 * prefetch distance based on SMP/UP. 15 14 */ 16 15 ALIGN 17 - SYM_FUNC_START(copy_page) 16 + SYM_TYPED_FUNC_START(copy_page) 18 17 ALTERNATIVE "jmp copy_page_regs", "", X86_FEATURE_REP_GOOD 19 18 movl $4096/8, %ecx 20 19 rep movsq
+2 -1
arch/x86/lib/memmove_64.S
··· 8 8 */ 9 9 #include <linux/export.h> 10 10 #include <linux/linkage.h> 11 + #include <linux/cfi_types.h> 11 12 #include <asm/cpufeatures.h> 12 13 #include <asm/alternative.h> 13 14 ··· 27 26 * Output: 28 27 * rax: dest 29 28 */ 30 - SYM_FUNC_START(__memmove) 29 + SYM_TYPED_FUNC_START(__memmove) 31 30 32 31 mov %rdi, %rax 33 32
+2 -1
arch/x86/lib/memset_64.S
··· 3 3 4 4 #include <linux/export.h> 5 5 #include <linux/linkage.h> 6 + #include <linux/cfi_types.h> 6 7 #include <asm/cpufeatures.h> 7 8 #include <asm/alternative.h> 8 9 ··· 29 28 * only for the return value that is the same as the source input, 30 29 * which the compiler could/should do much better anyway. 31 30 */ 32 - SYM_FUNC_START(__memset) 31 + SYM_TYPED_FUNC_START(__memset) 33 32 ALTERNATIVE "jmp memset_orig", "", X86_FEATURE_FSRS 34 33 35 34 movq %rdi,%r9
+2 -1
arch/x86/lib/msr-reg.S
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 #include <linux/linkage.h> 3 3 #include <linux/errno.h> 4 + #include <linux/cfi_types.h> 4 5 #include <asm/asm.h> 5 6 #include <asm/msr.h> 6 7 ··· 13 12 * 14 13 */ 15 14 .macro op_safe_regs op 16 - SYM_FUNC_START(\op\()_safe_regs) 15 + SYM_TYPED_FUNC_START(\op\()_safe_regs) 17 16 pushq %rbx 18 17 pushq %r12 19 18 movq %rdi, %r10 /* Save pointer */