【发布时间】:2020-09-26 10:36:00
【问题描述】:
在我的场景中,父进程(动态)生成一些机器代码,然后该代码应该由子进程执行。子进程不应该能够访问父资源(所以没有分叉),出于安全原因,它必须尽可能地受到限制,我想要这样的东西:
process_handle x;
give_memory_page_to_process(x, mempage); // allows x to access the page
/*some more pages for the child*/
/*remove the memory pages from the parent process*/
execute(x); // should create a process with just the given pages
【问题讨论】:
-
没有分叉?您还如何创建子进程?
-
如果您需要确保子代码无法访问父代码的任何数据,目前最简单的方法是
exec()一些琐碎的帮助程序,其唯一工作是加载和运行代码。您还必须关闭 fds 等等。另一方面,如果您不信任对父内存具有只读访问权限的子代码,您确定您完全信任它可以执行(具有进行系统调用等的全部能力)吗?
标签: c linux macos unix operating-system