Make a workaround for EGO when fstat returns NOT_SUPPORT (#1970)

The problem was found by a `Golang + WAMR (as CGO)` wrapped by EGO
in SGX Enclave.

`fstat()` in EGO returns dummy values:
- EGO uses a `mount` configuration to define the mount points that apply
  the host file system presented to the Encalve.
- EGO has a different programming model: the entire application runs inside
  the enclave. Manual ECALLs/OCALLs by application code are neither
  required nor possible.

Add platform ego and add macro control for the return value checking of
`fd_determine_type_rights` in libc-wasi to resolve the issue.
This commit is contained in:
liang.he
2023-02-21 11:11:27 +08:00
committed by GitHub
parent 37b09d0f24
commit 91eafa1ead
5 changed files with 57 additions and 9 deletions

View File

@ -685,9 +685,20 @@ fd_table_insert_existing(struct fd_table *ft, __wasi_fd_t in, int out)
struct fd_object *fo;
__wasi_errno_t error;
if (fd_determine_type_rights(out, &type, &rights_base, &rights_inheriting)
!= 0)
error =
fd_determine_type_rights(out, &type, &rights_base, &rights_inheriting);
if (error != 0) {
#ifdef BH_PLATFORM_EGO
/**
* since it is an already opened file and we can assume the opened file
* has all necessary rights no matter how to get
*/
if (error != __WASI_ENOTSUP)
return false;
#else
return false;
#endif
}
error = fd_object_new(type, &fo);
if (error != 0)