How to get source line numbers with crash utility in kernel crash debugging

492 Views Asked by At

I am using this tutorial to analyze the dump file generated on kernel crash.

The dump file is successfully generated and I am able to access it using crash utility.

  /* Code for the kernel module */
  #include<linux/module.h>
  #include<linux/kernel.h>
  #include<linux/types.h>
   
  static s32 __init testmoduleinit(void)
  {
          s8 *ptr = NULL;
          pr_info("%s:module loaded.\n", __func__);
          *ptr = 100;     // generate oops
          return 0;
  }
  static void __exit testmoduledeinit(void)
  {
          pr_info("%s:module un-loaded.\n", __func__);
  }
  module_init(testmoduleinit);
  module_exit(testmoduledeinit);
  MODULE_LICENSE("GPL");

The crash logs(backtrace output) are as follows.

crash> bt
PID: 3401   TASK: ffff9d6928b3af00  CPU: 2   COMMAND: "insmod"
 #0 [ffffb2bd846478c8] machine_kexec at ffffffff9246fe83
 #1 [ffffb2bd84647928] __crash_kexec at ffffffff9255a152
 #2 [ffffb2bd846479f8] crash_kexec at ffffffff9255aff1
 #3 [ffffb2bd84647a18] oops_end at ffffffff9243633d
 #4 [ffffb2bd84647a40] no_context at ffffffff924803c9
 #5 [ffffb2bd84647ab0] __bad_area_nosemaphore at ffffffff924807c0
 #6 [ffffb2bd84647af8] bad_area_nosemaphore at ffffffff92480976
 #7 [ffffb2bd84647b08] __do_page_fault at ffffffff9248133d
 #8 [ffffb2bd84647b70] do_page_fault at ffffffff9248162c
 #9 [ffffb2bd84647ba0] page_fault at ffffffff93001284
    [exception RIP: _MODULE_INIT_START_gencrash+44]
    RIP: ffffffffc062b02c  RSP: ffffb2bd84647c58  RFLAGS: 00010282
    RAX: 0000000000000000  RBX: 0000000000000000  RCX: 0000000000000000
    RDX: 0000000000000000  RSI: ffff9d6935c9c8c8  RDI: ffff9d6935c9c8c8
    RBP: ffffb2bd84647c60   R8: 0000000000000722   R9: 0000000000000004
    R10: ffff9d693219f730  R11: 0000000000000001  R12: ffffffffc062b000
    R13: ffff9d693219f730  R14: ffffb2bd84647e68  R15: ffffffffc0628000
    ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
#10 [ffffb2bd84647c68] do_one_initcall at ffffffff9240389a
#11 [ffffb2bd84647ce0] do_init_module at ffffffff92edd493
#12 [ffffb2bd84647d08] load_module at ffffffff92556e1b
#13 [ffffb2bd84647e48] __do_sys_finit_module at ffffffff9255773c
#14 [ffffb2bd84647f20] __x64_sys_finit_module at ffffffff9255777a
#15 [ffffb2bd84647f30] do_syscall_64 at ffffffff92405207
#16 [ffffb2bd84647f50] entry_SYSCALL_64_after_hwframe at ffffffff9300008c
    RIP: 00007f7f2613c539  RSP: 00007fff5ba4f6a8  RFLAGS: 00000246
    RAX: ffffffffffffffda  RBX: 000056442b32d7c0  RCX: 00007f7f2613c539
    RDX: 0000000000000000  RSI: 0000564429214d2e  RDI: 0000000000000003
    RBP: 0000564429214d2e   R8: 0000000000000000   R9: 00007f7f2640f000
    R10: 0000000000000003  R11: 0000000000000246  R12: 0000000000000000
    R13: 000056442b32d760  R14: 0000000000000000  R15: 0000000000000000
    ORIG_RAX: 0000000000000139  CS: 0033  SS: 002b

The "bt" logs show that page fault is generated at address ffffffffc062b02c.

But when I do

crash> mod -s test_module ./test_module.o
crash> sym ffffffffc062b02c

I don't see the line number in source code which is generating crash.

Is there any way to get the line number from the kernel module which is causing the oops condition.

0

There are 0 best solutions below