db_process.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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. /* Copyright (C) 2014 Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * db_process.c
  17. *
  18. * This source file contains functions to create a child process and terminate
  19. * the running process. Child does not inherit any objects or memory from its
  20. * parent pricess. A Parent process may not modify the execution of its
  21. * children. It can wait for a child to exit using its handle. Also, parent and
  22. * child may communicate through I/O streams provided by the parent to the child
  23. * at creation.
  24. */
  25. #include "pal_defs.h"
  26. #include "pal_linux_defs.h"
  27. #include "pal.h"
  28. #include "pal_internal.h"
  29. #include "pal_linux.h"
  30. #include "pal_debug.h"
  31. #include "pal_error.h"
  32. #include "pal_security.h"
  33. #include "pal_rtld.h"
  34. #include "graphene.h"
  35. #include "graphene-ipc.h"
  36. #include "api.h"
  37. #include <linux/sched.h>
  38. #include <linux/types.h>
  39. typedef __kernel_pid_t pid_t;
  40. #include <asm/fcntl.h>
  41. #include <sys/socket.h>
  42. #include <asm/errno.h>
  43. #ifndef SEEK_SET
  44. # define SEEK_SET 0
  45. #endif
  46. static inline int create_process_handle (PAL_HANDLE * parent,
  47. PAL_HANDLE * child)
  48. {
  49. PAL_HANDLE phdl = NULL, chdl = NULL;
  50. int fds[6] = { -1, -1, -1, -1, -1, -1 };
  51. int ret;
  52. if (IS_ERR((ret = INLINE_SYSCALL(pipe2, 2, &fds[0], O_CLOEXEC))) ||
  53. IS_ERR((ret = INLINE_SYSCALL(pipe2, 2, &fds[2], O_CLOEXEC))) ||
  54. IS_ERR((ret = INLINE_SYSCALL(socketpair, 4, AF_UNIX,
  55. SOCK_STREAM|SOCK_CLOEXEC,
  56. 0, &fds[4])))) {
  57. ret = -PAL_ERROR_DENIED;
  58. goto out;
  59. }
  60. int proc_fds[2][3] = {
  61. { fds[0], fds[3], fds[4] },
  62. { fds[2], fds[1], fds[5] },
  63. };
  64. phdl = malloc(HANDLE_SIZE(process));
  65. if (!phdl) {
  66. ret = -PAL_ERROR_NOMEM;
  67. goto out;
  68. }
  69. SET_HANDLE_TYPE(phdl, process);
  70. HANDLE_HDR(phdl)->flags |= RFD(0)|WFD(1)|RFD(2)|WFD(2)|WRITEABLE(1)|WRITEABLE(2);
  71. phdl->process.stream_in = proc_fds[0][0];
  72. phdl->process.stream_out = proc_fds[0][1];
  73. phdl->process.cargo = proc_fds[0][2];
  74. phdl->process.pid = linux_state.pid;
  75. phdl->process.nonblocking = PAL_FALSE;
  76. chdl = malloc(HANDLE_SIZE(process));
  77. if (!chdl) {
  78. ret = -PAL_ERROR_NOMEM;
  79. goto out;
  80. }
  81. SET_HANDLE_TYPE(chdl, process);
  82. HANDLE_HDR(chdl)->flags |= RFD(0)|WFD(1)|RFD(2)|WFD(2)|WRITEABLE(1)|WRITEABLE(2);
  83. chdl->process.stream_in = proc_fds[1][0];
  84. chdl->process.stream_out = proc_fds[1][1];
  85. chdl->process.cargo = proc_fds[1][2];
  86. chdl->process.pid = 0; /* unknown yet */
  87. chdl->process.nonblocking = PAL_FALSE;
  88. *parent = phdl;
  89. *child = chdl;
  90. ret = 0;
  91. out:
  92. if (ret < 0) {
  93. if (phdl)
  94. _DkObjectClose(phdl);
  95. if (chdl)
  96. _DkObjectClose(chdl);
  97. for (int i = 0 ; i < 6 ; i++)
  98. if (fds[i] != -1)
  99. INLINE_SYSCALL(close, 1, fds[i]);
  100. }
  101. return ret;
  102. }
  103. struct proc_param {
  104. PAL_HANDLE parent;
  105. PAL_HANDLE exec;
  106. PAL_HANDLE manifest;
  107. const char ** argv;
  108. };
  109. struct proc_args {
  110. PAL_NUM parent_process_id;
  111. struct pal_sec pal_sec;
  112. #if PROFILING == 1
  113. unsigned long process_create_time;
  114. #endif
  115. unsigned long memory_quota;
  116. unsigned int parent_data_size;
  117. unsigned int exec_data_size;
  118. unsigned int manifest_data_size;
  119. };
  120. static int child_process (void * param)
  121. {
  122. struct proc_param * proc_param = param;
  123. int ret;
  124. ret = INLINE_SYSCALL(dup2, 2, proc_param->parent->process.stream_in,
  125. PROC_INIT_FD);
  126. if (IS_ERR(ret))
  127. goto failed;
  128. if (proc_param->parent)
  129. handle_set_cloexec(proc_param->parent, false);
  130. if (proc_param->exec)
  131. handle_set_cloexec(proc_param->exec, false);
  132. if (proc_param->manifest)
  133. handle_set_cloexec(proc_param->manifest, false);
  134. INLINE_SYSCALL(execve, 3, PAL_LOADER, proc_param->argv,
  135. linux_state.environ);
  136. failed:
  137. /* fail is it gets here */
  138. return -PAL_ERROR_DENIED;
  139. }
  140. int _DkProcessCreate (PAL_HANDLE * handle, const char * uri, const char ** args)
  141. {
  142. PAL_HANDLE exec = NULL;
  143. PAL_HANDLE parent_handle = NULL, child_handle = NULL;
  144. int ret;
  145. #if PROFILING == 1
  146. unsigned long before_create = _DkSystemTimeQuery();
  147. #endif
  148. /* step 1: open uri and check whether it is an executable */
  149. if (uri) {
  150. if ((ret = _DkStreamOpen(&exec, uri, PAL_ACCESS_RDONLY, 0, 0, 0)) < 0)
  151. return ret;
  152. if (check_elf_object(exec) < 0) {
  153. ret = -PAL_ERROR_INVAL;
  154. goto out;
  155. }
  156. /* If this process creation is for fork emulation,
  157. * map address of executable is already determined.
  158. * tell its address to forked process.
  159. */
  160. size_t len;
  161. const char * file_uri = "file:";
  162. if (exec_map && exec_map->l_name &&
  163. (len = strlen(uri)) >= 5 && !memcmp(uri, file_uri, 5) &&
  164. /* skip "file:"*/
  165. strlen(exec_map->l_name) == len - 5 &&
  166. /* + 1 for lasting * NUL */
  167. !memcmp(exec_map->l_name, uri + 5, len - 5 + 1))
  168. exec->file.map_start = (PAL_PTR)exec_map->l_map_start;
  169. }
  170. /* step 2: create parant and child process handle */
  171. struct proc_param param;
  172. ret = create_process_handle(&parent_handle, &child_handle);
  173. if (ret < 0)
  174. goto out;
  175. param.parent = parent_handle;
  176. param.exec = exec;
  177. param.manifest = pal_state.manifest_handle;
  178. /* step 3: compose process parameter */
  179. int parent_datasz = 0, exec_datasz = 0, manifest_datasz = 0;
  180. void * parent_data = NULL;
  181. void * exec_data = NULL;
  182. void * manifest_data = NULL;
  183. ret = handle_serialize(parent_handle, &parent_data);
  184. if (ret < 0)
  185. goto out;
  186. parent_datasz = ret;
  187. if (exec) {
  188. ret = handle_serialize(exec, &exec_data);
  189. if (ret < 0) {
  190. free(parent_data);
  191. goto out;
  192. }
  193. exec_datasz = ret;
  194. }
  195. if (pal_state.manifest_handle) {
  196. ret = handle_serialize(pal_state.manifest_handle, &manifest_data);
  197. if (ret < 0) {
  198. free(parent_data);
  199. free(exec_data);
  200. goto out;
  201. }
  202. manifest_datasz = ret;
  203. }
  204. unsigned int datasz = parent_datasz + exec_datasz + manifest_datasz;
  205. struct proc_args * proc_args =
  206. __alloca(sizeof(struct proc_args) + datasz);
  207. proc_args->parent_process_id = linux_state.parent_process_id;
  208. memcpy(&proc_args->pal_sec, &pal_sec, sizeof(struct pal_sec));
  209. proc_args->pal_sec._dl_debug_state = NULL;
  210. proc_args->pal_sec._r_debug = NULL;
  211. proc_args->memory_quota = linux_state.memory_quota;
  212. void * data = (void *) (proc_args + 1);
  213. memcpy(data, parent_data, parent_datasz);
  214. data += (proc_args->parent_data_size = parent_datasz);
  215. free(parent_data);
  216. if (exec_data) {
  217. memcpy(data, exec_data, exec_datasz);
  218. data += (proc_args->exec_data_size = exec_datasz);
  219. free(exec_data);
  220. } else {
  221. proc_args->exec_data_size = 0;
  222. }
  223. if (manifest_data) {
  224. memcpy(data, manifest_data, manifest_datasz);
  225. data += (proc_args->manifest_data_size = manifest_datasz);
  226. free(manifest_data);
  227. } else {
  228. proc_args->manifest_data_size = 0;
  229. }
  230. /* step 4: create a child thread which will execve in the future */
  231. /* the first arguement must be the PAL */
  232. int argc = 0;
  233. if (args)
  234. for (; args[argc] ; argc++);
  235. param.argv = __alloca(sizeof(const char *) * (argc + 2));
  236. param.argv[0] = PAL_LOADER;
  237. if (args)
  238. memcpy(&param.argv[1], args, sizeof(const char *) * argc);
  239. param.argv[argc + 1] = NULL;
  240. #if PROFILING == 1
  241. proc_args->process_create_time = before_create;
  242. #endif
  243. ret = ARCH_VFORK();
  244. if (IS_ERR(ret)) {
  245. ret = -PAL_ERROR_DENIED;
  246. goto out;
  247. }
  248. if (!ret) {
  249. ret = child_process(&param);
  250. goto out; /* if child_process returned, there was a failure */
  251. }
  252. proc_args->pal_sec.process_id = ret;
  253. child_handle->process.pid = ret;
  254. /* step 4: send parameters over the process handle */
  255. ret = INLINE_SYSCALL(write, 3,
  256. child_handle->process.stream_out,
  257. proc_args,
  258. sizeof(struct proc_args) + datasz);
  259. if (IS_ERR(ret) ||
  260. ret < sizeof(struct proc_args) + datasz) {
  261. ret = -PAL_ERROR_DENIED;
  262. goto out;
  263. }
  264. *handle = child_handle;
  265. ret = 0;
  266. out:
  267. if (parent_handle)
  268. _DkObjectClose(parent_handle);
  269. if (exec)
  270. _DkObjectClose(exec);
  271. if (ret < 0) {
  272. if (child_handle)
  273. _DkObjectClose(child_handle);
  274. }
  275. return ret;
  276. }
  277. void init_child_process (PAL_HANDLE * parent_handle,
  278. PAL_HANDLE * exec_handle,
  279. PAL_HANDLE * manifest_handle)
  280. {
  281. int ret = 0;
  282. /* try to do a very large reading, so it doesn't have to be read for the
  283. second time */
  284. struct proc_args * proc_args = __alloca(sizeof(struct proc_args));
  285. struct proc_args * new_proc_args;
  286. int bytes = INLINE_SYSCALL(read, 3, PROC_INIT_FD, proc_args,
  287. sizeof(*proc_args));
  288. if (IS_ERR(bytes)) {
  289. if (ERRNO(bytes) != EBADF)
  290. INIT_FAIL(PAL_ERROR_DENIED, "communication fail with parent");
  291. /* in the first process */
  292. /* occupy PROC_INIT_FD so no one will use it */
  293. INLINE_SYSCALL(dup2, 2, 0, PROC_INIT_FD);
  294. return;
  295. }
  296. /* a child must have parent handle and an executable */
  297. if (!proc_args->parent_data_size)
  298. INIT_FAIL(PAL_ERROR_INVAL, "invalid process created");
  299. int datasz = proc_args->parent_data_size + proc_args->exec_data_size +
  300. proc_args->manifest_data_size;
  301. if (!datasz)
  302. goto no_data;
  303. new_proc_args = __alloca(sizeof(*proc_args) + datasz);
  304. memcpy(new_proc_args, proc_args, sizeof(*proc_args));
  305. proc_args = new_proc_args;
  306. void * data = (void *) (proc_args + 1);
  307. bytes = INLINE_SYSCALL(read, 3, PROC_INIT_FD, data, datasz);
  308. if (IS_ERR(bytes))
  309. INIT_FAIL(PAL_ERROR_DENIED, "communication fail with parent");
  310. /* now deserialize the parent_handle */
  311. PAL_HANDLE parent = NULL;
  312. ret = handle_deserialize(&parent, data, proc_args->parent_data_size);
  313. if (ret < 0)
  314. INIT_FAIL(-ret, "cannot deseilaize parent process handle");
  315. data += proc_args->parent_data_size;
  316. *parent_handle = parent;
  317. /* occupy PROC_INIT_FD so no one will use it */
  318. INLINE_SYSCALL(dup2, 2, 0, PROC_INIT_FD);
  319. /* deserialize the executable handle */
  320. if (proc_args->exec_data_size) {
  321. PAL_HANDLE exec = NULL;
  322. ret = handle_deserialize(&exec, data,
  323. proc_args->exec_data_size);
  324. if (ret < 0)
  325. INIT_FAIL(-ret, "cannot deserialize executable handle");
  326. data += proc_args->exec_data_size;
  327. *exec_handle = exec;
  328. }
  329. /* deserialize the manifest handle, if there is one */
  330. if (proc_args->manifest_data_size) {
  331. PAL_HANDLE manifest = NULL;
  332. ret = handle_deserialize(&manifest, data,
  333. proc_args->manifest_data_size);
  334. if (ret < 0)
  335. INIT_FAIL(-ret, "cannot deserialize manifest handle");
  336. data += proc_args->manifest_data_size;
  337. *manifest_handle = manifest;
  338. }
  339. no_data:
  340. linux_state.parent_process_id = proc_args->parent_process_id;
  341. linux_state.memory_quota = proc_args->memory_quota;
  342. #if PROFILING == 1
  343. pal_state.process_create_time = proc_args->process_create_time;
  344. #endif
  345. memcpy(&pal_sec, &proc_args->pal_sec, sizeof(struct pal_sec));
  346. }
  347. void _DkProcessExit (int exitcode)
  348. {
  349. INLINE_SYSCALL(exit_group, 1, exitcode);
  350. }
  351. int ioctl_set_graphene (struct config_store * config, int ndefault,
  352. const struct graphene_user_policy * default_policies);
  353. static int set_graphene_task (const char * uri, int flags)
  354. {
  355. PAL_HANDLE handle = NULL;
  356. int ret;
  357. if ((ret = _DkStreamOpen(&handle, uri, PAL_ACCESS_RDONLY, 0, 0, 0)) < 0)
  358. return ret;
  359. PAL_STREAM_ATTR attr;
  360. if ((ret = _DkStreamAttributesQueryByHandle(handle, &attr)) < 0)
  361. goto out;
  362. void * addr = NULL;
  363. size_t size = attr.pending_size;
  364. if ((ret = _DkStreamMap(handle, &addr, PAL_PROT_READ, 0,
  365. ALLOC_ALIGNUP(size))) < 0)
  366. goto out;
  367. struct config_store sandbox_config;
  368. sandbox_config.raw_data = addr;
  369. sandbox_config.raw_size = size;
  370. sandbox_config.malloc = malloc;
  371. sandbox_config.free = free;
  372. if ((ret = read_config(&sandbox_config, NULL, NULL)) < 0)
  373. goto out_mem;
  374. struct graphene_user_policy policies[5], * p = policies;
  375. if (strpartcmp_static(uri, "file:")) {
  376. p->type = GRAPHENE_FS_PATH | GRAPHENE_FS_READ;
  377. p->value = &uri[5];
  378. p++;
  379. }
  380. if (flags & PAL_SANDBOX_PIPE) {
  381. p->type = GRAPHENE_UNIX_PREFIX;
  382. p->value = &pal_sec.pipe_prefix_id;
  383. p++;
  384. p->type = GRAPHENE_MCAST_PORT;
  385. p->value = &pal_sec.mcast_port;
  386. p++;
  387. }
  388. p->type = GRAPHENE_FS_PATH | GRAPHENE_FS_READ;
  389. p->value = "/proc/meminfo";
  390. p++;
  391. ret = ioctl_set_graphene(&sandbox_config, p - policies, policies);
  392. if (ret < 0)
  393. goto out_mem;
  394. pal_state.manifest = uri;
  395. _DkObjectClose(pal_state.manifest_handle);
  396. pal_state.manifest_handle = handle;
  397. free_config(&sandbox_config);
  398. out_mem:
  399. _DkStreamUnmap(sandbox_config.raw_data,
  400. ALLOC_ALIGNUP(sandbox_config.raw_size));
  401. out:
  402. _DkObjectClose(handle);
  403. return ret;
  404. }
  405. int _DkProcessSandboxCreate (const char * manifest, int flags)
  406. {
  407. return set_graphene_task(manifest, flags);
  408. }
  409. static int64_t proc_read (PAL_HANDLE handle, uint64_t offset, uint64_t count,
  410. void * buffer)
  411. {
  412. if (offset)
  413. return -PAL_ERROR_INVAL;
  414. int64_t bytes = INLINE_SYSCALL(read, 3, handle->process.stream_in, buffer,
  415. count);
  416. if (IS_ERR(bytes))
  417. switch(ERRNO(bytes)) {
  418. case EWOULDBLOCK:
  419. return -PAL_ERROR_TRYAGAIN;
  420. case EINTR:
  421. return -PAL_ERROR_INTERRUPTED;
  422. default:
  423. return -PAL_ERROR_DENIED;
  424. }
  425. return bytes;
  426. }
  427. static int64_t proc_write (PAL_HANDLE handle, uint64_t offset, uint64_t count,
  428. const void * buffer)
  429. {
  430. if (offset)
  431. return -PAL_ERROR_INVAL;
  432. int64_t bytes = INLINE_SYSCALL(write, 3, handle->process.stream_out, buffer,
  433. count);
  434. if (IS_ERR(bytes))
  435. switch(ERRNO(bytes)) {
  436. case EWOULDBLOCK:
  437. HANDLE_HDR(handle)->flags &= ~WRITEABLE(1);
  438. return -PAL_ERROR_TRYAGAIN;
  439. case EINTR:
  440. return -PAL_ERROR_INTERRUPTED;
  441. default:
  442. return -PAL_ERROR_DENIED;
  443. }
  444. if (bytes == count)
  445. HANDLE_HDR(handle)->flags |= WRITEABLE(1);
  446. else
  447. HANDLE_HDR(handle)->flags &= ~WRITEABLE(1);
  448. return bytes;
  449. }
  450. static int proc_close (PAL_HANDLE handle)
  451. {
  452. if (handle->process.stream_in != PAL_IDX_POISON) {
  453. INLINE_SYSCALL(close, 1, handle->process.stream_in);
  454. handle->process.stream_in = PAL_IDX_POISON;
  455. }
  456. if (handle->process.stream_out != PAL_IDX_POISON) {
  457. INLINE_SYSCALL(close, 1, handle->process.stream_out);
  458. handle->process.stream_out = PAL_IDX_POISON;
  459. }
  460. if (handle->process.cargo != PAL_IDX_POISON) {
  461. INLINE_SYSCALL(close, 1, handle->process.cargo);
  462. handle->process.cargo = PAL_IDX_POISON;
  463. }
  464. return 0;
  465. }
  466. static int proc_delete (PAL_HANDLE handle, int access)
  467. {
  468. int shutdown;
  469. switch (access) {
  470. case 0:
  471. shutdown = SHUT_RDWR;
  472. break;
  473. case PAL_DELETE_RD:
  474. shutdown = SHUT_RD;
  475. break;
  476. case PAL_DELETE_WR:
  477. shutdown = SHUT_WR;
  478. break;
  479. default:
  480. return -PAL_ERROR_INVAL;
  481. }
  482. if (access != PAL_DELETE_WR &&
  483. handle->process.stream_in != PAL_IDX_POISON) {
  484. INLINE_SYSCALL(close, 1, handle->process.stream_in);
  485. handle->process.stream_in = PAL_IDX_POISON;
  486. }
  487. if (access != PAL_DELETE_RD &&
  488. handle->process.stream_out != PAL_IDX_POISON) {
  489. INLINE_SYSCALL(close, 1, handle->process.stream_out);
  490. handle->process.stream_out = PAL_IDX_POISON;
  491. }
  492. if (handle->process.cargo != PAL_IDX_POISON)
  493. INLINE_SYSCALL(shutdown, 2, handle->process.cargo, shutdown);
  494. return 0;
  495. }
  496. #ifndef FIONREAD
  497. # define FIONREAD 0x541B
  498. #endif
  499. static int proc_attrquerybyhdl (PAL_HANDLE handle, PAL_STREAM_ATTR * attr)
  500. {
  501. int ret, val;
  502. if (handle->process.stream_in == PAL_IDX_POISON)
  503. return -PAL_ERROR_BADHANDLE;
  504. ret = INLINE_SYSCALL(ioctl, 3, handle->process.stream_in, FIONREAD, &val);
  505. if (IS_ERR(ret))
  506. return unix_to_pal_error(ERRNO(ret));
  507. attr->handle_type = pal_type_process;
  508. attr->nonblocking = handle->process.nonblocking;
  509. attr->disconnected = HANDLE_HDR(handle)->flags & (ERROR(0)|ERROR(1));
  510. attr->readable = !!val;
  511. attr->writeable = HANDLE_HDR(handle)->flags & WRITEABLE(1);
  512. attr->runnable = PAL_FALSE;
  513. attr->pending_size = val;
  514. return 0;
  515. }
  516. static int proc_attrsetbyhdl (PAL_HANDLE handle, PAL_STREAM_ATTR * attr)
  517. {
  518. if (handle->process.stream_in == PAL_IDX_POISON)
  519. return -PAL_ERROR_BADHANDLE;
  520. int ret;
  521. if (attr->nonblocking != handle->process.nonblocking) {
  522. ret = INLINE_SYSCALL(fcntl, 3, handle->process.stream_in, F_SETFL,
  523. handle->process.nonblocking ? O_NONBLOCK : 0);
  524. if (IS_ERR(ret))
  525. return unix_to_pal_error(ERRNO(ret));
  526. handle->process.nonblocking = attr->nonblocking;
  527. }
  528. return 0;
  529. }
  530. struct handle_ops proc_ops = {
  531. .read = &proc_read,
  532. .write = &proc_write,
  533. .close = &proc_close,
  534. .delete = &proc_delete,
  535. .attrquerybyhdl = &proc_attrquerybyhdl,
  536. .attrsetbyhdl = &proc_attrsetbyhdl,
  537. };