Skip to content

Commit 2981557

Browse files
author
Peter Zijlstra
committed
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) <[email protected]> Reviewed-by: Sami Tolvanen <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 72e213a commit 2981557

11 files changed

+32
-21
lines changed

arch/x86/crypto/camellia-aesni-avx-asm_64.S

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include <linux/linkage.h>
19+
#include <linux/cfi_types.h>
1920
#include <asm/frame.h>
2021

2122
#define CAMELLIA_TABLE_BYTE_LEN 272
@@ -882,7 +883,7 @@ SYM_FUNC_START_LOCAL(__camellia_dec_blk16)
882883
jmp .Ldec_max24;
883884
SYM_FUNC_END(__camellia_dec_blk16)
884885

885-
SYM_FUNC_START(camellia_ecb_enc_16way)
886+
SYM_TYPED_FUNC_START(camellia_ecb_enc_16way)
886887
/* input:
887888
* %rdi: ctx, CTX
888889
* %rsi: dst (16 blocks)
@@ -907,7 +908,7 @@ SYM_FUNC_START(camellia_ecb_enc_16way)
907908
RET;
908909
SYM_FUNC_END(camellia_ecb_enc_16way)
909910

910-
SYM_FUNC_START(camellia_ecb_dec_16way)
911+
SYM_TYPED_FUNC_START(camellia_ecb_dec_16way)
911912
/* input:
912913
* %rdi: ctx, CTX
913914
* %rsi: dst (16 blocks)
@@ -937,7 +938,7 @@ SYM_FUNC_START(camellia_ecb_dec_16way)
937938
RET;
938939
SYM_FUNC_END(camellia_ecb_dec_16way)
939940

940-
SYM_FUNC_START(camellia_cbc_dec_16way)
941+
SYM_TYPED_FUNC_START(camellia_cbc_dec_16way)
941942
/* input:
942943
* %rdi: ctx, CTX
943944
* %rsi: dst (16 blocks)

arch/x86/crypto/camellia-aesni-avx2-asm_64.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/linkage.h>
9+
#include <linux/cfi_types.h>
910
#include <asm/frame.h>
1011

1112
#define CAMELLIA_TABLE_BYTE_LEN 272

arch/x86/crypto/camellia-x86_64-asm_64.S

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/linkage.h>
9+
#include <linux/cfi_types.h>
910

1011
.file "camellia-x86_64-asm_64.S"
1112
.text
@@ -177,7 +178,7 @@
177178
bswapq RAB0; \
178179
movq RAB0, 4*2(RIO);
179180

180-
SYM_FUNC_START(__camellia_enc_blk)
181+
SYM_TYPED_FUNC_START(__camellia_enc_blk)
181182
/* input:
182183
* %rdi: ctx, CTX
183184
* %rsi: dst
@@ -224,7 +225,7 @@ SYM_FUNC_START(__camellia_enc_blk)
224225
RET;
225226
SYM_FUNC_END(__camellia_enc_blk)
226227

227-
SYM_FUNC_START(camellia_dec_blk)
228+
SYM_TYPED_FUNC_START(camellia_dec_blk)
228229
/* input:
229230
* %rdi: ctx, CTX
230231
* %rsi: dst
@@ -411,7 +412,7 @@ SYM_FUNC_END(camellia_dec_blk)
411412
bswapq RAB1; \
412413
movq RAB1, 12*2(RIO);
413414

414-
SYM_FUNC_START(__camellia_enc_blk_2way)
415+
SYM_TYPED_FUNC_START(__camellia_enc_blk_2way)
415416
/* input:
416417
* %rdi: ctx, CTX
417418
* %rsi: dst
@@ -460,7 +461,7 @@ SYM_FUNC_START(__camellia_enc_blk_2way)
460461
RET;
461462
SYM_FUNC_END(__camellia_enc_blk_2way)
462463

463-
SYM_FUNC_START(camellia_dec_blk_2way)
464+
SYM_TYPED_FUNC_START(camellia_dec_blk_2way)
464465
/* input:
465466
* %rdi: ctx, CTX
466467
* %rsi: dst

arch/x86/crypto/serpent-avx-x86_64-asm_64.S

Lines changed: 4 additions & 3 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/frame.h>
1314
#include "glue_helper-asm-avx.S"
1415

@@ -656,7 +657,7 @@ SYM_FUNC_START_LOCAL(__serpent_dec_blk8_avx)
656657
RET;
657658
SYM_FUNC_END(__serpent_dec_blk8_avx)
658659

659-
SYM_FUNC_START(serpent_ecb_enc_8way_avx)
660+
SYM_TYPED_FUNC_START(serpent_ecb_enc_8way_avx)
660661
/* input:
661662
* %rdi: ctx, CTX
662663
* %rsi: dst
@@ -674,7 +675,7 @@ SYM_FUNC_START(serpent_ecb_enc_8way_avx)
674675
RET;
675676
SYM_FUNC_END(serpent_ecb_enc_8way_avx)
676677

677-
SYM_FUNC_START(serpent_ecb_dec_8way_avx)
678+
SYM_TYPED_FUNC_START(serpent_ecb_dec_8way_avx)
678679
/* input:
679680
* %rdi: ctx, CTX
680681
* %rsi: dst
@@ -692,7 +693,7 @@ SYM_FUNC_START(serpent_ecb_dec_8way_avx)
692693
RET;
693694
SYM_FUNC_END(serpent_ecb_dec_8way_avx)
694695

695-
SYM_FUNC_START(serpent_cbc_dec_8way_avx)
696+
SYM_TYPED_FUNC_START(serpent_cbc_dec_8way_avx)
696697
/* input:
697698
* %rdi: ctx, CTX
698699
* %rsi: dst

arch/x86/crypto/twofish-x86_64-asm_64-3way.S

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

88
#include <linux/linkage.h>
9+
#include <linux/cfi_types.h>
910

1011
.file "twofish-x86_64-asm-3way.S"
1112
.text
@@ -220,7 +221,7 @@
220221
rorq $32, RAB2; \
221222
outunpack3(mov, RIO, 2, RAB, 2);
222223

223-
SYM_FUNC_START(__twofish_enc_blk_3way)
224+
SYM_TYPED_FUNC_START(__twofish_enc_blk_3way)
224225
/* input:
225226
* %rdi: ctx, CTX
226227
* %rsi: dst
@@ -269,7 +270,7 @@ SYM_FUNC_START(__twofish_enc_blk_3way)
269270
RET;
270271
SYM_FUNC_END(__twofish_enc_blk_3way)
271272

272-
SYM_FUNC_START(twofish_dec_blk_3way)
273+
SYM_TYPED_FUNC_START(twofish_dec_blk_3way)
273274
/* input:
274275
* %rdi: ctx, CTX
275276
* %rsi: dst

arch/x86/crypto/twofish-x86_64-asm_64.S

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

1010
#include <linux/linkage.h>
11+
#include <linux/cfi_types.h>
1112
#include <asm/asm-offsets.h>
1213

1314
#define a_offset 0
@@ -202,7 +203,7 @@
202203
xor %r8d, d ## D;\
203204
ror $1, d ## D;
204205

205-
SYM_FUNC_START(twofish_enc_blk)
206+
SYM_TYPED_FUNC_START(twofish_enc_blk)
206207
pushq R1
207208

208209
/* %rdi contains the ctx address */
@@ -255,7 +256,7 @@ SYM_FUNC_START(twofish_enc_blk)
255256
RET
256257
SYM_FUNC_END(twofish_enc_blk)
257258

