Read Your First Kernel Oops Message Line by Line
Decode a real x86-64 NULL pointer oops from a module, one line at a time: fault address, error code, RIP, registers, call trace and taint flags.

The first oops looks like a wall of hexadecimal, and most of it can be ignored. A handful of lines carry the diagnosis: what kind of fault, at which address, in which function, called by which path, and on a kernel in what condition. This post takes one complete oops from a small module on Linux 6.12 x86-64 and reads it top to bottom, saying what each group of lines means and what to do with it. The code that caused it is shown first so you can see how the message maps to a bug. The general reference is Bug hunting, and the next posts in this series turn the offsets in the report into source lines.
The bug
A character device keeps per-open state in file->private_data. The author wrote the read handler and forgot to set the pointer in open:
struct ticker {
u64 stamp;
u32 count; /* offset 8 */
};
static int ticker_open(struct inode *inode, struct file *file)
{
/* BUG: private_data is never set, so it stays NULL */
return 0;
}
static ssize_t ticker_read(struct file *file, char __user *buf,
size_t len, loff_t *pos)
{
struct ticker *t = file->private_data;
char tmp[16];
int n = scnprintf(tmp, sizeof(tmp), "%u\n", t->count); /* t is NULL */
return simple_read_from_buffer(buf, len, pos, tmp, n);
}Running cat /dev/ticker as root produces the oops below. The field count sits 8 bytes into the structure, and the pointer is NULL, so the read touches address 8. Keep that arithmetic in mind: it is the key to this report.
The full report
BUG: kernel NULL pointer dereference, address: 0000000000000008
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 2 UID: 0 PID: 4411 Comm: cat Tainted: G O 6.12.0 #1
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3 04/01/2014
RIP: 0010:ticker_read+0x2a/0x90 [ticker]
Code: 0f 1f 44 00 00 55 48 89 e5 41 56 53 48 83 ec 10 48 8b 5f 70 8b 53 08 48 89 f3 ...
RSP: 0018:ffffc90001abfe00 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000020000 RSI: 00007ffd4a1c0b10 RDI: ffff888104f6c200
RBP: ffffc90001abfe30 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000020000
R13: ffffc90001abff08 R14: 00007ffd4a1c0b10 R15: ffff888104f6c200
FS: 00007f8c1a2b0740(0000) GS:ffff88813bd00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000008 CR3: 0000000104a5c000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
<TASK>
? __die+0x24/0x70
? page_fault_oops+0x15a/0x2f0
? exc_page_fault+0x6e/0x180
? asm_exc_page_fault+0x26/0x30
? ticker_read+0x2a/0x90 [ticker]
vfs_read+0xbe/0x320
ksys_read+0x6c/0xf0
do_syscall_64+0x5b/0x180
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>
Modules linked in: ticker(O) nft_chain_nat xt_REDIRECT
CR2: 0000000000000008
---[ end trace 0000000000000000 ]---Addresses, offsets and register values will differ on your machine, and the Hardware name line shows your own platform.
The first three lines: what and where
**BUG: kernel NULL pointer dereference, address: 0000000000000008.** This is the headline. The kernel tried to access memory that is not mapped, and the address was small enough to look like a NULL pointer plus a field offset. The address is the most useful single number. Any address below roughly 4096 is almost always a NULL base pointer plus an offset: here, offset 8, which is the count field. Open the structure definition and find which field sits at that offset.
**#PF: supervisor read access in kernel mode.** A page fault (#PF), by code running in kernel mode ("supervisor"), trying to read. Possible variants are write access and instruction fetch. A fetch at a small address means a call through a NULL function pointer.
**#PF: error_code(0x0000) - not-present page.** The hardware error code decoded: bit 0 clear means the page was not present, bit 1 clear means a read, bit 2 clear means kernel mode. A nonzero bit 0 would mean a protection violation on a mapped page, which suggests a different bug, such as writing to read-only memory.
The line PGD 0 P4D 0 shows the top page table entries for the address, both zero, meaning nothing is mapped near address 0.
The Oops line and the context
**Oops: 0000 [#1] PREEMPT SMP NOPTI.** The four-digit number is the error code again, and [#1] counts oopses since boot. A second oops would say [#2], and by then the machine may be unreliable. The words after it describe the build: preemptible, symmetric multiprocessing, and no page table isolation on this CPU.
**CPU: 2 UID: 0 PID: 4411 Comm: cat.** The CPU, user id, process id and name of the task that was running. cat is not buggy. It called read() on your device, and your driver crashed in the kernel on its behalf. The process you see is the victim, and the bug is in the code at the RIP.
**Tainted: G O.** The taint flags. G means no proprietary module was loaded, and O means an out-of-tree module was. Out-of-tree is expected for your development module. Extra letters such as D or W would say earlier problems happened, which means you should look at the first failure, not this one.
**6.12.0 #1.** The kernel release and the build number. Always include it in a bug report.
The instruction pointer
**RIP: 0010:ticker_read+0x2a/0x90 [ticker].** This is the line to remember. RIP is the instruction pointer when the fault happened. 0010 is the code segment selector. The rest says the instruction was in function ticker_read, at offset 0x2a bytes from its start, and that the function is 0x90 bytes long, inside module ticker. The next post uses faddr2line with exactly ticker_read+0x2a/0x90 to find the source line.
**Code: ....** The bytes of machine code around the faulting instruction, with the faulting byte marked in angle brackets in the full report on many kernels. The scripts/decodecode tool disassembles them. You rarely need them if you have symbols.
The registers
The block from RSP to PKRU is the CPU state. Most of it is noise, but three things help.
RAX through R15 are the general registers. A register holding 0000000000000000 that the code then dereferences is your NULL. In this oops RBX is zero, and RBX held t in the compiled function, which is why the fault address is RBX + 8.
RDI, RSI and RDX hold the first three arguments of the function in the x86-64 calling convention. At the fault, RDI is ffff888104f6c200, the struct file *, which looks like a valid kernel address, and RSI is a user-space address, the buf argument, starting with 00007. Addresses beginning ffff8881 are in the kernel's direct map. Addresses beginning ffffc9 are vmalloc or stack areas. Addresses beginning 0000 or 00007 are user space.
CR2 is the faulting address again, 0000000000000008. If it differs from the headline address, something unusual happened. CR3 is the page table root and CR4 the feature flags, which you can ignore.
The call trace
? __die+0x24/0x70
? page_fault_oops+0x15a/0x2f0
? exc_page_fault+0x6e/0x180
? asm_exc_page_fault+0x26/0x30
? ticker_read+0x2a/0x90 [ticker]
vfs_read+0xbe/0x320
ksys_read+0x6c/0xf0
do_syscall_64+0x5b/0x180The trace reads from the top, most recent call first. The first four lines are the machinery of fault handling: asm_exc_page_fault, exc_page_fault and page_fault_oops are the kernel catching the fault and starting the report, and __die prints it. The leading question mark means the unwinder is not certain the frame is real, which is normal for the fault frames above the faulting function. After them comes ticker_read, the function that crashed, and then its callers in order: vfs_read called by ksys_read called by the system call entry do_syscall_64. That is the path from user space.
So the story is: cat made a read() system call, which went through the VFS into ticker_read, which accessed address 8 and faulted. That is the whole diagnosis, produced from five lines.
Frames marked with ? deserve a little suspicion. On a kernel with the ORC unwinder, the default on x86-64, most frames are exact, and the question marks appear only above an exception. On older frame-pointer kernels, the stack is scanned and some frames may be stale entries.
The footer
**Modules linked in: ticker(O) ....** The loaded modules, with taint markers. This tells you which code could have corrupted memory. A crash in core code with a third-party module loaded is a different investigation than one with none.
**---[ end trace 0000000000000000 ]---.** The end marker. The trace id is always zero in current kernels.
From message to fix
The reading procedure for any oops, from this example:
Top line. What kind of fault and what address. A small address is a NULL pointer plus an offset.
RIP. Which function and offset. This is where to look in the source.
Offset arithmetic. Subtract: address 8 means the field at offset 8 of whichever struct the code was reading. Check with
pahole -C ticker ticker.koor by counting.Call trace. Who called into the function. The bug is often not in the crashing function but in a caller that passed a bad pointer, or in an earlier function that never initialized it, as here.
Taint and modules. What state the kernel was in before.
For the example, step 3 says the NULL pointer is t, step 2 says it is in ticker_read, and step 4 says it was called directly from the VFS, so the pointer must come from file->private_data, which ticker_open never set. The fix:
static int ticker_open(struct inode *inode, struct file *file)
{
struct ticker *t = kzalloc(sizeof(*t), GFP_KERNEL);
if (!t)
return -ENOMEM;
file->private_data = t;
return 0;
}
static int ticker_release(struct inode *inode, struct file *file)
{
kfree(file->private_data);
return 0;
}Save it before you do anything else
An oops is evidence. Copy the full text before rebooting or reloading the module: dmesg > oops.txt, or from a crashed machine, from the journal of the previous boot as described in the dmesg post. Include everything from the first BUG: or WARNING: line to the end marker, plus a few lines before it, because the cause is sometimes a warning printed just earlier. Note the exact kernel version and the commit or config if you build your own.


