2240d72f15
Adds support for: * `-mfunction-return=<value>` command line flag, and * `__attribute__((function_return("<value>")))` function attribute Where the supported <value>s are: * keep (disable) * thunk-extern (enable) thunk-extern enables clang to change ret instructions into jmps to an external symbol named __x86_return_thunk, implemented as a new MachineFunctionPass named "x86-return-thunks", keyed off the new IR attribute fn_ret_thunk_extern. The symbol __x86_return_thunk is expected to be provided by the runtime the compiled code is linked against and is not defined by the compiler. Enabling this option alone doesn't provide mitigations without corresponding definitions of __x86_return_thunk! This new MachineFunctionPass is very similar to "x86-lvi-ret". The <value>s "thunk" and "thunk-inline" are currently unsupported. It's not clear yet that they are necessary: whether the thunk pattern they would emit is beneficial or used anywhere. Should the <value>s "thunk" and "thunk-inline" become necessary, x86-return-thunks could probably be merged into x86-retpoline-thunks which has pre-existing machinery for emitting thunks (which could be used to implement the <value> "thunk"). Has been found to build+boot with corresponding Linux kernel patches. This helps the Linux kernel mitigate RETBLEED. * CVE-2022-23816 * CVE-2022-28693 * CVE-2022-29901 See also: * "RETBLEED: Arbitrary Speculative Code Execution with Return Instructions." * AMD SECURITY NOTICE AMD-SN-1037: AMD CPU Branch Type Confusion * TECHNICAL GUIDANCE FOR MITIGATING BRANCH TYPE CONFUSION REVISION 1.0 2022-07-12 * Return Stack Buffer Underflow / Return Stack Buffer Underflow / CVE-2022-29901, CVE-2022-28693 / INTEL-SA-00702 SystemZ may eventually want to support "thunk-extern" and "thunk"; both options are used by the Linux kernel's CONFIG_EXPOLINE. This functionality has been available in GCC since the 8.1 release, and was backported to the 7.3 release. Many thanks for folks that provided discrete review off list due to the embargoed nature of this hardware vulnerability. Many Bothans died to bring us this information. Link: https://www.youtube.com/watch?v=IF6HbCKQHK8 Link: https://github.com/llvm/llvm-project/issues/54404 Link: https://gcc.gnu.org/legacy-ml/gcc-patches/2018-01/msg01197.html Link: https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/return-stack-buffer-underflow.html Link: https://arstechnica.com/information-technology/2022/07/intel-and-amd-cpus-vulnerable-to-a-new-speculative-execution-attack/?comments=1 Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ce114c866860aa9eae3f50974efc68241186ba60 Link: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00702.html Link: https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00707.html Reviewed By: aaron.ballman, craig.topper Differential Revision: https://reviews.llvm.org/D129572 |
||
---|---|---|
.. | ||
Inputs | ||
aarch64-target-cpu.c | ||
aarch64-vscale-min.c | ||
absolute-paths-symlinks.c | ||
absolute-paths-windows.test | ||
absolute-paths.c | ||
aix-unsupported.c | ||
arm-branch-protection-default-arch.c | ||
arm-ignore-branch-protection-option.c | ||
arm-invalid-branch-protection.c | ||
ast-codegen.c | ||
ast-main.c | ||
ast-main.cpp | ||
backend-attribute-error-warning-optimize.c | ||
backend-attribute-error-warning.c | ||
backend-attribute-error-warning.cpp | ||
backend-diagnostic.c | ||
cc1-return-codes.c | ||
clang-abi-compat.cpp | ||
compiler-options-dump.cpp | ||
cpp-output.c | ||
crash-diagnostic-renderer.cpp | ||
darwin-eabi.c | ||
darwin-version.c | ||
dependency-gen-escaping.c | ||
dependency-gen-extradeps-phony.c | ||
dependency-gen-has-include.c | ||
dependency-gen-symlink.c | ||
dependency-gen-windows-duplicates.c | ||
dependency-gen.c | ||
dependency-generation-crash.c | ||
diagnostics-option-names.c | ||
diagnostics-order.c | ||
disable-output.c | ||
embed-bitcode-noopt.c | ||
embed-bitcode-noopt.ll | ||
embed-bitcode.ll | ||
embed-object.c | ||
embed-object.ll | ||
exceptions.c | ||
fixed_point_add.c | ||
fixed_point_add_const.c | ||
fixed_point_bit_widths.c | ||
fixed_point_comparisons.c | ||
fixed_point_compound.c | ||
fixed_point_conversions.c | ||
fixed_point_conversions_const.c | ||
fixed_point_conversions_half.c | ||
fixed_point_crash.c | ||
fixed_point_declarations.c | ||
fixed_point_div.c | ||
fixed_point_div_const.c | ||
fixed_point_errors.c | ||
fixed_point_errors.cpp | ||
fixed_point_mul.c | ||
fixed_point_mul_const.c | ||
fixed_point_not_enabled.c | ||
fixed_point_same_fbits.c | ||
fixed_point_shift.c | ||
fixed_point_shift_const.c | ||
fixed_point_sub.c | ||
fixed_point_sub_const.c | ||
fixed_point_to_bool.c | ||
fixed_point_unary.c | ||
fixed_point_unknown_conversions.c | ||
force-include-not-found.c | ||
ftime-report-template-decl.cpp | ||
fwarn-stack-size.c | ||
gnu-inline.c | ||
gnu-mcount.c | ||
hexagon-target-basic.c | ||
iframework.c | ||
include-duplicate-removal.c | ||
int128.cpp | ||
invalid-cxx-abi.cpp | ||
invalid-o-level.c | ||
ir-support-codegen.ll | ||
ir-support-errors.ll | ||
ir-support.c | ||
lit.local.cfg | ||
macro_defined_type.cpp | ||
macros.c | ||
mfpmath.c | ||
mfunction-return.c | ||
minimize_source_to_dependency_directives.c | ||
mips-long-double.c | ||
no-knr-functions.c | ||
noderef.c | ||
noderef.cpp | ||
noderef_on_non_pointers.m | ||
noderef_templates.cpp | ||
nostdlib-for-asmpp.s | ||
objc-bool-is-bool.m | ||
opencl.cl | ||
optimization-remark-analysis.c | ||
optimization-remark-extra-analysis.c | ||
optimization-remark-line-directive.c | ||
optimization-remark-new-pm.c | ||
optimization-remark-options.c | ||
optimization-remark-with-hotness-new-pm.c | ||
optimization-remark.c | ||
output-paths.c | ||
plugin-annotate-functions.c | ||
plugin-attribute.cpp | ||
plugin-call-super.cpp | ||
plugin-delayed-template.cpp | ||
plugin-unknown.c | ||
plugin-vs-debug-info.cpp | ||
plugins-order.c | ||
plugins.c | ||
pp-only-no-editor-placeholders.c | ||
preprocessed-input.i | ||
preprocessed-output-macro-first-token.c | ||
print-header-includes.c | ||
profile-sample-use-loc-tracking.c | ||
region-pragmas.c | ||
remarks-hotness.cpp | ||
remove-file-on-signal.c | ||
rewrite-includes-bom.c | ||
rewrite-includes-cli-include.c | ||
rewrite-includes-conditions.c | ||
rewrite-includes-eof.c | ||
rewrite-includes-filenotfound.c | ||
rewrite-includes-header-cmd-line.c | ||
rewrite-includes-invalid-hasinclude.c | ||
rewrite-includes-line-markers.c | ||
rewrite-includes-macros.cpp | ||
rewrite-includes-messages.c | ||
rewrite-includes-missing.c | ||
rewrite-includes-modules.c | ||
rewrite-includes-warnings.c | ||
rewrite-includes.c | ||
rewrite-macros.c | ||
round-trip-cc1-args.c | ||
source-col-map.c | ||
stack-usage-safestack.c | ||
stats-file.c | ||
stdin-input.c | ||
stdin.c | ||
stdlang.c | ||
sycl-aux-triple.cpp | ||
sycl.cpp | ||
system-header-line-directive-ms-lineendings.c | ||
system-header-line-directive.c | ||
system-header-prefix.c | ||
trigraphs.cpp | ||
undef.c | ||
unknown-arg.c | ||
unknown-pragmas.c | ||
valid-cxx-abi.cpp | ||
verify-any-file.c | ||
verify-any-file.h | ||
verify-directive.h | ||
verify-fatal.c | ||
verify-ignore-unexpected.c | ||
verify-marker.c | ||
verify-marker.h | ||
verify-prefixes.c | ||
verify-unknown-arg.c | ||
verify.c | ||
verify2.c | ||
verify2.h | ||
verify3.c | ||
warn-device-init-fun.cu | ||
warning-mapping-1.c | ||
warning-mapping-2.c | ||
warning-mapping-3.c | ||
warning-mapping-4.c | ||
warning-mapping-5.c | ||
warning-mapping-6.c | ||
warning-options.cpp | ||
warning-poison-system-directories.c | ||
Weverything.c | ||
windows-exceptions.cpp | ||
windows-nul.c | ||
Wno-everything.c | ||
x86-embed-bitcode.ll | ||
x86-target-cpu.c | ||
x86_64-nacl-types.cpp |