Forcing a Kernel Panic

Ever Wondered how to panic a Linux Kernel? It is really easy. Here is your source code:

Quote from panic.c:
#define __NO_VERSION__
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/module.h>

int init_module(void)
{
    panic(" insert lame excuse here");
    return 0;
}

Then compile it with gcc -I/usr/src/linux/include -D__KERNEL__ -DMODULE -o panic.o -c panic.c.
Now just run insmod panic.o.

Okay, So I was a little bored tonight.

One Response to “Forcing a Kernel Panic”

  1. benito says:

    This code does not compile on 2.6.23 and 2.6.24.

Leave a Reply