Kernel Oops vs Panic vs BUG vs WARN: What Each Means
Tell a kernel warning from an oops, a BUG and a panic by what the kernel does next, which taint flag it sets and which sysctls turn one into another.

The kernel log is full of alarming words: warning, oops, BUG, panic. They are not synonyms. Each describes a different failure, a different reaction by the kernel, and a different amount of trust you should place in the machine afterward. A WARN leaves the system running. An oops kills one task and taints the kernel. A BUG() is an oops raised on purpose. A panic stops everything. This post separates them on Linux 6.12 with the log text of each, the taint flags they set, and the settings that promote one to another. The authoritative references are Bug hunting and Tainted kernels.
The four at a glance
| Event | Trigger | What the kernel does | Taint flag | System afterward |
|---|---|---|---|---|
WARN | WARN(), WARN_ON(), WARN_ON_ONCE() | Prints a message and a stack trace, then continues | W | Running, but a bug was hit |
| Oops | A CPU exception in kernel mode (bad pointer, invalid opcode) | Prints registers and a trace, kills the current task | D | Possibly unstable |
BUG | BUG(), BUG_ON(cond) | Prints a message, then raises an oops | D | Same as an oops |
| Panic | panic(), or an oops it cannot survive | Prints a message, stops, optionally reboots | none needed | Halted or rebooting |
The summary: warnings are "this should not happen", oopses and BUGs are "the current code path is broken and is being ended", and a panic is "the whole system is unsafe to continue".
WARN: loud but survivable
A warning is a check the developer wrote with WARN_ON(condition) for a state that indicates a bug but that the kernel can plausibly continue from. The log has the file, line and function, and a stack trace:
------------[ cut here ]------------
WARNING: CPU: 1 PID: 2411 at drivers/misc/ticker.c:88 ticker_set_rate+0x4a/0x90 [ticker]
Modules linked in: ticker(O) nft_chain_nat xt_REDIRECT
CPU: 1 UID: 0 PID: 2411 Comm: ticker-test Tainted: G O 6.12.0 #3
Call Trace:
<TASK>
ticker_ioctl+0x88/0x140 [ticker]
__x64_sys_ioctl+0x91/0xd0
do_syscall_64+0x5b/0x180
</TASK>
---[ end trace 0000000000000000 ]---The cut-here marker delimits the report for tools that scan logs. The caller continues after the check, so the code around a WARN_ON() should handle the bad state, usually by returning an error:
static int ticker_set_rate(struct ticker *t, unsigned int rate)
{
if (WARN_ON(rate == 0)) /* a caller passed a bad value */
return -EINVAL;
t->rate = rate;
return 0;
}The variant WARN_ON_ONCE() prints only the first time, which stops a bug in a hot path from flooding the log, and is the form to prefer. WARN() takes a printf-style message as well. A warning sets the W taint flag, shown as Tainted: W in later reports. That flag matters for bug reports: it says the kernel has already seen something wrong, so a later failure may be a consequence.
Oops: a task dies, the kernel may live
An oops happens when the CPU raises an exception while running kernel code, and the kernel cannot recover: a NULL or wild pointer dereference, an invalid instruction, a general protection fault. The handler prints the state, marks the kernel tainted with D (died), and kills the task that caused it. Whether the machine keeps running depends on where the fault occurred and how it is configured.
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
RIP: 0010:ticker_read+0x2a/0x90 [ticker]
Call Trace:
<TASK>
vfs_read+0xbe/0x320
ksys_read+0x6c/0xf0
do_syscall_64+0x5b/0x180
</TASK>The first line begins with BUG: even though it is an oops caused by a page fault, which confuses people. The word Oops: on the fifth line and the bracket [#1], which counts oopses since boot, are the markers. After an oops, the task is terminated with a signal, resources it held, including locks, are not released, and any other code that later needs one of those locks will hang. That is why a system "survives" an oops but is not trustworthy: it may be wedged on the next access to the same resource, or hold corrupted state. The next post in this series reads this report line by line.
BUG: an oops on purpose
BUG() is a deliberate crash for a condition the developer decided is not recoverable, and BUG_ON(cond) is the conditional form. On x86 it executes an undefined instruction, which raises an exception, and the report names the file and line:
------------[ cut here ]------------
kernel BUG at drivers/misc/ticker.c:101!
Oops: invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
CPU: 3 UID: 0 PID: 4502 Comm: ticker-test Tainted: G O 6.12.0 #1
RIP: 0010:ticker_finish+0x3e/0x60 [ticker]The text kernel BUG at file:line! marks it, and the invalid opcode is the mechanism. New code should avoid BUG_ON(). Kernel policy, stated repeatedly by maintainers, is that a driver must not take the machine down for a condition it could report: use WARN_ON_ONCE() and an error return. Existing BUG_ON() calls remain for corruption that cannot be contained, such as a broken list that would spread memory damage. Builds with CONFIG_BUG=n compile BUG() away, which is only for tiny embedded kernels.
static void ticker_finish(struct ticker *t)
{
BUG_ON(t->state != TICKER_IDLE); /* avoid in new code */
}Panic: the system stops
A panic is a decision that the kernel cannot continue. Some are raised explicitly with panic("message"), such as "Attempted to kill init!", "VFS: Unable to mount root fs", or a hardware machine check. Others are an oops that cannot be survived: an oops in an interrupt handler, in the idle task, or with in_atomic() true cannot kill just a task, so the kernel panics:
Kernel panic - not syncing: Fatal exception in interrupt
Kernel Offset: disabled
---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---A panic prints the reason, tries to flush logs and stops all CPUs. What happens next depends on settings: the machine halts, reboots after a delay, or jumps into a crash kernel to take a memory dump with kdump. By default it halts and spins.
How the settings convert one into another
You can make the kernel stricter, or more tolerant, with a few controls:
| Setting | Effect |
|---|---|
kernel.panic_on_oops=1 or oops=panic | An oops becomes a panic |
kernel.panic_on_warn=1 or panic_on_warn=1 | A WARN becomes a panic |
kernel.panic=N or panic=N | Reboot N seconds after a panic; 0 never reboots; negative reboots at once |
kernel.softlockup_panic, kernel.hung_task_panic | Panic on a detected lockup or hung task |
kernel.unknown_nmi_panic | Panic on an unknown NMI |
CONFIG_BUG_ON_DATA_CORRUPTION=y | Corrupted lists and heap metadata become a BUG() |
Production servers commonly set panic_on_oops=1 with panic=10 plus kdump, because an oopsed machine is untrustworthy, and a clean reboot or dump beats a half-working node in a cluster. Development machines usually leave them off so you can read the log after an oops. Fuzzing and CI systems enable panic_on_warn, which turns every WARN into a failure that is impossible to miss.
sudo sysctl -w kernel.panic_on_oops=1
sudo sysctl -w kernel.panic=10kernel.panic_on_oops = 1
kernel.panic = 10Reading the taint flags
The Tainted: string in every report shows letters for conditions that make bug reports harder to trust. The ones you meet while developing:
| Letter | Meaning |
|---|---|
G | No proprietary module loaded (when shown as G); P shows when one is |
O | An out-of-tree module was loaded |
W | A warning was issued earlier |
D | The kernel died: an oops or a BUG happened earlier |
E | An unsigned module was loaded |
L | A soft lockup occurred earlier |
U | User requested the taint |
cat /proc/sys/kernel/tainted prints the bitmask, and the documentation lists every flag. Report the first oops after a boot, not the later ones: once D is set, later failures are often consequences.
A quick way to classify a log message
| You see | It is a |
|---|---|
WARNING: CPU: ... at file:line | Warning |
kernel BUG at file:line! | BUG, followed by an oops |
BUG: kernel NULL pointer dereference or Oops: | Oops from a bad access |
BUG: unable to handle page fault for address | Oops from a bad access |
BUG: scheduling while atomic, BUG: sleeping function called from invalid context | Not an oops: a detected misuse that the kernel logs and survives |
Kernel panic - not syncing: ... | Panic |
watchdog: BUG: soft lockup - CPU#N stuck | A detected lockup, not an oops |
The word BUG: appears in many reports that are not BUG() calls. It is a prefix that the kernel uses for several kinds of serious but sometimes survivable problems. Read the rest of the line to know which.
What to do first
For a warning, find the line, work out which caller passed the bad value, and fix the caller. For an oops or a BUG, save the whole report before anything else, since the log may be lost on reboot, then decode it with the tools in this series. For a panic, the log may be incomplete, so a serial console, netconsole or a crash dump is how you capture it. In all cases, record the first event after boot, the kernel version and the taint line.


