Explorar el Código

[Pal/Linux-SGX] Don't call EEXIT if handle_ecall returns

During normal operation handle_ecall does not return. But when invalid
parameters are passed it does. In this case it's not guaranteed that the
parameters for EEXIT are already prepared. Ecalls are not designed to
return and calling OCALL_EXIT at this point is also not easy. So just go
into an endless loop. This case should only ever be reached if the
outside behaves maliciously.
Simon Gaiser hace 6 años
padre
commit
9df4d9671a
Se han modificado 1 ficheros con 11 adiciones y 4 borrados
  1. 11 4
      Pal/src/host/Linux-SGX/enclave_entry.S

+ 11 - 4
Pal/src/host/Linux-SGX/enclave_entry.S

@@ -4,6 +4,15 @@
 	.extern ecall_table
 	.extern enclave_ecall_pal_main
 
+# In some cases, like bogus parameters passed to enclave_entry, it's tricky to
+# return cleanly (passing the correct return address to EEXIT, OCALL_EXIT can
+# be interrupted, etc.). Since those cases should only ever happen with a
+# malicious urts, just go into an endless loop.
+.macro FAIL_LOOP
+.Lfail_loop\@:
+	jmp .Lfail_loop\@
+.endm
+
 	.global enclave_entry
 	.type enclave_entry, @function
 
@@ -73,10 +82,8 @@ enclave_entry:
 	# to handle_ecall() in enclave_ecalls.c
 	callq handle_ecall
 
-	# never return to this point (should die)
-	xorq %rdi, %rdi
-	xorq %rsi, %rsi
-	jmp .Leexit
+	# handle_ecall will only return when invalid parameters has been passed.
+	FAIL_LOOP
 
 .Lhandle_resume:
 	# PAL convention: