ocall_types.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /*
  4. * This is for enclave to make ocalls to untrusted runtime.
  5. */
  6. #include "linux_types.h"
  7. /*
  8. * GCC's structure padding may cause leaking from uninialized
  9. * regions (https://arxiv.org/abs/1710.09061).
  10. * A simple contermeasure is to enable packing for all ocall
  11. * argument structures.
  12. */
  13. #pragma pack(push, 1)
  14. enum {
  15. OCALL_EXIT = 0,
  16. OCALL_PRINT_STRING,
  17. OCALL_ALLOC_UNTRUSTED,
  18. OCALL_MAP_UNTRUSTED,
  19. OCALL_UNMAP_UNTRUSTED,
  20. OCALL_CPUID,
  21. OCALL_OPEN,
  22. OCALL_CLOSE,
  23. OCALL_READ,
  24. OCALL_WRITE,
  25. OCALL_FSTAT,
  26. OCALL_FIONREAD,
  27. OCALL_FSETNONBLOCK,
  28. OCALL_FCHMOD,
  29. OCALL_FSYNC,
  30. OCALL_FTRUNCATE,
  31. OCALL_MKDIR,
  32. OCALL_GETDENTS,
  33. OCALL_WAKE_THREAD,
  34. OCALL_CREATE_PROCESS,
  35. OCALL_FUTEX,
  36. OCALL_SOCKETPAIR,
  37. OCALL_SOCK_LISTEN,
  38. OCALL_SOCK_ACCEPT,
  39. OCALL_SOCK_CONNECT,
  40. OCALL_SOCK_RECV,
  41. OCALL_SOCK_SEND,
  42. OCALL_SOCK_RECV_FD,
  43. OCALL_SOCK_SEND_FD,
  44. OCALL_SOCK_SETOPT,
  45. OCALL_SOCK_SHUTDOWN,
  46. OCALL_GETTIME,
  47. OCALL_SLEEP,
  48. OCALL_POLL,
  49. OCALL_RENAME,
  50. OCALL_DELETE,
  51. OCALL_LOAD_DEBUG,
  52. OCALL_NR,
  53. };
  54. #define OCALL_NO_TIMEOUT ((uint64_t) -1)
  55. typedef struct {
  56. const char * ms_str;
  57. unsigned int ms_length;
  58. } ms_ocall_print_string_t;
  59. typedef struct {
  60. uint64_t ms_size;
  61. void * ms_mem;
  62. } ms_ocall_alloc_untrusted_t;
  63. typedef struct {
  64. int ms_fd;
  65. uint64_t ms_offset;
  66. uint64_t ms_size;
  67. unsigned short ms_prot;
  68. void * ms_mem;
  69. } ms_ocall_map_untrusted_t;
  70. typedef struct {
  71. const void * ms_mem;
  72. uint64_t ms_size;
  73. } ms_ocall_unmap_untrusted_t;
  74. typedef struct {
  75. unsigned int ms_leaf;
  76. unsigned int ms_subleaf;
  77. unsigned int ms_values[4];
  78. } ms_ocall_cpuid_t;
  79. typedef struct {
  80. const char * ms_pathname;
  81. int ms_flags;
  82. unsigned short ms_mode;
  83. } ms_ocall_open_t;
  84. typedef struct {
  85. int ms_fd;
  86. } ms_ocall_close_t;
  87. typedef struct {
  88. int ms_fd;
  89. void * ms_buf;
  90. unsigned int ms_count;
  91. } ms_ocall_read_t;
  92. typedef struct {
  93. int ms_fd;
  94. const void * ms_buf;
  95. unsigned int ms_count;
  96. } ms_ocall_write_t;
  97. typedef struct {
  98. int ms_fd;
  99. struct stat ms_stat;
  100. } ms_ocall_fstat_t;
  101. typedef struct {
  102. int ms_fd;
  103. } ms_ocall_fionread_t;
  104. typedef struct {
  105. int ms_fd;
  106. int ms_nonblocking;
  107. } ms_ocall_fsetnonblock_t;
  108. typedef struct {
  109. int ms_fd;
  110. unsigned short ms_mode;
  111. } ms_ocall_fchmod_t;
  112. typedef struct {
  113. int ms_fd;
  114. } ms_ocall_fsync_t;
  115. typedef struct {
  116. int ms_fd;
  117. uint64_t ms_length;
  118. } ms_ocall_ftruncate_t;
  119. typedef struct {
  120. const char * ms_pathname;
  121. unsigned short ms_mode;
  122. } ms_ocall_mkdir_t;
  123. typedef struct {
  124. int ms_fd;
  125. struct linux_dirent64 * ms_dirp;
  126. unsigned int ms_size;
  127. } ms_ocall_getdents_t;
  128. typedef struct {
  129. unsigned int ms_pid;
  130. const char * ms_uri;
  131. int ms_proc_fds[3];
  132. int ms_nargs;
  133. const char * ms_args[];
  134. } ms_ocall_create_process_t;
  135. typedef struct {
  136. int * ms_futex;
  137. int ms_op, ms_val;
  138. uint64_t ms_timeout;
  139. } ms_ocall_futex_t;
  140. typedef struct {
  141. int ms_domain, ms_type, ms_protocol;
  142. int ms_sockfds[2];
  143. } ms_ocall_socketpair_t;
  144. typedef struct {
  145. int ms_domain, ms_type, ms_protocol;
  146. const struct sockaddr * ms_addr;
  147. unsigned int ms_addrlen;
  148. struct sockopt ms_sockopt;
  149. } ms_ocall_sock_listen_t;
  150. typedef struct {
  151. int ms_sockfd;
  152. struct sockaddr * ms_addr;
  153. unsigned int ms_addrlen;
  154. struct sockopt ms_sockopt;
  155. } ms_ocall_sock_accept_t;
  156. typedef struct {
  157. int ms_domain, ms_type, ms_protocol;
  158. const struct sockaddr * ms_addr;
  159. unsigned int ms_addrlen;
  160. struct sockaddr * ms_bind_addr;
  161. unsigned int ms_bind_addrlen;
  162. struct sockopt ms_sockopt;
  163. } ms_ocall_sock_connect_t;
  164. typedef struct {
  165. int ms_sockfd;
  166. void * ms_buf;
  167. unsigned int ms_count;
  168. struct sockaddr * ms_addr;
  169. unsigned int ms_addrlen;
  170. } ms_ocall_sock_recv_t;
  171. typedef struct {
  172. int ms_sockfd;
  173. const void * ms_buf;
  174. unsigned int ms_count;
  175. const struct sockaddr * ms_addr;
  176. unsigned int ms_addrlen;
  177. } ms_ocall_sock_send_t;
  178. typedef struct {
  179. int ms_sockfd;
  180. void * ms_buf;
  181. unsigned int ms_count;
  182. unsigned int * ms_fds;
  183. unsigned int ms_nfds;
  184. } ms_ocall_sock_recv_fd_t;
  185. typedef struct {
  186. int ms_sockfd;
  187. const void * ms_buf;
  188. unsigned int ms_count;
  189. const unsigned int * ms_fds;
  190. unsigned int ms_nfds;
  191. } ms_ocall_sock_send_fd_t;
  192. typedef struct {
  193. int ms_sockfd;
  194. int ms_level;
  195. int ms_optname;
  196. const void * ms_optval;
  197. unsigned int ms_optlen;
  198. } ms_ocall_sock_setopt_t;
  199. typedef struct {
  200. int ms_sockfd;
  201. int ms_how;
  202. } ms_ocall_sock_shutdown_t;
  203. typedef struct {
  204. unsigned long ms_microsec;
  205. } ms_ocall_gettime_t;
  206. typedef struct {
  207. unsigned long ms_microsec;
  208. } ms_ocall_sleep_t;
  209. typedef struct {
  210. struct pollfd * ms_fds;
  211. int ms_nfds;
  212. uint64_t ms_timeout;
  213. } ms_ocall_poll_t;
  214. typedef struct {
  215. const char * ms_oldpath;
  216. const char * ms_newpath;
  217. } ms_ocall_rename_t;
  218. typedef struct {
  219. const char * ms_pathname;
  220. } ms_ocall_delete_t;
  221. typedef struct {
  222. unsigned int ms_tid;
  223. } ms_ocall_schedule_t;
  224. #pragma pack(pop)