|
|
5ab3ad |
From cd7620a730413a48843e175d34dc408c152f8125 Mon Sep 17 00:00:00 2001
|
|
|
5ab3ad |
From: "H.J. Lu" <hjl.tools@gmail.com>
|
|
|
5ab3ad |
Date: Tue, 11 Jan 2022 07:28:25 -0800
|
|
|
5ab3ad |
Subject: [PATCH] x86-64: Enable Intel CET
|
|
|
5ab3ad |
|
|
|
5ab3ad |
Intel Control-flow Enforcement Technology (CET):
|
|
|
5ab3ad |
|
|
|
5ab3ad |
https://en.wikipedia.org/wiki/Control-flow_integrity#Intel_Control-flow_Enforcement_Technology
|
|
|
5ab3ad |
|
|
|
5ab3ad |
requires that on Linux, all linker input files are marked as CET enabled
|
|
|
5ab3ad |
in .note.gnu.property section. For high-level language source codes,
|
|
|
5ab3ad |
.note.gnu.property section is added by compiler with the -fcf-protection
|
|
|
5ab3ad |
option. For assembly sources, include <cet.h> to add .note.gnu.property
|
|
|
5ab3ad |
section.
|
|
|
5ab3ad |
---
|
|
|
5ab3ad |
lib/common/portability_macros.h | 11 +++++++++++
|
|
|
5ab3ad |
1 file changed, 11 insertions(+)
|
|
|
5ab3ad |
|
|
|
5ab3ad |
diff --git a/lib/common/portability_macros.h b/lib/common/portability_macros.h
|
|
|
5ab3ad |
index 627ef9eed4..6ac4b05510 100644
|
|
|
5ab3ad |
--- a/lib/common/portability_macros.h
|
|
|
5ab3ad |
+++ b/lib/common/portability_macros.h
|
|
|
5ab3ad |
@@ -128,4 +128,15 @@
|
|
|
5ab3ad |
# define ZSTD_ENABLE_ASM_X86_64_BMI2 0
|
|
|
5ab3ad |
#endif
|
|
|
5ab3ad |
|
|
|
5ab3ad |
+/*
|
|
|
5ab3ad |
+ * For x86 ELF targets, add .note.gnu.property section for Intel CET in
|
|
|
5ab3ad |
+ * assembly sources when CET is enabled.
|
|
|
5ab3ad |
+ */
|
|
|
5ab3ad |
+#if defined(__ELF__) && (defined(__x86_64__) || defined(__i386__)) \
|
|
|
5ab3ad |
+ && defined(__has_include)
|
|
|
5ab3ad |
+# if __has_include(<cet.h>)
|
|
|
5ab3ad |
+# include <cet.h>
|
|
|
5ab3ad |
+# endif
|
|
|
5ab3ad |
+#endif
|
|
|
5ab3ad |
+
|
|
|
5ab3ad |
#endif /* ZSTD_PORTABILITY_MACROS_H */
|