Skip to content

Instantly share code, notes, and snippets.

@tbarabosch
Last active September 10, 2019 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbarabosch/bb25c3497bec2413724b010a360e82a3 to your computer and use it in GitHub Desktop.
Save tbarabosch/bb25c3497bec2413724b010a360e82a3 to your computer and use it in GitHub Desktop.
Provoke FreeBSD kernel panic
KMOD = panic
SRCS = panic.c
.include <bsd.kmod.mk>
#include <sys/param.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>
static int
panic_modevent(module_t mod __unused, int event, void* arg __unused){
int error = 0;
switch(event){
case MOD_LOAD:
uprintf("Goodbye!\n");
memset(NULL, 0x42, 1000);
break;
default:
error = EOPNOTSUPP;
break;
}
return (error);
}
static moduledata_t panic_mod = {
"panic",
panic_modevent,
NULL
};
DECLARE_MODULE(panic, panic_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
@tbarabosch
Copy link
Author

Load with kldload(8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment