28.08.2015 Views

The Design and Implementation of the Anykernel and Rump Kernels

1F3KDce

1F3KDce

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

179<br />

pid_t<br />

rumpclient_fork()<br />

{<br />

pid_t rv;<br />

cookie = rumpclient_prefork();<br />

switch ((rv = host_fork())) {<br />

case 0:<br />

rumpclient_fork_init(cookie);<br />

break;<br />

default:<br />

break;<br />

case -1:<br />

error();<br />

}<br />

}<br />

return rv;<br />

Figure 3.36: <strong>Implementation</strong> <strong>of</strong> fork() on <strong>the</strong> client side. <strong>The</strong> prefork<br />

cookie is used to connect <strong>the</strong> newly created child to <strong>the</strong> parent when <strong>the</strong> new remote<br />

process performs <strong>the</strong> rump kernel h<strong>and</strong>shake.<br />

Since calling exec replaces <strong>the</strong> memory image <strong>of</strong> a process with that <strong>of</strong> a new one<br />

from disk, we lose all <strong>of</strong> <strong>the</strong> rump client state in memory. Important state in memory<br />

includes for example rumpclient’s file descriptors. For hijacked clients <strong>the</strong> clearing<br />

<strong>of</strong> memory additionally means we will lose e.g. <strong>the</strong> dup2 file descriptor alias table.<br />

Recall, though, that exec closes only those file descriptors which are set FD_CLOEXEC.<br />

Before calling <strong>the</strong> host’s execve, we first augment <strong>the</strong> environment to contain all<br />

<strong>the</strong> rump client state; librumpclient <strong>and</strong> librumphijack have <strong>the</strong>ir own sets <strong>of</strong> state<br />

as was pointed out above. After that, execve() is called with <strong>the</strong> augmented<br />

environment. When <strong>the</strong> rump client constructor runs, it will search <strong>the</strong> environment<br />

for <strong>the</strong>se variables. If found, it will initialize state from <strong>the</strong>m instead <strong>of</strong> starting from<br />

a pristine state.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!