Dispatches / a short note
Kernel modules for your own file format
Making your own kernel modules for your private use.
Author wants to strip out unwanted metadata from a C binary, and successfully reduces his 4KB binary to 40bytes (with standard ELF executable format). Then reduces further to 35 bytes (with a.out executable format). Author wants even smaller binary, he then finds MS-DOS’s file format (.com) - which is truly a flat format without any form of metadata in the executable - just pure CPU instructions.
Then the author tries to create a kernel module to add support for .com file in kernel (wait, that does not count as interpreter)?
… some unfortunate things are remarkably easy to do. For example, one time while working on my kernel module, I accidentally put --i instead of ++i in the iterator of my for loop. I inserted that module into my kernel to test it, and my mouse cursor disappeared, and my music stopped playing
Suddenly Android messed up with audio / video after a random software update makes a lot of sense now… I digress.
And finally, after loading his newly made custom module with insmod, Author creates the smallest binary - it was 12bytes in size (totals to 96bits, just 32bit more than 64bit single integer).
NO, HE MADE ANOTHER BINARY WITH 7BYTES (WOW, that’s only slightly larger than a single 32bit integer). Of course he didn’t want to stop there. Now he wants his stripped off binaries to have the privilege to access dynamic memory…, so the authors adds support for heap in v0.2 in his custom module, and then support for arguments in v0.3…
Luckily he stopped there, coz he reached the real limit of how much you can shrink your code and instructions in asm… and so his fallow field binary.
My Own Private Binary: An Idiosyncratic Introduction to Linux Kernel Modules: https://www.muppetlabs.com/~breadbox/txt/mopb.html