Forcibly Trigger a Kernel Panic on Linux

by Phil Dufault on July 17, 2008 · 1 comment

in CentOS,Featured,Gentoo,Linux,Redhat,Ubuntu

This might sound strange, as people usually want to fix or prevent their computer from kernel panicing, but I was trying to test / create a method of logging kernel panic messages to a remote logging server. All of the existing tutorials I found on the net were for Linux kernel version 2.4, or were incomplete.

My method involves creating a Linux kernel module, that when it’s inserted, causes the panic.

Here’s my my tarball: (includes the module source and a makefile)
kernelpanic.tgz

Here’s how to compile it: (you’ll need the the build kernel sources installed at /usr/src/linux of your current running kernel version)
make -C /lib/modules/$(uname -r)/build M=$(pwd)

After it’s done compiling: (WARNING, THIS WILL CRASH THE MACHINE, and you need to be root)
insmod panic.ko

To recover from the crash, just reboot your computer.

Let me know if this is any good in the comments, and any improvements I can make!

Should I obfuscate the source code at all to prevent misuse of this? Since you need root access to insert a kernel module, and anyone with root access can halt the machine, I find the ramifications of releasing this information moot. Comment!

Here’s where I found a quick howto on creating a Linux 2.6 kernel module:
http://tldp.org/LDP/lkmpg/2.6/html/x279.html

{ 1 comment… read it below or add one }

Alex August 18, 2010 at 8:37 am

Thanks it works perfectly

Leave a Comment

Previous post:

Next post: