0

I have a sample driver with intentional null pointer access. When I load driver, my ubunut 18.04 with 4.15.0-55-generic kernel is not showing up any stack trace in dmesg or dmesg -w or in /var/log/kern.log file.

I have other Ubuntu system with the same config, where it is not hanging up and it is showing proper kernel oops in dmesg or /var/log/kern.log.

I want to fix the problem exactly what is causing and what setting is making kernel to hang up forever.

I tried reinstallation of linuxcrashdump kdump and kexec-tools. But still problem is there.

Later, I compare with the working Ubuntu and non working Ubuntu. In working system, there is no Linux-crashdump, kdump-tools and kexec-tools.

Vijay Kalyanam
  • 327
  • 1
  • 3
  • 15

2 Answers2

0

Maybe in the kernel the flag CONFIG_DEBUG_KERNEL is not turned on. But anyhow it is not likely a problem of kernel itself.

I used printk a lot in driver development. It shows information normally on console, when you load the driver. I recommend to put a printk at init of your driver and before and after critical lines. Hence, you will see how far code is executed.

printk(KERN_ERR "Reached init of my driver");
...
printk(KERN_ERR "Reached open device");
...

With KERN_xxx you can set severity. When you start, choose a high one. It has to be set. Apart from that it works like printf.

C.Lechner
  • 19
  • 5
  • When Kernel figured out OOPS, it prints stack trace in the kernel logs. This is something not related to printk or pr_info or pr_err in the driver source code. This part of work is happening in my Ubuntu system. – Vijay Kalyanam Aug 13 '19 at 07:35
0

Maybe in the kernel the flag CONFIG_DEBUG_INFO is not truned on or syslogd didn't running.In my ubuntu system is work fine

  1 #include <linux/kernel.h>                                                                                                                                                
  2 #include <linux/module.h>
  3 #include <linux/init.h>
  4 
  5 static void create_oops() {
  6         *(int *)0 = 0;
  7 }
  8 
  9 static int __init my_oops_init(void) {
 10                 printk("oops from the module\n");
 11                         create_oops();
 12                                return (0);
 13 }
 14 static void __exit my_oops_exit(void) {
 15                 printk("Goodbye world\n");
 16 }
 17 
 18 module_init(my_oops_init);
 19 module_exit(my_oops_exit);
~                              

Makefile

  1 obj-m   := oops.o                                                                                                                                                        
  2 KDIR    := /lib/modules/$(shell uname -r)/build
  3 PWD     := $(shell pwd)
  4 SYM=$(PWD)
  5 KBUILD_CFLAGS   += -Wno-error=strict-prototypes
  6 all:
  7         $(MAKE) -k -C $(KDIR) SUBDIRS=$(PWD)  modules

⋊> uname -a 
Linux zjp 4.18.0-25-generic #26-Ubuntu SMP Mon Jun 24 09:32:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

4402 Aug 13 19:56:01 zjp kernel: [117908.066176] oops: loading out-of-tree module taints kernel.                                                                            
4403 Aug 13 19:56:01 zjp kernel: [117908.066180] oops: module license 'unspecified' taints kernel.                                                                          
4404 Aug 13 19:56:01 zjp kernel: [117908.066181] Disabling lock debugging due to kernel taint                                                                               
4405 Aug 13 19:56:01 zjp kernel: [117908.066242] oops: module verification failed: signature and/or required key missing - tainting kernel                                  
4406 Aug 13 19:56:01 zjp kernel: [117908.066491] oops from the module
4407 Aug 13 19:56:01 zjp kernel: [117908.066498] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000                                                  
4408 Aug 13 19:56:01 zjp kernel: [117908.066503] PGD 0 P4D 0
Joeys
  • 21
  • 4