From eb6167ae639c34ae02e2305a6b6706c463310e47 Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Tue, 17 Dec 2024 20:56:26 +0200 Subject: [PATCH] add uncaught bug for debugging in the wild --- Makefile | 6 +++++- hello1.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 14cbe97..413e385 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,17 @@ ifneq ($(KERNELRELEASE),) # kbuild part of makefile obj-m := hello1.o hello2.o -ccflags-y := -I$(obj)/inc +ccflags-y := -I$(obj)/inc -g else # normal makefile KDIR ?= /lib/modules/`uname -r`/build default: $(MAKE) -C $(KDIR) M=$$PWD + cp hello1.ko hello1.ko.unstripped + $(CROSS_COMPILE)strip -g hello1.ko + clean: $(MAKE) -C $(KDIR) M=$$PWD clean + endif diff --git a/hello1.c b/hello1.c index 8d2487f..9008558 100644 --- a/hello1.c +++ b/hello1.c @@ -45,6 +45,7 @@ struct TimingList { }; static struct TimingList *tl_head; +static unsigned int bug_generator; static struct TimingList *write_first_node(void) { @@ -59,8 +60,12 @@ static struct TimingList *insert_next_node(struct TimingList *tail) struct TimingList *new_tl_node = kmalloc(sizeof(struct TimingList), GFP_KERNEL); - tail->next = new_tl_node; - new_tl_node->next = NULL; + if (bug_generator == 2) { + new_tl_node = NULL; + } else { + tail->next = new_tl_node; + new_tl_node->next = NULL; + } return new_tl_node; } @@ -106,6 +111,8 @@ void print_hello(int msg_count) struct TimingList *current_tail = tl_head; for (i = 0; i < msg_count; i++) { + bug_generator = i; + current_tail = add_new_node(current_tail); current_tail->t_before = ktime_get();