kernel/panic.c
Source file repositories/reference/linux-study-clean/kernel/panic.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/panic.c- Extension
.c- Size
- 32565 bytes
- Lines
- 1275
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debug_locks.hlinux/sched/debug.hlinux/interrupt.hlinux/kgdb.hlinux/kmsg_dump.hlinux/kallsyms.hlinux/notifier.hlinux/vt_kern.hlinux/module.hlinux/random.hlinux/ftrace.hlinux/reboot.hlinux/delay.hlinux/kexec.hlinux/panic_notifier.hlinux/sched.hlinux/string_helpers.hlinux/sysrq.hlinux/init.hlinux/nmi.hlinux/console.hlinux/bug.hlinux/ratelimit.hlinux/debugfs.hlinux/sysfs.hlinux/context_tracking.hlinux/seq_buf.hlinux/sys_info.htrace/events/error_report.hasm/sections.hkunit/test-bug.h
Detected Declarations
struct warn_argsfunction panic_print_deprecatedfunction proc_taintfunction sysctl_panic_print_handlerfunction kernel_panic_sysctls_initfunction setup_panic_sys_infofunction warn_count_showfunction kernel_panic_sysfs_initfunction no_blinkfunction panic_smp_self_stopfunction nmi_panic_self_stopfunction crash_smp_send_stopfunction panic_force_cpu_setupfunction panic_force_cpu_late_initfunction do_panic_on_target_cpufunction panic_smp_redirect_cpufunction panic_try_force_cpufunction IS_ENABLEDfunction panic_try_force_cpufunction panic_try_startfunction panic_resetfunction panic_in_progressfunction panic_on_this_cpufunction panic_on_other_cpufunction panicfunction check_panic_on_warnfunction panic_trigger_all_cpu_backtracefunction backtracefunction vpanicfunction smp_send_stopfunction panicfunction print_tainted_seqfunction alloc_taint_buffunction print_taintedfunction test_taintfunction get_taintfunction add_taintfunction spin_msecfunction oops_enterfunction oops_may_printfunction oops_enterfunction print_oops_end_markerfunction oops_exitfunction __warnfunction warn_slowpath_fmtfunction __warn_printkfunction clear_warn_once_setfunction register_warn_debugfs
Annotated Snippet
device_initcall(register_warn_debugfs);
#endif
#ifdef CONFIG_STACKPROTECTOR
/*
* Called when gcc's -fstack-protector feature is used, and
* gcc detects corruption of the on-stack canary value
*/
__visible noinstr void __stack_chk_fail(void)
{
unsigned long flags;
instrumentation_begin();
flags = user_access_save();
panic("stack-protector: Kernel stack is corrupted in: %pB",
__builtin_return_address(0));
user_access_restore(flags);
instrumentation_end();
}
EXPORT_SYMBOL(__stack_chk_fail);
#endif
core_param(panic, panic_timeout, int, 0644);
core_param(pause_on_oops, pause_on_oops, int, 0644);
core_param(panic_on_warn, panic_on_warn, int, 0644);
core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644);
core_param(panic_console_replay, panic_console_replay, bool, 0644);
static int panic_print_set(const char *val, const struct kernel_param *kp)
{
panic_print_deprecated();
return param_set_ulong(val, kp);
}
static int panic_print_get(char *val, const struct kernel_param *kp)
{
return param_get_ulong(val, kp);
}
static const struct kernel_param_ops panic_print_ops = {
.set = panic_print_set,
.get = panic_print_get,
};
__core_param_cb(panic_print, &panic_print_ops, &panic_print, 0644);
static int __init oops_setup(char *s)
{
if (!s)
return -EINVAL;
if (!strcmp(s, "panic"))
panic_on_oops = 1;
return 0;
}
early_param("oops", oops_setup);
static int __init panic_on_taint_setup(char *s)
{
char *taint_str;
if (!s)
return -EINVAL;
taint_str = strsep(&s, ",");
if (kstrtoul(taint_str, 16, &panic_on_taint))
return -EINVAL;
/* make sure panic_on_taint doesn't hold out-of-range TAINT flags */
panic_on_taint &= TAINT_FLAGS_MAX;
if (!panic_on_taint)
return -EINVAL;
if (s && !strcmp(s, "nousertaint"))
panic_on_taint_nousertaint = true;
pr_info("panic_on_taint: bitmask=0x%lx nousertaint_mode=%s\n",
panic_on_taint, str_enabled_disabled(panic_on_taint_nousertaint));
return 0;
}
early_param("panic_on_taint", panic_on_taint_setup);
Annotation
- Immediate include surface: `linux/debug_locks.h`, `linux/sched/debug.h`, `linux/interrupt.h`, `linux/kgdb.h`, `linux/kmsg_dump.h`, `linux/kallsyms.h`, `linux/notifier.h`, `linux/vt_kern.h`.
- Detected declarations: `struct warn_args`, `function panic_print_deprecated`, `function proc_taint`, `function sysctl_panic_print_handler`, `function kernel_panic_sysctls_init`, `function setup_panic_sys_info`, `function warn_count_show`, `function kernel_panic_sysfs_init`, `function no_blink`, `function panic_smp_self_stop`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.