Skip to content

Commit

Permalink
[PAL/Linux-SGX] Drop ms_ prefix
Browse files Browse the repository at this point in the history
Signed-off-by: Mariusz Zaborski <oshogbo@invisiblethingslab.com>
  • Loading branch information
oshogbo authored and Dmitrii Kuvaiskii committed Oct 24, 2022
1 parent db86ad2 commit f512b33
Show file tree
Hide file tree
Showing 6 changed files with 982 additions and 923 deletions.
31 changes: 17 additions & 14 deletions pal/src/host/linux-sgx/enclave_ecalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ void handle_ecall(long ecall_index, void* ecall_args, void* exit_target, void* e
return;
}

ms_ecall_enclave_start_t* ms;
if (!sgx_is_valid_untrusted_ptr(ecall_args, sizeof(*ms), alignof(__typeof__(*ms)))) {
struct ecall_enclave_start* start_args;
if (!sgx_is_valid_untrusted_ptr(ecall_args, sizeof(*start_args),
alignof(__typeof__(*start_args)))) {
return;
}
ms = ecall_args;
start_args = ecall_args;

/* xsave size must be initialized early, from a trusted source (EREPORT result) */
// TODO: This eats 1KB of a stack frame which lives for the whole lifespan of this enclave.
Expand All @@ -87,17 +88,19 @@ void handle_ecall(long ecall_index, void* ecall_args, void* exit_target, void* e
init_xsave_size(report.body.attributes.xfrm);

/* pal_linux_main is responsible for checking the passed arguments */
pal_linux_main(COPY_UNTRUSTED_VALUE(&ms->ms_libpal_uri),
COPY_UNTRUSTED_VALUE(&ms->ms_libpal_uri_len),
COPY_UNTRUSTED_VALUE(&ms->ms_args), COPY_UNTRUSTED_VALUE(&ms->ms_args_size),
COPY_UNTRUSTED_VALUE(&ms->ms_env), COPY_UNTRUSTED_VALUE(&ms->ms_env_size),
COPY_UNTRUSTED_VALUE(&ms->ms_parent_stream_fd),
COPY_UNTRUSTED_VALUE(&ms->ms_qe_targetinfo),
COPY_UNTRUSTED_VALUE(&ms->ms_topo_info),
COPY_UNTRUSTED_VALUE(&ms->rpc_queue),
COPY_UNTRUSTED_VALUE(&ms->ms_dns_host_conf),
COPY_UNTRUSTED_VALUE(&ms->ms_reserved_mem_ranges),
COPY_UNTRUSTED_VALUE(&ms->ms_reserved_mem_ranges_size));
pal_linux_main(COPY_UNTRUSTED_VALUE(&start_args->libpal_uri),
COPY_UNTRUSTED_VALUE(&start_args->libpal_uri_len),
COPY_UNTRUSTED_VALUE(&start_args->args),
COPY_UNTRUSTED_VALUE(&start_args->args_size),
COPY_UNTRUSTED_VALUE(&start_args->env),
COPY_UNTRUSTED_VALUE(&start_args->env_size),
COPY_UNTRUSTED_VALUE(&start_args->parent_stream_fd),
COPY_UNTRUSTED_VALUE(&start_args->qe_targetinfo),
COPY_UNTRUSTED_VALUE(&start_args->topo_info),
COPY_UNTRUSTED_VALUE(&start_args->rpc_queue),
COPY_UNTRUSTED_VALUE(&start_args->dns_host_conf),
COPY_UNTRUSTED_VALUE(&start_args->reserved_mem_ranges),
COPY_UNTRUSTED_VALUE(&start_args->reserved_mem_ranges_size));
} else {
// ENCLAVE_START already called (maybe successfully, maybe not), so
// only valid ecall is THREAD_START.
Expand Down
Loading

0 comments on commit f512b33

Please sign in to comment.