From d48980f5dffdce261284eb59da24a246e4b7ab71 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 8 Mar 2016 17:40:43 +0100 Subject: [PATCH] added some documentation --- c/linux_loader_poc/README.md | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/c/linux_loader_poc/README.md b/c/linux_loader_poc/README.md index 3c9d63d..092e080 100644 --- a/c/linux_loader_poc/README.md +++ b/c/linux_loader_poc/README.md @@ -1,8 +1,36 @@ -# Custom ELF interpreter under Linux +# Proof-of-concept custom loaders in Linux -This is proof-of-concept shows how to use a custom +This is a proof-of-concept to show different methods to load executables in the Linux kernel with our own loaders / linkers / interpreters. +### Methods -#### Credits +#### 1. binfmt_misc + +We use a kernel module called binfmt_misc to register our own binary format in the Linux kernel. + +The loader will be called in userspace. + +See: https://www.kernel.org/doc/Documentation/binfmt_misc.txt + +See: `demo_binfmt_misc` in Makefile + +#### 2. ELF Interpreter section (INTERP) + +Every dynamically linked ELF executable contains a special section called `.interp`. + +In case the Linux kernel sees such a section, I will load the interpreter instead. +Afterwards, it is the task of the interpreter (usually ld-linux.so) to load all dependencies and do the final relocation. + +See: `demo_interpreter` in the Makefile + +#### 3. Custom kernel module + +We use the binfmt subsystem of the Linux kernel to implement our own format. + +A good example is the loader for the script she-bangs (`#!/bin/bash` et al): + +https://github.com/torvalds/linux/blob/master/fs/binfmt_script.c + +### Credits Steffen Vogel \ No newline at end of file