Re: Linux kernel module to cause OOPS on demand?

Mike (mike@oxlug.org)
Sun, 15 Aug 1999 18:56:50 +0100 (BST)


On Thu, 12 Aug 1999, Brian Hall wrote:

> I need a way to cause the kernel to oops on demand. This needs to work with an
> arbitrary kernel version, and it would be preferable as a module. I recall that
> awhile back (possibly running 2.0.x), there was a joystick driver revision that
> had an action (unintended) like this. I suppose I could just modify the
> joystick driver to deference a null pointer when a button is pressed, but I
> thought I'd ask if anyone had built a module/patch for this purpose already.
>
I used to have one. I might even still have the source somewhere, but I can't
find it quickly.

Its fairly easy - init_module registers a file in /proc. Reading that
file deferences a null pointer.

So you have (from memory, completely untested):

#include <linux/proc_fs.h>

int oops(/* can't remember the args*/) {
/* Force an oops */
foo = *(int *)0;
}

struct proc_dir_entry oopser={
0,4,"Oops",00200,1,0,0,0,NULL,oops,
};

int init_module(void) {
proc_register_dynamic(&proc_sys,&oopser);
}
void cleanup_module(void) {
proc_unregister(&proc_sys,oopser.inode);
}

-- 
Mike <rickettm@ox.compsoc.net>

Chemist who falls in acid will be tripping for weeks.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/