Browse Source

[Pal/Linux-SGX] Correctly propagate arguments to _DkHandleExternalEvent()

Previously, Case A in the in-enclave exception handler in enclave_entry.S
incorrectly set RDI register to -EINTR (to indicate interrupted syscall)
of the current CPU context, instead of setting RDI register of the interrupted
CPU context (which is accessed via SGX_GPR_RDI). This led to very rare data
races that hanged the interrupted thread/corrupted its memory, because
-EINTR incorrectly propated to SGX_GPR_RSI that holds external event (signal
number) and this led to buffer overflows.
Dmitrii Kuvaiskii 5 years ago
parent
commit
111516090b
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Pal/src/host/Linux-SGX/enclave_entry.S

+ 1 - 1
Pal/src/host/Linux-SGX/enclave_entry.S

@@ -306,7 +306,7 @@ enclave_entry:
 	# If there is registered signal handler for the current exception,
 	# _DkHandleExternalEvent() will be called (and thus we need to save
 	# %rdi = <external event>) before returning from ocall.
-	movq $-EINTR, %rdi # return value for .Lreturn_from_ocall
+	movq $-EINTR, SGX_GPR_RDI(%rbx) # return value for .Lreturn_from_ocall
 	# fallthrough to Case C.
 
 	# This code cannot land in Case B because: