Skip to content

Commit b642a70

Browse files
committed
00459: Apply Intel Control-flow Technology for x86-64
Required for mitigation against return-oriented programming (ROP) and Call or Jump Oriented Programming (COP/JOP) attacks Proposed upstream: python#128606 See also: https://sourceware.org/annobin/annobin.html/Test-cf-protection.html
1 parent e0e34c0 commit b642a70

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Python/asm_trampoline.S

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# }
1010
_Py_trampoline_func_start:
1111
#ifdef __x86_64__
12+
#if defined(__CET__) && (__CET__ & 1)
13+
endbr64
14+
#endif
1215
sub $8, %rsp
1316
call *%rcx
1417
add $8, %rsp
@@ -26,3 +29,22 @@ _Py_trampoline_func_start:
2629
.globl _Py_trampoline_func_end
2730
_Py_trampoline_func_end:
2831
.section .note.GNU-stack,"",@progbits
32+
# Note for indicating the assembly code supports CET
33+
#if defined(__x86_64__) && defined(__CET__) && (__CET__ & 1)
34+
.section .note.gnu.property,"a"
35+
.align 8
36+
.long 1f - 0f
37+
.long 4f - 1f
38+
.long 5
39+
0:
40+
.string "GNU"
41+
1:
42+
.align 8
43+
.long 0xc0000002
44+
.long 3f - 2f
45+
2:
46+
.long 0x3
47+
3:
48+
.align 8
49+
4:
50+
#endif // __x86_64__

0 commit comments

Comments
 (0)