intel / intel/confidential-computing.sgx
The psw misinterprets returned values ioctl
- Dominant language
- C++
- Stars
- 1.5k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
In many cases the PSW treats values returned from the `ioctl()` syscall as the error returned from the sgx driver. In reality, ioctl just returns -1 on error and sets errno.
For example:
```
int ret = ioctl(hfile, SGX_IOC_ENCLAVE_ADD_PAGES_IN_KERNEL, &addp);
if (ret) {
SE_TRACE(SE_TRACE_WARNING, "\nAdd Page - %p to %p... FAIL\n", source, target_address);
if (enclave_error != NULL)
*enclave_error = error_driver2api(ret);
```
Should be
```
int ret = ioctl(hfile, SGX_IOC_ENCLAVE_ADD_PAGES_IN_KERNEL, &addp);
if (ret) {
SE_TRACE(SE_TRACE_WARNING, "\nAdd Page - %p to %p... FAIL\n", source, target_address);
if (enclave_error != NULL)
*enclave_error = error_driver2api(errno);
```
Note that this is tested with driver currently being upstreamed in the v26 patchset
Contributor guide
Assessment
This issue has not been assessed yet.