libc: execve

This patch implements 'execve' in Genode's libc.

The mechanism relies on the dynamic linker's ability to replace the
loaded binary while keeping crucial libraries - in particular the libc -
intact. The state outside the libc is wiped. For this reason, all libc
internal state needed beyond the 'execve' call must be allocated on a
heap separate from the application-owned malloc heap. E.g.,
libc-internal file-descriptor objects must not be allocated or refer to
any memory object allocated from the malloc heap.

Issue #3481
This commit is contained in:
Norman Feske
2019-08-20 12:18:54 +02:00
committed by Christian Helmuth
parent 2a3cebdd6e
commit 6894ced63b
16 changed files with 527 additions and 146 deletions

View File

@ -63,21 +63,7 @@ namespace Libc {
Id_space::Id id)
: _elem(*this, id_space, id), plugin(&plugin), context(&context) { }
void path(char const *newpath)
{
if (fd_path) { Genode::warning("may leak former FD path memory"); }
if (newpath) {
Genode::size_t const path_size = ::strlen(newpath) + 1;
char *buf = (char*)malloc(path_size);
if (!buf) {
Genode::error("could not allocate path buffer for libc_fd ", libc_fd);
return;
}
::memcpy(buf, newpath, path_size);
fd_path = buf;
} else
fd_path = 0;
}
void path(char const *newpath);
};