User-mode implementation of execve()

User-mode exec is an implementation of the execve() call that works by changing memory mappings from user space, rather than by using the kernel's execve() system call. This includes an ELF loader.

There is a prototype implementation in the scratch directory in SVN. This is mainly useful for PtraceJail.

User-mode exec must do the following things:

It's not possible to unmap all the code used by the caller. At least a page containing the exec code must remain.

Is it possible to shrink the stack? Is the stack usually mapped with MAP_GROWSDOWN? Note that the heap and stack are marked in /proc/self/maps with "[heap]" and "[stack]" so the kernel is presumably treating them as special cases.

Differences from kernel execve():

One nice side effect of a user mode execve() is that it can remove any limits on size of command line arguments that the kernel might normally impose.

Related work

QEMU includes an ELF loader for its "user mode emulation" (running individual emulated processes rather than whole machines). See http://cvs.savannah.nongnu.org/viewcvs/qemu/linux-user/?root=qemu.

grugq provides an implementation of a user-mode exec, described in "The Design and Implementation of Userland Exec".

rtldi implements an ELF loader for the purpose of chain loading another version of the dynamic linker (ld.so).

UserModeExec (last edited 2007-07-11 22:22:54 by MarkSeaborn)