From 62c8c7cca8f4e8133878c6e42ebb3c4236b3e7ff Mon Sep 17 00:00:00 2001 From: Raoul Strackx Date: Mon, 1 May 2023 13:08:26 +0200 Subject: [PATCH 1/2] Correct LVI print function test --- .../run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks index 8a5493650a7..e02fe094889 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks +++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks @@ -1,6 +1,6 @@ CHECK: print CHECK: lfence -CHECK: lfence -CHECK: lfence -CHECK: callq 0x{{[[:xdigit:]]*}} <_Unwind_Resume> -CHECK-NEXT: ud2 +CHECK: popq +CHECK-NEXT: popq [[REGISTER:%[a-z]+]] +CHECK-NEXT: lfence +CHECK-NEXT: jmpq *[[REGISTER]] From b35f243c89907ba86b55fac5f86f591f7f342cde Mon Sep 17 00:00:00 2001 From: Raoul Strackx Date: Mon, 5 Jun 2023 15:10:03 +0200 Subject: [PATCH 2/2] Verify that (almost) all `ret` instructions have been replaced --- tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh index 235bb603b84..04a34724518 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh +++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh @@ -33,6 +33,15 @@ function check { ${objdump} --disassemble-symbols="${func}" --demangle \ ${enclave} > ${asm} ${filecheck} --input-file ${asm} ${checks} + + if [ "${func_re}" != "rust_plus_one_global_asm" && + "${func_re}" != "cmake_plus_one_c_global_asm" ]; then + # The assembler cannot avoid explicit `ret` instructions. Sequences + # of `shlq $0x0, (%rsp); lfence; retq` are used instead. + # https://www.intel.com/content/www/us/en/developer/articles/technical/ + # software-security-guidance/technical-documentation/load-value-injection.html + ${filecheck} --implicit-check-not ret --input-file ${asm} ${checks} + fi } build