From 8bf06ca6cc5929dac535ceb9c4972ba4129bc3ed Mon Sep 17 00:00:00 2001 From: Dmitrii Kuvaiskii Date: Fri, 12 Apr 2019 18:23:44 -0700 Subject: [PATCH] [Pal/Linux-SGX] Set PAL_ERRNO to PAL_ERROR_INTERRUPTED when interrupted by host signal Current Linux-SGX PAL signal handling unwinds all inner PAL frames if host signal interrupts Graphene while it waits on a long syscall. Because PAL frames are unwound, all inner logic of PAL setting PAL_ERRNO = PAL_ERROR_INTERRUPTED (using the _DkRaiseFailure() flow) is skipped. This commit retrofits this logic. --- Pal/src/host/Linux-SGX/db_exception.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Pal/src/host/Linux-SGX/db_exception.c b/Pal/src/host/Linux-SGX/db_exception.c index faaeb592..d8abbb75 100644 --- a/Pal/src/host/Linux-SGX/db_exception.c +++ b/Pal/src/host/Linux-SGX/db_exception.c @@ -410,6 +410,11 @@ void _DkHandleExternalEvent (PAL_NUM event, sgx_context_t * uc) arch_store_frame(&frame->arch); } + /* We only end up in _DkHandleExternalEvent() if interrupted during + * host syscall; Dk* function will be unwound, so we must inform LibOS + * layer that PAL was interrupted (by setting PAL_ERRNO). */ + _DkRaiseFailure(PAL_ERROR_INTERRUPTED); + if (!_DkGenericSignalHandle(event, 0, frame, NULL) && event != PAL_EVENT_RESUME) _DkThreadExit();