I need to modify the ELF loader's kernel implementation of an Ubuntu 14.04 distribution. Having downloaded the sources using:
sudo apt-get source linux-image-$(uname -r)
I ran the configuration script:
in the root source tree. After a seemingly endless sequence of input requests, the script created the
.config file needed to build the kernel (or a set of modules). The kernel version that I am using is
linux-3.13.0, and it has the following source tree layout:
$ ls arch Documentation fs kernel README sound block drivers include lib REPORTING-BUGS tools COPYING dropped.txt init MAINTAINERS samples ubuntu CREDITS elf.dat ipc Makefile scripts usr crypto FileSystemMake Kbuild mm security virt debian.master firmware Kconfig net shortcuts
The ELF loader is located in
/path/to/source/fs/binfmt_elf.c. Following this question, in order to compile an individual module it is sufficient to run
In this case that would be:
The compilation is quite lengthy; it takes about twenty minutes (on a virtual machine) and the output is written (by default) in the same directory in which the module is located. I've found the object files by running:
find . -name "*.o"
/path/to/source/fs. Filtering by name, the ELF loader can be located by running:
find . -name "*elf*.o"
In the current sources it is written (by default) in:
Having gone through this tutorial, I've noticed that kernel modules have the naming convention
module_name.ko in order to distinguish them from user space object files.
How can I insert the new (modified) ELF loader into the kernel, given that the current ELF loader is present (and unloading it may prevent binaries from being executed)?