Skip to content

Conversation

private-yusuke
Copy link

Normally, when invoking an ECALL, we first need to line up two arguments, eid and retval, to obtain the result of the ECALL from an untrusted environment. However, the current definition of the macro enclave! does not support using ECALL appropriately, effectively rendering the first argument other than eid and retval unusable within the enclave.

For example, consider the following function defined within the trusted block of enclave.edl:

public sgx_status_t ecall_test(
    int a,
    int b
);

After macro expansion, the generated code running in the untrusted environment would incorrectly attempt to invoke this function as ecall_test(eid, a, b, retval). The correct invocation should be ecall_test(eid, retval, a, b).

This issue did not manifest previously when ECALLs did not include any user-defined arguments, resulting in invocations such as f(eid, retval).

These suggested changes have been validated in my project based on sgx-scaffold.

@javierron
Copy link

@private-yusuke great fix, 🙏 This needs to be merged.

@chzyer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants