28.08.2015 Views

The Design and Implementation of the Anykernel and Rump Kernels

1F3KDce

1F3KDce

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

128<br />

Host Dynamic Linker<br />

Using <strong>the</strong> host’s dynamic linker requires that <strong>the</strong> component is in a format that<br />

<strong>the</strong> dynamic linker can underst<strong>and</strong>. In practice, this requirement means that <strong>the</strong><br />

component needs to be a shared library (ELF type ET_DYN). All loading <strong>and</strong> linking<br />

is done by <strong>the</strong> host, but <strong>the</strong> init routine must be run by <strong>the</strong> rump kernel. Revisiting<br />

Table 3.3, a module loaded <strong>and</strong> linked by <strong>the</strong> host is a builtin module from <strong>the</strong><br />

perspective <strong>of</strong> <strong>the</strong> kernel.<br />

Since <strong>the</strong>re is no system call for informing <strong>the</strong> kernel about new builtin modules<br />

appearing at runtime, we defined a rump kernel interface for running <strong>the</strong> init routine.<br />

<strong>The</strong> rump_pub_module_init() routine takes as an argument <strong>the</strong> pointer to <strong>the</strong><br />

beginning <strong>of</strong> <strong>the</strong> modules section <strong>and</strong> <strong>the</strong> number <strong>of</strong> struct modinfo pointers. An<br />

example <strong>of</strong> client side code (adapted from lib/libukfs/ukfs.c) is presented in<br />

Figure 3.16.<br />

In <strong>the</strong> monolithic kernel builtin modules cannot be unloaded because <strong>the</strong>y are loaded<br />

as part <strong>of</strong> <strong>the</strong> kernel at system bootstrap time, <strong>and</strong> are not placed in separately allocated<br />

memory. However, if builtin modules are loaded into a rump kernel with<br />

dlopen(), it is possible to unload modules which are not busy via dlclose(). First,<br />

<strong>the</strong> module’s fini routine should be run so that o<strong>the</strong>r kernel subsystems are no longer<br />

aware <strong>of</strong> it. For running <strong>the</strong> fini routine to be possible, we added <strong>the</strong> concept <strong>of</strong> disabling<br />

a builtin module to NetBSD’s kernel module support. What disabling does is<br />

run <strong>the</strong> fini routine <strong>of</strong> <strong>the</strong> module <strong>the</strong>reby removing <strong>the</strong> functionality from <strong>the</strong> kernel.<br />

This concept is useful also outside <strong>the</strong> scope <strong>of</strong> rump kernels, <strong>and</strong> can for example<br />

be used to disable a driver with a newly discovered security vulnerability, perhaps<br />

making it possible to postpone <strong>the</strong> system upgrade until a suitable time. A rump<br />

kernel client can disable a builtin module by calling rump_pub_module_fini(). If<br />

disabling is successful, it can proceed to call dlclose() to unload <strong>the</strong> module from<br />

memory.

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

Saved successfully!

Ooh no, something went wrong!