258-
SYM_FUNC_START(twofish_dec_blk)
259+
SYM_TYPED_FUNC_START(twofish_dec_blk)
259260
pushq R1
260261

261262
/* %rdi contains the ctx address */

arch/x86/lib/clear_page_64.S

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
#include <linux/export.h>
33
#include <linux/linkage.h>
4+
#include <linux/cfi_types.h>
45
#include <asm/asm.h>
56

67
/*
@@ -14,15 +15,15 @@
1415
* Zero a page.
1516
* %rdi - page
1617
*/
17-
SYM_FUNC_START(clear_page_rep)
18+
SYM_TYPED_FUNC_START(clear_page_rep)
1819
movl $4096/8,%ecx
1920
xorl %eax,%eax
2021
rep stosq
2122
RET
2223
SYM_FUNC_END(clear_page_rep)
2324
EXPORT_SYMBOL_GPL(clear_page_rep)
2425

25-
SYM_FUNC_START(clear_page_orig)
26+
SYM_TYPED_FUNC_START(clear_page_orig)
2627
xorl %eax,%eax
2728
movl $4096/64,%ecx
2829
.p2align 4
@@ -44,7 +45,7 @@ SYM_FUNC_START(clear_page_orig)
4445
SYM_FUNC_END(clear_page_orig)
4546
EXPORT_SYMBOL_GPL(clear_page_orig)
4647

