Internal error: Oops [#1]: reading a kernel Oops on the console

Kernel code did something the CPU refused, the kernel caught it and printed a report. Unlike a panic, an Oops does not have to stop the system: the kernel kills the process that was running and carries on, damaged.

The line

[   42.101337] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
[   42.118733] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
[   42.125034] Modules linked in: my_driver(O)
[   42.129243] CPU: 2 UID: 0 PID: 381 Comm: insmod Tainted: G           O       6.12.0 #1
[   42.143390] pc : my_probe+0x24/0x80 [my_driver]
[   42.147932] lr : platform_probe+0x68/0xd8
[   42.201771] ---[ end trace 0000000000000000 ]---

An arm64 report, shortened; the driver name and addresses are illustrative. On x86 the same line reads Oops: 0002 [#1] PREEMPT SMP.

What it means

On arm64 and 32-bit Arm the line is Internal error: <what>: <code> [#n], where the code is the fault status the CPU reported. On x86 it is Oops: <code> [#n], where the four hex digits are the page fault error code. The number in [#n] counts Oopses since boot. Only [#1] is fully trustworthy: once the kernel has oopsed it is marked tainted, and later reports may be consequences of the first.

The lines that matter most are the pc line on Arm or the RIP line on x86, which name the function, the offset into it and, in brackets, the module it belongs to, and the call trace under it. If panic_on_oops is set, or the Oops happened in an interrupt, a Kernel panic - not syncing: Fatal exception line follows and the system stops.

Common causes

A NULL or invalid pointer in a driver

A frequent report on a board under development. A probe function uses a pointer that a failed lookup left NULL, or a callback runs after the data it uses was released. The Oops line is then preceded by Unable to handle kernel NULL pointer dereference or paging request, and the pc line points into the driver.

Source: Linux kernel docs: Bug hunting (reading an Oops, gdb, decode_stacktrace.sh)

A BUG() or BUG_ON() assertion

Kernel code checks its own assumptions with BUG_ON(). When one fails, the report starts with kernel BUG at <file>:<line>! and, on arm64, continues as Internal error: Oops - BUG. The file and line are given directly, so this is the easiest kind to locate: the question becomes why the condition there was false.

Sources: Linux kernel docs: Bug hunting (reading an Oops, gdb, decode_stacktrace.sh) · Linux v6.12: arch/arm64/kernel/traps.c

Memory corruption that surfaces somewhere else

A use after free or a write past the end of a buffer damages an object that unrelated code trips over later. The sign is an Oops in well-tested core code (the slab allocator, list handling, the scheduler) with your module loaded. KASAN, built into a debug kernel, reports the bad access at the moment it happens, with the allocation and free call stacks.

Source: Linux kernel docs: Kernel Address Sanitizer (KASAN)

An out-of-tree or proprietary module

The Tainted: field on the CPU: line records what has happened to this kernel. O means an out-of-tree module was loaded, P a proprietary one, D that it has already oopsed once and W that it has already warned. A module built against different kernel headers than the running kernel is a frequent source of Oopses in otherwise sound code.

Source: Linux kernel docs: Tainted kernels

What to check first

  1. Find the first report, the one marked [#1], and ignore the later ones until it is understood.
  2. Read the line above the Oops line. An Unable to handle kernel line gives the address that was accessed, a kernel BUG at line gives a file and line number.
  3. Read the pc or RIP line: it has the form function+offset/size [module]. That function is where the fault was taken; the lr line and the call trace say how the kernel got there.
  4. Turn the offset into a source line. With a vmlinux built with debug info, gdb vmlinux and l *my_probe+0x24 list it, and piping the whole report through scripts/decode_stacktrace.sh vmlinux annotates every frame.
  5. Check the Tainted: flags and Modules linked in:. If the function is in your module, start there; if it is in core code and an out-of-tree module is loaded, suspect the module first.
  6. If the location makes no sense, rebuild with KASAN enabled and reproduce: memory corruption is reported where it is caused, not where it hurts.

In NeuroTerm

On a serial tab with pattern markers on, NeuroTerm recognises this line as “Board crash: Linux Oops”. A coding agent connected through Terminal Use gets that name in its list of tabs and among the markers of the output it reads, with a cursor for reading the lines around it. Setup is in Terminal Use (MCP).