x86,aarch64,arm

Ciro Santilli 31fa73327b Inird hardcoded, TODO add run option 7 سال پیش
buildroot @ 8ce27bb9fe 12abf43b78 Attempt migration to Buildroot 2017.08 + kernel 4.12. 7 سال پیش
buildroot_patches 5ad68edd00 Linux 4.12, buildroot 2017.08, Ubuntu 17.10. 7 سال پیش
global_patch_dir 5393299433 Make global_patch_dir empty 7 سال پیش
hello_host bb10d0e914 Improve hello_host readme 7 سال پیش
kernel_module dc495f9334 Linux v4.15 7 سال پیش
linux @ 225d02dc63 dc495f9334 Linux v4.15 7 سال پیش
qemu @ 09fa182a4e 9ec43c4e88 lkmc_platform_device read example 7 سال پیش
rootfs_overlay c771b40913 rand_check_poweroff.sh + random stuff 7 سال پیش
.gitignore 8ddefa940e gem5 7 سال پیش
.gitmodules 23eddfb2a2 Shallow clone to save clone time and disk space 7 سال پیش
.travis.yml 2f82f78589 build without sdl for travis 7 سال پیش
CONTRIBUTING.md c771b40913 rand_check_poweroff.sh + random stuff 7 سال پیش
LICENSE.txt 36cd620dd2 license 8 سال پیش
README.md dc495f9334 Linux v4.15 7 سال پیش
S99 4727fadcc8 procfs example, S99 symlink 7 سال پیش
bibliography.md 6b0f89a8b4 aosp 7 سال پیش
build f5a0111c3e Fix kernel_config_fragment that was getting ignored after gem5 addition 7 سال پیش
build-gem5 6ddbec9c99 Automate failed gem5 x86 attempt 7 سال پیش
buildroot_config_fragment 31fa73327b Inird hardcoded, TODO add run option 7 سال پیش
buildroot_config_fragment_x11 fa5c64a0b0 Make X11 optional 7 سال پیش
buildroot_override 9133fe023c qemu and linux as submodlues, S98 vs S99, readme benefits of Ctrl + C 7 سال پیش
busybox_config_fragment 8d668d6ed3 Use busybox devmem 7 سال پیش
configure cf063ad8d2 Bail out of shallow cloning if it fails, and do full clone instead 7 سال پیش
configure-gem5 8ddefa940e gem5 7 سال پیش
count-boot-instructions.md 6c51ecaf7b split build and run scripts due to option conflicts 7 سال پیش
device-tree.md 2ff3648e8f device tree info 7 سال پیش
ftrace.md f80957cc40 frace docs an mmap minor improvements 7 سال پیش
gdb-step-debugging.md c052a83205 nokaslr, thanks to @dakami at close #12 7 سال پیش
gdbserver.md 027bca7927 Update gdbserver.md 7 سال پیش
gem5.md 3a34f9f2a5 gem5 kernel command line arguments 7 سال پیش
getting-started.md 03f418b53e document how to clean the build in getting started 7 سال پیش
init.md 920afba40a Disable networking on image with command line option ./build -p -n 7 سال پیش
kernel_config_arm-gem5 6ddbec9c99 Automate failed gem5 x86 attempt 7 سال پیش
kernel_config_fragment 31fa73327b Inird hardcoded, TODO add run option 7 سال پیش
kernel_config_x86_64-gem5 6ddbec9c99 Automate failed gem5 x86 attempt 7 سال پیش
kgdb.md 6c51ecaf7b split build and run scripts due to option conflicts 7 سال پیش
kmod.md fa0a7e150d Less converstaion 7 سال پیش
maintainers.md 7bd1508c98 Improve maintainer guideline on Linux updates 7 سال پیش
modprobe.md fa0a7e150d Less converstaion 7 سال پیش
other-architectures.md 6c51ecaf7b split build and run scripts due to option conflicts 7 سال پیش
qemu-user-mode.md 21da1e9b76 QEMU user mode fun 7 سال پیش
qemumonitor a8e11e6de9 qemumonitor helper, extra_append from CLI, pci_rescan.sh 7 سال پیش
record-and-replay.md a070486855 Mention rr on record and replay 7 سال پیش
rootfs_post_build_script 920afba40a Disable networking on image with command line option ./build -p -n 7 سال پیش
run 31fa73327b Inird hardcoded, TODO add run option 7 سال پیش
run-on-host.md c7bbc6029a Merge branch 'master' of github.com:cirosantilli/linux-kernel-module-cheat 7 سال پیش
rungdb c052a83205 nokaslr, thanks to @dakami at close #12 7 سال پیش
rungdb-user 52c3ee15dc Userland without gdbserver 7 سال پیش
rungdbserver b89ba9b799 gdbserver shared library 7 سال پیش
rungem5 3a34f9f2a5 gem5 kernel command line arguments 7 سال پیش
rungem5-shell 8ddefa940e gem5 7 سال پیش
screenshot.png 53c1b61879 screenshot, vm to description, qemu debug non intrusive 8 سال پیش
user_table b2459d07f5 Add a non-root user user0 password "a" 7 سال پیش
x11.md 6c51ecaf7b split build and run scripts due to option conflicts 7 سال پیش
x11.png 01f6ca24e5 x11 screenshot and link to insmod C 7 سال پیش

README.md

Linux Kernel Module Cheat

Run one command, get a QEMU Buildroot BusyBox virtual machine built from source with several minimal Linux kernel 4.15 module development example tutorials with GDB and KGDB step debugging and minimal educational hardware models. Limited GEM5 full system support. "Tested" in x86, ARM and MIPS guests, Ubuntu 17.10 host.

Reserve 12Gb of disk and run:

git clone https://github.com/cirosantilli/linux-kernel-module-cheat
cd linux-kernel-module-cheat
./configure && ./build && ./run

The first build will take a while (GCC, Linux kernel), e.g.:

  • 2 hours on a mid end 2012 laptop
  • 30 minutes on a high end 2017 desktop

If you don't want to wait, you could also try to compile the examples and run them on your host computer as explained on the "Run on host" section, but as explained on that section, that is dangerous, limited, and will likely not work.

After QEMU opens up, you can start playing with the kernel modules:

root
insmod /hello.ko
insmod /hello2.ko
rmmod hello
rmmod hello2

This should print to the screen:

hello init
hello2 init
hello cleanup
hello2 cleanup

which are printk messages from init and cleanup methods of those modules.

All available modules can be found in the kernel_module directory.

See the getting started section for further details.

  1. Getting started
  2. Action
    1. Step debugging
      1. GDB step debugging
      2. KGDB
      3. gdbserver
    2. Other architectures
    3. modprobe
    4. X11
    5. Count boot instructions
    6. GEM5
    7. ftrace
    8. QEMU user mode
  3. Failed action
    1. Record and replay
  4. Insane action
    1. Run on host
    2. Hello host
  5. Conversation
    1. kmod
    2. Device tree
    3. Maintainers
    4. Bibliography