SlideShare a Scribd company logo
Understanding a Kernel Oops
and a Kernel panic
Linux Kernel Version 4.9.8
Joseph Lu
joseph78715@gmail.com
Page 2
Understanding a Kernel Oops and a Kernel panic
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In user space : Segmentation fault
1
Page 3
Understanding a Kernel Oops and a Kernel panic
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
Oops
– In kernel space : kernel oops.
– In user space : Segmentation fault
2
Page 4
Understanding a Kernel Oops and a Kernel panic
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
• “kernel oops" will kill the process to keep system running, unless “kernel oops" are bad enough to cause
“kernel panic”.
Oops
moderate
do_exit()
– In kernel space : kernel oops.
– In user space : Segmentation fault
3
Page 5
Understanding a Kernel Oops and a Kernel panic
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
• “kernel oops" will kill the process to keep system running, unless “kernel oops" are bad enough to cause
“kernel panic”.
• “kernel panic” means the system decides to stop running immediately.
Oops
Panic
severe
moderate
do_exit()
– In kernel space : kernel oops.
– In user space : Segmentation fault
4
Page 6
Linux kernel oops
, illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
• illegal instruction (SIGILL)
5
Page 7
Linux kernel oops
, illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
• illegal instruction (SIGILL)
6
Page 8
Linux kernel oops
, illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
• bad_mode()
→ die(“Oops - bad mode”, …);
illegal instruction
• illegal instruction (SIGILL)
die()
Oops
7
Page 9
Linux kernel oops
, illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
• bad_mode()
→ die(“Oops - bad mode”, …);
illegal instruction
die()
Oops
Panic()
→ panic(“bad mode”);
• illegal instruction (SIGILL)
8
Page 10
Linux kernel oops
, illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
• bad_mode()
→ die(“Oops - bad mode”, …);
illegal instruction
die()
Oops
Panic()
→ panic(“bad mode”);
• illegal instruction (SIGILL)
9
Page 11
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
10
Page 12
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
illegal instruction cause oops :
1. Call BUG()
arm_notify_die()
Oops
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
11
user_mode
No
Yes
force_sig_info()
Page 13
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
illegal instruction cause oops :
1. Call BUG()
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
2. unrecognised system calls :
• arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …)
12
arm_notify_die()
Oops
user_mode
No
Yes
force_sig_info()
Page 14
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
illegal instruction cause oops :
1. Call BUG()
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
2. unrecognised system calls :
• arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …)
3. undefined cpu instruction :
• do_undefinstr() → arm_notify_die("Oops - undefined
instruction", …)
13
arm_notify_die()
Oops
user_mode
No
Yes
force_sig_info()
Page 15
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
illegal instruction cause oops :
1. Call BUG()
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
2. unrecognised system calls :
• arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …)
3. undefined cpu instruction :
• do_undefinstr() → arm_notify_die("Oops - undefined
instruction", …)
4. unknown data abort : data accesses (load or store)
• alignment faults, translation faults, access bit faults, domain faults,
permission faults.
• E.g. Unaligned memory access, Memory access to reserved areas,
A write to ROM (flash) space
• E.g. baddataabort() → arm_notify_die(“unknown data abort
code”, …)
• E.g. do_DataAbort() → arm_notify_die("", ...);
14
arm_notify_die()
Oops
user_mode
No
Yes
force_sig_info()
Page 16
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
illegal instruction cause oops :
1. Call BUG()
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
instruction translation lookaside buffer (ITLB) and
a data translation lookaside buffer (DTLB) aren't
seeing the same picture.
2. unrecognised system calls :
• arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …)
3. undefined cpu instruction :
• do_undefinstr() → arm_notify_die("Oops - undefined
instruction", …)
4. unknown data abort : data accesses (load or store)
• alignment faults, translation faults, access bit faults, domain faults,
permission faults.
• E.g. Unaligned memory access, Memory access to reserved areas,
A write to ROM (flash) space
• E.g. baddataabort() → arm_notify_die(“unknown data abort
code”, …)
• E.g. do_DataAbort() → arm_notify_die("", ...);
15
arm_notify_die()
Oops
user_mode
No
Yes
force_sig_info()
Page 17
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
illegal instruction cause oops :
1. Call BUG()
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
2. unrecognised system calls :
• arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …)
3. undefined cpu instruction :
• do_undefinstr() → arm_notify_die("Oops - undefined
instruction", …)
4. unknown data abort : data accesses (load or store)
• alignment faults, translation faults, access bit faults, domain faults,
permission faults.
• E.g. Unaligned memory access, Memory access to reserved areas,
A write to ROM (flash) space
• E.g. baddataabort() → arm_notify_die(“unknown data abort
code”, …)
• E.g. do_DataAbort() → arm_notify_die("", ...);
5. prefetch-abort :
• do_PrefetchAbort() → arm_notify_die("",…);
16
arm_notify_die()
Oops
user_mode
No
Yes
force_sig_info()
Page 18
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
arm_notify_die()
Oops
user_mode
No
Yes
force_sig_info()
17
Page 19
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
arm_notify_die()
Oops
user_mode
No
Yes
force_sig_info()
__do_kernel_fault()
18
Page 20
Linux kernel oops
• __do_kernel_fault : oops
• __do_user_fault : SIGENV
19
Page 21
code flow of data abort(1/2)
Macro start
Macro end
20
Page 22
code flow of data abort (2/2)
21
Page 23
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal instruction
illegal instruction cause oops :
1. Call BUG()
2. unrecognised system calls
3. undefined cpu instruction
4. unknown data abort
5. prefetch-abort
__do_kernel_fault()
Oops
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
22
Page 24
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal memory access
do_translation_fault
(E.g Null pointer exception)
__do_kernel_fault()
Oops
illegal instruction
illegal instruction cause oops :
1. Call BUG()
2. unrecognised system calls
3. undefined cpu instruction
4. unknown data abort
5. prefetch-abort
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
23
Page 25
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal memory access
do_translation_fault
(E.g Null pointer exception)
do_bad_area()
Where does it happen?
__do_kernel_fault()
Oops
illegal instruction
illegal instruction cause oops :
1. Call BUG()
2. unrecognised system calls
3. undefined cpu instruction
4. unknown data abort
5. prefetch-abort
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
24
No
fixup the exception
Page 26
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal memory access
do_translation_fault
(E.g Null pointer exception)
In user space
__do_user_fault()
Segmentation fault
do_bad_area()
Where does it happen?
__do_kernel_fault()
Oops
illegal instruction
illegal instruction cause oops :
1. Call BUG()
2. unrecognised system calls
3. undefined cpu instruction
4. unknown data abort
5. prefetch-abort
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
25
No
fixup the exception
Page 27
Linux kernel oops
• illegal instruction (SIGILL), illegal memory access (SIGSEGV)
– In kernel : Cause of an oops.
illegal memory access
do_translation_fault
(E.g Null pointer exception)
In user space
__do_user_fault()
Segmentation fault
do_bad_area()
Where does it happen?
in
Kernel
Space __do_kernel_fault()
Oops
illegal instruction
illegal instruction cause oops :
1. Call BUG()
2. unrecognised system calls
3. undefined cpu instruction
4. unknown data abort
5. prefetch-abort
illegal instruction cause panic:
It handles the impossible case in the interrupt vectors
26
No
fixup the exception
Page 28
…
27
Linux kernel oops
Page 29
Linux Kernel panic
Page 30
Linux Kernel panic
__do_kernel_fault()
Oops
…
28
Page 31
Linux Kernel panic
__do_kernel_fault()
Oops
Oop_end()
…
29
Page 32
Linux Kernel panic
__do_kernel_fault()
Oops
Oop_end()
do_exit()
…
moderate
30
Page 33
Linux Kernel panic
__do_kernel_fault()
Oops
Oop_end()
do_exit()
panic()
…
moderate
severe
31
Page 34
Linux Kernel panic
__do_kernel_fault()
Oops
Oop_end()
In
process context
do_exit()
panic()
…
severe
32
Page 35
Linux Kernel panic
__do_kernel_fault()
Oops
Oop_end()
In Interrupt context
Or
panic_on_oops is set
In
process context
do_exit()
panic()
…
33
Page 36
Linux Kernel panic
__do_kernel_fault()
Oops
Oop_end()
In Interrupt context
Or
panic_on_oops is set
In
process context
do_exit()
panic()
…
34
Page 37
Linux Kernel panic
__do_kernel_fault()
Oops
Oop_end()
In Interrupt context
Or
panic_on_oops is set
In
process context
do_exit()
panic()
… console_verbose()
dump_stack()
panic_smp_self_stop() & smp_send_stop()
shut down other CPUs
panic_timeout ==0
Delay timeout seconds
while(1)
emergency_restart()
No
Yes
35
Page 38
Introduce Crash Dump Mechanism in Linux
1. Kdump : build a separate custom dump-capture kernel for capturing the
kernel core dump
2. Ramoops : log data into persistent the RAM storage
3. Mtdoops : log data into MTD partition
4. Reserved-memory
36
Page 39
Thank you for listening

More Related Content

PDF
U-Boot - An universal bootloader
PDF
Process Address Space: The way to create virtual address (page table) of user...
PDF
Arm device tree and linux device drivers
PPT
U Boot or Universal Bootloader
PPT
U boot porting guide for SoC
PDF
LCU13: An Introduction to ARM Trusted Firmware
PPTX
Linux Initialization Process (1)
U-Boot - An universal bootloader
Process Address Space: The way to create virtual address (page table) of user...
Arm device tree and linux device drivers
U Boot or Universal Bootloader
U boot porting guide for SoC
LCU13: An Introduction to ARM Trusted Firmware
Linux Initialization Process (1)

What's hot (20)

PDF
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
PDF
Build your own embedded linux distributions by yocto project
PDF
LAS16-200: SCMI - System Management and Control Interface
PPTX
Linux Device Tree
PDF
Physical Memory Models.pdf
PPTX
QEMU - Binary Translation
PPTX
Linux Kernel Booting Process (1) - For NLKB
PDF
XPDS16: Keeping coherency on ARM - Julien Grall, ARM
PDF
The Linux Kernel Scheduler (For Beginners) - SFO17-421
PDF
Let's trace Linux Lernel with KGDB @ COSCUP 2021
PPTX
Linux Initialization Process (2)
PPTX
U-Boot presentation 2013
PPTX
Linux Kernel Booting Process (2) - For NLKB
PDF
Kdump and the kernel crash dump analysis
PDF
Linux Kernel - Virtual File System
PPT
Pcie drivers basics
PPTX
Introduction to armv8 aarch64
PDF
Uboot startup sequence
PDF
Physical Memory Management.pdf
PDF
Memory Mapping Implementation (mmap) in Linux Kernel
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
Build your own embedded linux distributions by yocto project
LAS16-200: SCMI - System Management and Control Interface
Linux Device Tree
Physical Memory Models.pdf
QEMU - Binary Translation
Linux Kernel Booting Process (1) - For NLKB
XPDS16: Keeping coherency on ARM - Julien Grall, ARM
The Linux Kernel Scheduler (For Beginners) - SFO17-421
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Linux Initialization Process (2)
U-Boot presentation 2013
Linux Kernel Booting Process (2) - For NLKB
Kdump and the kernel crash dump analysis
Linux Kernel - Virtual File System
Pcie drivers basics
Introduction to armv8 aarch64
Uboot startup sequence
Physical Memory Management.pdf
Memory Mapping Implementation (mmap) in Linux Kernel
Ad

Similar to Understanding a kernel oops and a kernel panic (20)

PDF
[Kiwicon 2011] Post Memory Corruption Memory Analysis
PDF
[HITB Malaysia 2011] Exploit Automation
PPTX
Reverse Engineering the TomTom Runner pt. 1
PDF
Onion and Swiss Cheese: Security Revisited
PDF
Basics_of_Kernel_Panic_Hang_and_ Kdump.pdf
PDF
C-SEC|2016 Session 2 The Security Game : You Failed at the Beginning By Incog...
PPTX
0x003 - Exploiting LOLDrivers - Physical Memory Mayhem
PPT
[DEFCON 16] Bypassing pre-boot authentication passwords by instrumenting the...
PDF
Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009
PPTX
Steelcon 2014 - Process Injection with Python
PPTX
Techno-Fest-15nov16
PPT
[CCC-28c3] Post Memory Corruption Memory Analysis
PDF
[Ruxcon 2011] Post Memory Corruption Memory Analysis
PDF
"egg" - A stealth fine grained code analyzer
PDF
You suck at Memory Analysis
PDF
Talk 160920 @ Cat System Workshop
PDF
AOS Lab 4: If you liked it, then you should have put a “lock” on it
PDF
Rubinius - Improving the Rails ecosystem
PDF
Vale Security Conference - 2011 - 17 - Rodrigo Rubira Branco (BSDaemon)
PDF
Copy Protection Wars: Analyzing Retro and Modern Schemes (RSA 2007)
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[HITB Malaysia 2011] Exploit Automation
Reverse Engineering the TomTom Runner pt. 1
Onion and Swiss Cheese: Security Revisited
Basics_of_Kernel_Panic_Hang_and_ Kdump.pdf
C-SEC|2016 Session 2 The Security Game : You Failed at the Beginning By Incog...
0x003 - Exploiting LOLDrivers - Physical Memory Mayhem
[DEFCON 16] Bypassing pre-boot authentication passwords by instrumenting the...
Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009
Steelcon 2014 - Process Injection with Python
Techno-Fest-15nov16
[CCC-28c3] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis
"egg" - A stealth fine grained code analyzer
You suck at Memory Analysis
Talk 160920 @ Cat System Workshop
AOS Lab 4: If you liked it, then you should have put a “lock” on it
Rubinius - Improving the Rails ecosystem
Vale Security Conference - 2011 - 17 - Rodrigo Rubira Branco (BSDaemon)
Copy Protection Wars: Analyzing Retro and Modern Schemes (RSA 2007)
Ad

Recently uploaded (20)

PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Geodesy 1.pptx...............................................
DOCX
573137875-Attendance-Management-System-original
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPT
Mechanical Engineering MATERIALS Selection
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
additive manufacturing of ss316l using mig welding
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
OOP with Java - Java Introduction (Basics)
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
PPT on Performance Review to get promotions
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Geodesy 1.pptx...............................................
573137875-Attendance-Management-System-original
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
CH1 Production IntroductoryConcepts.pptx
Foundation to blockchain - A guide to Blockchain Tech
Lecture Notes Electrical Wiring System Components
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Mechanical Engineering MATERIALS Selection
Operating System & Kernel Study Guide-1 - converted.pdf
additive manufacturing of ss316l using mig welding
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
bas. eng. economics group 4 presentation 1.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
OOP with Java - Java Introduction (Basics)
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPT on Performance Review to get promotions

Understanding a kernel oops and a kernel panic

  • 1. Understanding a Kernel Oops and a Kernel panic Linux Kernel Version 4.9.8 Joseph Lu joseph78715@gmail.com
  • 2. Page 2 Understanding a Kernel Oops and a Kernel panic • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In user space : Segmentation fault 1
  • 3. Page 3 Understanding a Kernel Oops and a Kernel panic • illegal instruction (SIGILL), illegal memory access (SIGSEGV) Oops – In kernel space : kernel oops. – In user space : Segmentation fault 2
  • 4. Page 4 Understanding a Kernel Oops and a Kernel panic • illegal instruction (SIGILL), illegal memory access (SIGSEGV) • “kernel oops" will kill the process to keep system running, unless “kernel oops" are bad enough to cause “kernel panic”. Oops moderate do_exit() – In kernel space : kernel oops. – In user space : Segmentation fault 3
  • 5. Page 5 Understanding a Kernel Oops and a Kernel panic • illegal instruction (SIGILL), illegal memory access (SIGSEGV) • “kernel oops" will kill the process to keep system running, unless “kernel oops" are bad enough to cause “kernel panic”. • “kernel panic” means the system decides to stop running immediately. Oops Panic severe moderate do_exit() – In kernel space : kernel oops. – In user space : Segmentation fault 4
  • 6. Page 6 Linux kernel oops , illegal memory access (SIGSEGV) – In kernel : Cause of an oops. • illegal instruction (SIGILL) 5
  • 7. Page 7 Linux kernel oops , illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction • illegal instruction (SIGILL) 6
  • 8. Page 8 Linux kernel oops , illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction cause panic: It handles the impossible case in the interrupt vectors • bad_mode() → die(“Oops - bad mode”, …); illegal instruction • illegal instruction (SIGILL) die() Oops 7
  • 9. Page 9 Linux kernel oops , illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction cause panic: It handles the impossible case in the interrupt vectors • bad_mode() → die(“Oops - bad mode”, …); illegal instruction die() Oops Panic() → panic(“bad mode”); • illegal instruction (SIGILL) 8
  • 10. Page 10 Linux kernel oops , illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction cause panic: It handles the impossible case in the interrupt vectors • bad_mode() → die(“Oops - bad mode”, …); illegal instruction die() Oops Panic() → panic(“bad mode”); • illegal instruction (SIGILL) 9
  • 11. Page 11 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction illegal instruction cause panic: It handles the impossible case in the interrupt vectors 10
  • 12. Page 12 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction illegal instruction cause oops : 1. Call BUG() arm_notify_die() Oops illegal instruction cause panic: It handles the impossible case in the interrupt vectors 11 user_mode No Yes force_sig_info()
  • 13. Page 13 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction illegal instruction cause oops : 1. Call BUG() illegal instruction cause panic: It handles the impossible case in the interrupt vectors 2. unrecognised system calls : • arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …) 12 arm_notify_die() Oops user_mode No Yes force_sig_info()
  • 14. Page 14 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction illegal instruction cause oops : 1. Call BUG() illegal instruction cause panic: It handles the impossible case in the interrupt vectors 2. unrecognised system calls : • arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …) 3. undefined cpu instruction : • do_undefinstr() → arm_notify_die("Oops - undefined instruction", …) 13 arm_notify_die() Oops user_mode No Yes force_sig_info()
  • 15. Page 15 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction illegal instruction cause oops : 1. Call BUG() illegal instruction cause panic: It handles the impossible case in the interrupt vectors 2. unrecognised system calls : • arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …) 3. undefined cpu instruction : • do_undefinstr() → arm_notify_die("Oops - undefined instruction", …) 4. unknown data abort : data accesses (load or store) • alignment faults, translation faults, access bit faults, domain faults, permission faults. • E.g. Unaligned memory access, Memory access to reserved areas, A write to ROM (flash) space • E.g. baddataabort() → arm_notify_die(“unknown data abort code”, …) • E.g. do_DataAbort() → arm_notify_die("", ...); 14 arm_notify_die() Oops user_mode No Yes force_sig_info()
  • 16. Page 16 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction illegal instruction cause oops : 1. Call BUG() illegal instruction cause panic: It handles the impossible case in the interrupt vectors instruction translation lookaside buffer (ITLB) and a data translation lookaside buffer (DTLB) aren't seeing the same picture. 2. unrecognised system calls : • arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …) 3. undefined cpu instruction : • do_undefinstr() → arm_notify_die("Oops - undefined instruction", …) 4. unknown data abort : data accesses (load or store) • alignment faults, translation faults, access bit faults, domain faults, permission faults. • E.g. Unaligned memory access, Memory access to reserved areas, A write to ROM (flash) space • E.g. baddataabort() → arm_notify_die(“unknown data abort code”, …) • E.g. do_DataAbort() → arm_notify_die("", ...); 15 arm_notify_die() Oops user_mode No Yes force_sig_info()
  • 17. Page 17 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction illegal instruction cause oops : 1. Call BUG() illegal instruction cause panic: It handles the impossible case in the interrupt vectors 2. unrecognised system calls : • arm_syscall() → arm_notify_die("Oops - bad syscall(2)", …) 3. undefined cpu instruction : • do_undefinstr() → arm_notify_die("Oops - undefined instruction", …) 4. unknown data abort : data accesses (load or store) • alignment faults, translation faults, access bit faults, domain faults, permission faults. • E.g. Unaligned memory access, Memory access to reserved areas, A write to ROM (flash) space • E.g. baddataabort() → arm_notify_die(“unknown data abort code”, …) • E.g. do_DataAbort() → arm_notify_die("", ...); 5. prefetch-abort : • do_PrefetchAbort() → arm_notify_die("",…); 16 arm_notify_die() Oops user_mode No Yes force_sig_info()
  • 18. Page 18 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction arm_notify_die() Oops user_mode No Yes force_sig_info() 17
  • 19. Page 19 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction arm_notify_die() Oops user_mode No Yes force_sig_info() __do_kernel_fault() 18
  • 20. Page 20 Linux kernel oops • __do_kernel_fault : oops • __do_user_fault : SIGENV 19
  • 21. Page 21 code flow of data abort(1/2) Macro start Macro end 20
  • 22. Page 22 code flow of data abort (2/2) 21
  • 23. Page 23 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal instruction illegal instruction cause oops : 1. Call BUG() 2. unrecognised system calls 3. undefined cpu instruction 4. unknown data abort 5. prefetch-abort __do_kernel_fault() Oops illegal instruction cause panic: It handles the impossible case in the interrupt vectors 22
  • 24. Page 24 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal memory access do_translation_fault (E.g Null pointer exception) __do_kernel_fault() Oops illegal instruction illegal instruction cause oops : 1. Call BUG() 2. unrecognised system calls 3. undefined cpu instruction 4. unknown data abort 5. prefetch-abort illegal instruction cause panic: It handles the impossible case in the interrupt vectors 23
  • 25. Page 25 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal memory access do_translation_fault (E.g Null pointer exception) do_bad_area() Where does it happen? __do_kernel_fault() Oops illegal instruction illegal instruction cause oops : 1. Call BUG() 2. unrecognised system calls 3. undefined cpu instruction 4. unknown data abort 5. prefetch-abort illegal instruction cause panic: It handles the impossible case in the interrupt vectors 24 No fixup the exception
  • 26. Page 26 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal memory access do_translation_fault (E.g Null pointer exception) In user space __do_user_fault() Segmentation fault do_bad_area() Where does it happen? __do_kernel_fault() Oops illegal instruction illegal instruction cause oops : 1. Call BUG() 2. unrecognised system calls 3. undefined cpu instruction 4. unknown data abort 5. prefetch-abort illegal instruction cause panic: It handles the impossible case in the interrupt vectors 25 No fixup the exception
  • 27. Page 27 Linux kernel oops • illegal instruction (SIGILL), illegal memory access (SIGSEGV) – In kernel : Cause of an oops. illegal memory access do_translation_fault (E.g Null pointer exception) In user space __do_user_fault() Segmentation fault do_bad_area() Where does it happen? in Kernel Space __do_kernel_fault() Oops illegal instruction illegal instruction cause oops : 1. Call BUG() 2. unrecognised system calls 3. undefined cpu instruction 4. unknown data abort 5. prefetch-abort illegal instruction cause panic: It handles the impossible case in the interrupt vectors 26 No fixup the exception
  • 30. Page 30 Linux Kernel panic __do_kernel_fault() Oops … 28
  • 31. Page 31 Linux Kernel panic __do_kernel_fault() Oops Oop_end() … 29
  • 32. Page 32 Linux Kernel panic __do_kernel_fault() Oops Oop_end() do_exit() … moderate 30
  • 33. Page 33 Linux Kernel panic __do_kernel_fault() Oops Oop_end() do_exit() panic() … moderate severe 31
  • 34. Page 34 Linux Kernel panic __do_kernel_fault() Oops Oop_end() In process context do_exit() panic() … severe 32
  • 35. Page 35 Linux Kernel panic __do_kernel_fault() Oops Oop_end() In Interrupt context Or panic_on_oops is set In process context do_exit() panic() … 33
  • 36. Page 36 Linux Kernel panic __do_kernel_fault() Oops Oop_end() In Interrupt context Or panic_on_oops is set In process context do_exit() panic() … 34
  • 37. Page 37 Linux Kernel panic __do_kernel_fault() Oops Oop_end() In Interrupt context Or panic_on_oops is set In process context do_exit() panic() … console_verbose() dump_stack() panic_smp_self_stop() & smp_send_stop() shut down other CPUs panic_timeout ==0 Delay timeout seconds while(1) emergency_restart() No Yes 35
  • 38. Page 38 Introduce Crash Dump Mechanism in Linux 1. Kdump : build a separate custom dump-capture kernel for capturing the kernel core dump 2. Ramoops : log data into persistent the RAM storage 3. Mtdoops : log data into MTD partition 4. Reserved-memory 36
  • 39. Page 39 Thank you for listening