Skip to content

Commit

Permalink
Store untrusted output pointer in enclave
Browse files Browse the repository at this point in the history
Validate the pointer after it's stored in enclave to avoid unexpected
modifications after it's validated.

PiperOrigin-RevId: 365648810
Change-Id: I3079128040c142e86bab8255b07d03562a6fcb61
  • Loading branch information
kongoshuu committed Mar 29, 2021
1 parent e73373f commit 53ed5d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions asylo/platform/primitives/sgx/trusted_sgx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,16 @@ PrimitiveStatus TrustedPrimitives::UntrustedCall(uint64_t untrusted_selector,
if (sgx_params->input) {
untrusted_cache->Free(const_cast<void *>(sgx_params->input));
}
if (!TrustedPrimitives::IsOutsideEnclave(sgx_params->output,
sgx_params->output_size)) {
const void *output_pointer = sgx_params->output;
uint64_t output_size = sgx_params->output_size;
if (!TrustedPrimitives::IsOutsideEnclave(output_pointer, output_size)) {
TrustedPrimitives::BestEffortAbort(
"UntrustedCall: sgx_param output should be in untrusted memory");
}
if (sgx_params->output) {
// For the results obtained in |output_buffer|, copy them to |output|
// before freeing the buffer.
output->Deserialize(sgx_params->output, sgx_params->output_size);
output->Deserialize(output_pointer, output_size);
TrustedPrimitives::UntrustedLocalFree(sgx_params->output);
}
return PrimitiveStatus::OkStatus();
Expand Down

0 comments on commit 53ed5d8

Please sign in to comment.