47-
SYM_FUNC_START(clear_page_erms)
48+
SYM_TYPED_FUNC_START(clear_page_erms)
4849
movl $4096,%ecx
4950
xorl %eax,%eax
5051
rep stosb

arch/x86/lib/copy_page_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <linux/export.h>
55
#include <linux/linkage.h>
6+
#include <linux/cfi_types.h>
67
#include <asm/cpufeatures.h>
78
#include <asm/alternative.h>
89

@@ -13,7 +14,7 @@
1314
* prefetch distance based on SMP/UP.
1415
*/
1516
ALIGN
16-
SYM_FUNC_START(copy_page)
17+
SYM_TYPED_FUNC_START(copy_page)
1718
ALTERNATIVE "jmp copy_page_regs", "", X86_FEATURE_REP_GOOD
1819
movl $4096/8, %ecx
1920
rep movsq

arch/x86/lib/memmove_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
#include <linux/export.h>
1010
#include <linux/linkage.h>
11+
#include <linux/cfi_types.h>
1112
#include <asm/cpufeatures.h>
1213
#include <asm/alternative.h>
1314

@@ -26,7 +27,7 @@
2627
* Output:
2728
* rax: dest
2829
*/
29-
SYM_FUNC_START(__memmove)
30+
SYM_TYPED_FUNC_START(__memmove)
3031

3132
mov %rdi, %rax
3233

arch/x86/lib/memset_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <linux/export.h>
55
#include <linux/linkage.h>
6+
#include <linux/cfi_types.h>
67
#include <asm/cpufeatures.h>
78
#include <asm/alternative.h>
89

@@ -28,7 +29,7 @@
2829
* only for the return value that is the same as the source input,
2930
* which the compiler could/should do much better anyway.
3031
*/
31-
SYM_FUNC_START(__memset)
32+
SYM_TYPED_FUNC_START(__memset)
3233
ALTERNATIVE "jmp memset_orig", "", X86_FEATURE_FSRS
3334

3435
movq %rdi,%r9

arch/x86/lib/msr-reg.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
#include <linux/linkage.h>
33
#include <linux/errno.h>
4+
#include <linux/cfi_types.h>
45
#include <asm/asm.h>
56
#include <asm/msr.h>
67

@@ -12,7 +13,7 @@
1213
*
1314
*/
1415
.macro op_safe_regs op
15-
SYM_FUNC_START(\op\()_safe_regs)
16+
SYM_TYPED_FUNC_START(\op\()_safe_regs)
1617
pushq %rbx
1718
pushq %r12
1819
movq %rdi, %r10 /* Save pointer */

0 commit comments

Comments
 (0)