diff options
Diffstat (limited to 'src/non_critical/kern_panic')
| -rw-r--r-- | src/non_critical/kern_panic/Makefile | 13 | ||||
| -rw-r--r-- | src/non_critical/kern_panic/linux_kmod.c | 22 | ||||
| -rw-r--r-- | src/non_critical/kern_panic/linux_sysrq.c | 10 | ||||
| -rw-r--r-- | src/non_critical/kern_panic/linux_sysrq.c | 1 |
4 files changed, 46 insertions, 0 deletions
diff --git a/src/non_critical/kern_panic/Makefile b/src/non_critical/kern_panic/Makefile new file mode 100644 index 0000000..9b4a328 --- /dev/null +++ b/src/non_critical/kern_panic/Makefile @@ -0,0 +1,13 @@ +obj-m += linux_kmod.o + +KDIR ?= /lib/modules/$(shell uname -r)/build +PWD := $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) + +all: + $(MAKE) -C $(KDIR) M=$(PWD) modules + +clean: + $(MAKE) -C $(KDIR) M=$(PWD) clean + +.PHONY: all clean + diff --git a/src/non_critical/kern_panic/linux_kmod.c b/src/non_critical/kern_panic/linux_kmod.c new file mode 100644 index 0000000..ae0494d --- /dev/null +++ b/src/non_critical/kern_panic/linux_kmod.c @@ -0,0 +1,22 @@ +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/delay.h> + +static int __init cr_init(void) { + printk(KERN_INFO "Crash module loaded, your kernel will broke in \n"); + for(int i = 0; i < 10; i++) { + ssleep(1); + printk(KERN_INFO "%d\n", i); + } + *(int*)0 = 0xdeadbeef; + return 0; +} + +static void __exit cr_exit(void) { + printk(KERN_INFO "Crash module unloaded((((\n"); + printk(KERN_INFO "It's not a bug, it's a feature. Were just wanted to write dump to 0 addr.\n"); +} + +module_init(cr_init); +module_exit(cr_exit); +MODULE_LICENSE("BSD-2-CLAUSE");
\ No newline at end of file diff --git a/src/non_critical/kern_panic/linux_sysrq.c b/src/non_critical/kern_panic/linux_sysrq.c new file mode 100644 index 0000000..b609043 --- /dev/null +++ b/src/non_critical/kern_panic/linux_sysrq.c @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <stdlib.h> + +void linux_sysrq_start() { + system("echo 1 > /proc/sys/kernel/sysrq"); +} + +void linux_sysrq_panic() { + system("echo 1 > /proc/sysrq-trigger"); +}
\ No newline at end of file diff --git a/src/non_critical/kern_panic/linux_sysrq.c b/src/non_critical/kern_panic/linux_sysrq.c new file mode 100644 index 0000000..c85f12c --- /dev/null +++ b/src/non_critical/kern_panic/linux_sysrq.c @@ -0,0 +1 @@ +#include <
\ No newline at end of file |
