Linux 用户态执行
我需要一个 C 库,它允许我 exec() 静态链接的二进制文件,而不调用 execve() 系统调用。系统调用不起作用的原因是二进制文件不可执行,并且不可能使其在该系统上可执行。对于动态链接的二进制文件,运行 /lib/ld-linux.so.2 progname
可以解决问题,但在我的静态链接的二进制文件上会出现段错误。
我在 http://archive.cert 上找到了 ul_exec 1.1。 uni-stuttgart.de/bugtraq/2004/01/msg00002.html ,但这似乎在我的系统上其自己的 Hello, World 二进制文件出现了段错误。
一种选择是制作二进制文件的副本,使副本可执行,然后调用 execve()。我正在寻找一种不需要这样的副本的解决方案(由于性能原因)。
I need a C library which lets me exec() a statically linked binary, without invoking the execve() system call. The reason why the system call wouldn't work is that the binary file is not executable, and it's not possible to make it executable on that system. For dynamically linked binaries, running /lib/ld-linux.so.2 progname
does the trick, but that segfaults on my statically linked binary.
I've found ul_exec 1.1 on http://archive.cert.uni-stuttgart.de/bugtraq/2004/01/msg00002.html , but that seems to segfault for its own Hello, World binary on my system.
One option would be to make a copy of the binary, make the copy executable, and call execve(). I'm looking for a solution which doesn't need such a copy (because of performance reasons).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有一篇很好的简短 wiki 文章,其中包含一些未完全生产就绪的实现: http://plash.beasts .org/wiki/UserModeExec
There is a good short wiki article with some not-completely-production-ready implementations: http://plash.beasts.org/wiki/UserModeExec
我已经更新了 Grugq 的 userland exec 以与现代 x86 Linux 配合使用。我从头开始编写了一个 x86_64 userland exec。
I've updated The Grugq's userland exec to work with modern x86 Linuxes. I wrote an x86_64 userland exec from scratch.
那么将执行位映射到任何指定文件的用户模式文件系统(例如使用 python-fuse)怎么样?这会对性能造成太大影响吗?
then how about a usermode filesystem (using python-fuse for example) that maps the execute bit to any file specified? would that be too much of a performance hit?