| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/kernel/panic.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 11 | 12 | #include <linux/debug_locks.h> |
|---|
| 12 | 13 | #include <linux/sched/debug.h> |
|---|
| 13 | 14 | #include <linux/interrupt.h> |
|---|
| 15 | +#include <linux/kgdb.h> |
|---|
| 14 | 16 | #include <linux/kmsg_dump.h> |
|---|
| 15 | 17 | #include <linux/kallsyms.h> |
|---|
| 16 | 18 | #include <linux/notifier.h> |
|---|
| .. | .. |
|---|
| 29 | 31 | #include <linux/bug.h> |
|---|
| 30 | 32 | #include <linux/ratelimit.h> |
|---|
| 31 | 33 | #include <linux/debugfs.h> |
|---|
| 34 | +#include <linux/sysfs.h> |
|---|
| 32 | 35 | #include <asm/sections.h> |
|---|
| 33 | 36 | |
|---|
| 34 | 37 | #define PANIC_TIMER_STEP 100 |
|---|
| 35 | 38 | #define PANIC_BLINK_SPD 18 |
|---|
| 39 | + |
|---|
| 40 | +#ifdef CONFIG_SMP |
|---|
| 41 | +/* |
|---|
| 42 | + * Should we dump all CPUs backtraces in an oops event? |
|---|
| 43 | + * Defaults to 0, can be changed via sysctl. |
|---|
| 44 | + */ |
|---|
| 45 | +static unsigned int __read_mostly sysctl_oops_all_cpu_backtrace; |
|---|
| 46 | +#else |
|---|
| 47 | +#define sysctl_oops_all_cpu_backtrace 0 |
|---|
| 48 | +#endif /* CONFIG_SMP */ |
|---|
| 36 | 49 | |
|---|
| 37 | 50 | int panic_on_oops = CONFIG_PANIC_ON_OOPS_VALUE; |
|---|
| 38 | 51 | static unsigned long tainted_mask = |
|---|
| .. | .. |
|---|
| 42 | 55 | static DEFINE_SPINLOCK(pause_on_oops_lock); |
|---|
| 43 | 56 | bool crash_kexec_post_notifiers; |
|---|
| 44 | 57 | int panic_on_warn __read_mostly; |
|---|
| 58 | +unsigned long panic_on_taint; |
|---|
| 59 | +bool panic_on_taint_nousertaint = false; |
|---|
| 60 | +static unsigned int warn_limit __read_mostly; |
|---|
| 45 | 61 | |
|---|
| 46 | 62 | int panic_timeout = CONFIG_PANIC_TIMEOUT; |
|---|
| 47 | 63 | EXPORT_SYMBOL_GPL(panic_timeout); |
|---|
| 48 | 64 | |
|---|
| 65 | +#define PANIC_PRINT_TASK_INFO 0x00000001 |
|---|
| 66 | +#define PANIC_PRINT_MEM_INFO 0x00000002 |
|---|
| 67 | +#define PANIC_PRINT_TIMER_INFO 0x00000004 |
|---|
| 68 | +#define PANIC_PRINT_LOCK_INFO 0x00000008 |
|---|
| 69 | +#define PANIC_PRINT_FTRACE_INFO 0x00000010 |
|---|
| 70 | +#define PANIC_PRINT_ALL_PRINTK_MSG 0x00000020 |
|---|
| 71 | +unsigned long panic_print; |
|---|
| 72 | + |
|---|
| 49 | 73 | ATOMIC_NOTIFIER_HEAD(panic_notifier_list); |
|---|
| 74 | + |
|---|
| 50 | 75 | EXPORT_SYMBOL(panic_notifier_list); |
|---|
| 51 | 76 | |
|---|
| 52 | | -void (*vendor_panic_cb)(u64 sp); |
|---|
| 53 | | -EXPORT_SYMBOL_GPL(vendor_panic_cb); |
|---|
| 77 | +#ifdef CONFIG_SYSCTL |
|---|
| 78 | +static struct ctl_table kern_panic_table[] = { |
|---|
| 79 | +#ifdef CONFIG_SMP |
|---|
| 80 | + { |
|---|
| 81 | + .procname = "oops_all_cpu_backtrace", |
|---|
| 82 | + .data = &sysctl_oops_all_cpu_backtrace, |
|---|
| 83 | + .maxlen = sizeof(int), |
|---|
| 84 | + .mode = 0644, |
|---|
| 85 | + .proc_handler = proc_dointvec_minmax, |
|---|
| 86 | + .extra1 = SYSCTL_ZERO, |
|---|
| 87 | + .extra2 = SYSCTL_ONE, |
|---|
| 88 | + }, |
|---|
| 89 | +#endif |
|---|
| 90 | + { |
|---|
| 91 | + .procname = "warn_limit", |
|---|
| 92 | + .data = &warn_limit, |
|---|
| 93 | + .maxlen = sizeof(warn_limit), |
|---|
| 94 | + .mode = 0644, |
|---|
| 95 | + .proc_handler = proc_douintvec, |
|---|
| 96 | + }, |
|---|
| 97 | + { } |
|---|
| 98 | +}; |
|---|
| 99 | + |
|---|
| 100 | +static __init int kernel_panic_sysctls_init(void) |
|---|
| 101 | +{ |
|---|
| 102 | + register_sysctl_init("kernel", kern_panic_table); |
|---|
| 103 | + return 0; |
|---|
| 104 | +} |
|---|
| 105 | +late_initcall(kernel_panic_sysctls_init); |
|---|
| 106 | +#endif |
|---|
| 107 | + |
|---|
| 108 | +static atomic_t warn_count = ATOMIC_INIT(0); |
|---|
| 109 | + |
|---|
| 110 | +#ifdef CONFIG_SYSFS |
|---|
| 111 | +static ssize_t warn_count_show(struct kobject *kobj, struct kobj_attribute *attr, |
|---|
| 112 | + char *page) |
|---|
| 113 | +{ |
|---|
| 114 | + return sysfs_emit(page, "%d\n", atomic_read(&warn_count)); |
|---|
| 115 | +} |
|---|
| 116 | + |
|---|
| 117 | +static struct kobj_attribute warn_count_attr = __ATTR_RO(warn_count); |
|---|
| 118 | + |
|---|
| 119 | +static __init int kernel_panic_sysfs_init(void) |
|---|
| 120 | +{ |
|---|
| 121 | + sysfs_add_file_to_group(kernel_kobj, &warn_count_attr.attr, NULL); |
|---|
| 122 | + return 0; |
|---|
| 123 | +} |
|---|
| 124 | +late_initcall(kernel_panic_sysfs_init); |
|---|
| 125 | +#endif |
|---|
| 54 | 126 | |
|---|
| 55 | 127 | static long no_blink(int state) |
|---|
| 56 | 128 | { |
|---|
| .. | .. |
|---|
| 127 | 199 | } |
|---|
| 128 | 200 | EXPORT_SYMBOL(nmi_panic); |
|---|
| 129 | 201 | |
|---|
| 202 | +static void panic_print_sys_info(void) |
|---|
| 203 | +{ |
|---|
| 204 | + if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG) |
|---|
| 205 | + console_flush_on_panic(CONSOLE_REPLAY_ALL); |
|---|
| 206 | + |
|---|
| 207 | + if (panic_print & PANIC_PRINT_TASK_INFO) |
|---|
| 208 | + show_state(); |
|---|
| 209 | + |
|---|
| 210 | + if (panic_print & PANIC_PRINT_MEM_INFO) |
|---|
| 211 | + show_mem(0, NULL); |
|---|
| 212 | + |
|---|
| 213 | + if (panic_print & PANIC_PRINT_TIMER_INFO) |
|---|
| 214 | + sysrq_timer_list_show(); |
|---|
| 215 | + |
|---|
| 216 | + if (panic_print & PANIC_PRINT_LOCK_INFO) |
|---|
| 217 | + debug_show_all_locks(); |
|---|
| 218 | + |
|---|
| 219 | + if (panic_print & PANIC_PRINT_FTRACE_INFO) |
|---|
| 220 | + ftrace_dump(DUMP_ALL); |
|---|
| 221 | +} |
|---|
| 222 | + |
|---|
| 223 | +void check_panic_on_warn(const char *origin) |
|---|
| 224 | +{ |
|---|
| 225 | + unsigned int limit; |
|---|
| 226 | + |
|---|
| 227 | + if (panic_on_warn) |
|---|
| 228 | + panic("%s: panic_on_warn set ...\n", origin); |
|---|
| 229 | + |
|---|
| 230 | + limit = READ_ONCE(warn_limit); |
|---|
| 231 | + if (atomic_inc_return(&warn_count) >= limit && limit) |
|---|
| 232 | + panic("%s: system warned too often (kernel.warn_limit is %d)", |
|---|
| 233 | + origin, limit); |
|---|
| 234 | +} |
|---|
| 235 | + |
|---|
| 130 | 236 | /** |
|---|
| 131 | 237 | * panic - halt the system |
|---|
| 132 | 238 | * @fmt: The text string to print |
|---|
| .. | .. |
|---|
| 139 | 245 | { |
|---|
| 140 | 246 | static char buf[1024]; |
|---|
| 141 | 247 | va_list args; |
|---|
| 142 | | - long i, i_next = 0; |
|---|
| 248 | + long i, i_next = 0, len; |
|---|
| 143 | 249 | int state = 0; |
|---|
| 144 | 250 | int old_cpu, this_cpu; |
|---|
| 145 | 251 | bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers; |
|---|
| 252 | + |
|---|
| 253 | + if (panic_on_warn) { |
|---|
| 254 | + /* |
|---|
| 255 | + * This thread may hit another WARN() in the panic path. |
|---|
| 256 | + * Resetting this prevents additional WARN() from panicking the |
|---|
| 257 | + * system on this thread. Other threads are blocked by the |
|---|
| 258 | + * panic_mutex in panic(). |
|---|
| 259 | + */ |
|---|
| 260 | + panic_on_warn = 0; |
|---|
| 261 | + } |
|---|
| 146 | 262 | |
|---|
| 147 | 263 | /* |
|---|
| 148 | 264 | * Disable local interrupts. This will prevent panic_smp_self_stop |
|---|
| .. | .. |
|---|
| 177 | 293 | console_verbose(); |
|---|
| 178 | 294 | bust_spinlocks(1); |
|---|
| 179 | 295 | va_start(args, fmt); |
|---|
| 180 | | - vsnprintf(buf, sizeof(buf), fmt, args); |
|---|
| 296 | + len = vscnprintf(buf, sizeof(buf), fmt, args); |
|---|
| 181 | 297 | va_end(args); |
|---|
| 182 | | - if (vendor_panic_cb) |
|---|
| 183 | | - vendor_panic_cb(0); |
|---|
| 298 | + |
|---|
| 299 | + if (len && buf[len - 1] == '\n') |
|---|
| 300 | + buf[len - 1] = '\0'; |
|---|
| 301 | + |
|---|
| 184 | 302 | pr_emerg("Kernel panic - not syncing: %s\n", buf); |
|---|
| 185 | 303 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
|---|
| 186 | 304 | /* |
|---|
| .. | .. |
|---|
| 189 | 307 | if (!test_taint(TAINT_DIE) && oops_in_progress <= 1) |
|---|
| 190 | 308 | dump_stack(); |
|---|
| 191 | 309 | #endif |
|---|
| 310 | + |
|---|
| 311 | + /* |
|---|
| 312 | + * If kgdb is enabled, give it a chance to run before we stop all |
|---|
| 313 | + * the other CPUs or else we won't be able to debug processes left |
|---|
| 314 | + * running on them. |
|---|
| 315 | + */ |
|---|
| 316 | + kgdb_panic(buf); |
|---|
| 192 | 317 | |
|---|
| 193 | 318 | /* |
|---|
| 194 | 319 | * If we have crashed and we have a crash kernel loaded let it handle |
|---|
| .. | .. |
|---|
| 253 | 378 | * panic() is not being callled from OOPS. |
|---|
| 254 | 379 | */ |
|---|
| 255 | 380 | debug_locks_off(); |
|---|
| 256 | | - console_flush_on_panic(); |
|---|
| 381 | + console_flush_on_panic(CONSOLE_FLUSH_PENDING); |
|---|
| 382 | + |
|---|
| 383 | + panic_print_sys_info(); |
|---|
| 257 | 384 | |
|---|
| 258 | 385 | if (!panic_blink) |
|---|
| 259 | 386 | panic_blink = no_blink; |
|---|
| .. | .. |
|---|
| 294 | 421 | } |
|---|
| 295 | 422 | #endif |
|---|
| 296 | 423 | #if defined(CONFIG_S390) |
|---|
| 297 | | - { |
|---|
| 298 | | - unsigned long caller; |
|---|
| 299 | | - |
|---|
| 300 | | - caller = (unsigned long)__builtin_return_address(0); |
|---|
| 301 | | - disabled_wait(caller); |
|---|
| 302 | | - } |
|---|
| 424 | + disabled_wait(); |
|---|
| 303 | 425 | #endif |
|---|
| 304 | 426 | pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf); |
|---|
| 427 | + |
|---|
| 428 | + /* Do not scroll important messages printed above */ |
|---|
| 429 | + suppress_printk = 1; |
|---|
| 305 | 430 | local_irq_enable(); |
|---|
| 306 | 431 | for (i = 0; ; i += PANIC_TIMER_STEP) { |
|---|
| 307 | 432 | touch_softlockup_watchdog(); |
|---|
| .. | .. |
|---|
| 343 | 468 | /** |
|---|
| 344 | 469 | * print_tainted - return a string to represent the kernel taint state. |
|---|
| 345 | 470 | * |
|---|
| 346 | | - * For individual taint flag meanings, see Documentation/sysctl/kernel.txt |
|---|
| 471 | + * For individual taint flag meanings, see Documentation/admin-guide/sysctl/kernel.rst |
|---|
| 347 | 472 | * |
|---|
| 348 | 473 | * The string is overwritten by the next call to print_tainted(), |
|---|
| 349 | 474 | * but is always NULL terminated. |
|---|
| .. | .. |
|---|
| 396 | 521 | pr_warn("Disabling lock debugging due to kernel taint\n"); |
|---|
| 397 | 522 | |
|---|
| 398 | 523 | set_bit(flag, &tainted_mask); |
|---|
| 524 | + |
|---|
| 525 | + if (tainted_mask & panic_on_taint) { |
|---|
| 526 | + panic_on_taint = 0; |
|---|
| 527 | + panic("panic_on_taint set ..."); |
|---|
| 528 | + } |
|---|
| 399 | 529 | } |
|---|
| 400 | 530 | EXPORT_SYMBOL(add_taint); |
|---|
| 401 | 531 | |
|---|
| .. | .. |
|---|
| 452 | 582 | * Return true if the calling CPU is allowed to print oops-related info. |
|---|
| 453 | 583 | * This is a bit racy.. |
|---|
| 454 | 584 | */ |
|---|
| 455 | | -int oops_may_print(void) |
|---|
| 585 | +bool oops_may_print(void) |
|---|
| 456 | 586 | { |
|---|
| 457 | 587 | return pause_on_oops_flag == 0; |
|---|
| 458 | 588 | } |
|---|
| .. | .. |
|---|
| 477 | 607 | /* can't trust the integrity of the kernel anymore: */ |
|---|
| 478 | 608 | debug_locks_off(); |
|---|
| 479 | 609 | do_oops_enter_exit(); |
|---|
| 610 | + |
|---|
| 611 | + if (sysctl_oops_all_cpu_backtrace) |
|---|
| 612 | + trigger_all_cpu_backtrace(); |
|---|
| 480 | 613 | } |
|---|
| 481 | 614 | |
|---|
| 482 | 615 | /* |
|---|
| .. | .. |
|---|
| 495 | 628 | } |
|---|
| 496 | 629 | late_initcall(init_oops_id); |
|---|
| 497 | 630 | |
|---|
| 498 | | -void print_oops_end_marker(void) |
|---|
| 631 | +static void print_oops_end_marker(void) |
|---|
| 499 | 632 | { |
|---|
| 500 | 633 | init_oops_id(); |
|---|
| 501 | 634 | pr_warn("---[ end trace %016llx ]---\n", (unsigned long long)oops_id); |
|---|
| .. | .. |
|---|
| 522 | 655 | { |
|---|
| 523 | 656 | disable_trace_on_warning(); |
|---|
| 524 | 657 | |
|---|
| 525 | | - if (args) |
|---|
| 526 | | - pr_warn(CUT_HERE); |
|---|
| 527 | | - |
|---|
| 528 | 658 | if (file) |
|---|
| 529 | 659 | pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n", |
|---|
| 530 | 660 | raw_smp_processor_id(), current->pid, file, line, |
|---|
| .. | .. |
|---|
| 536 | 666 | if (args) |
|---|
| 537 | 667 | vprintk(args->fmt, args->args); |
|---|
| 538 | 668 | |
|---|
| 539 | | - if (panic_on_warn) { |
|---|
| 540 | | - /* |
|---|
| 541 | | - * This thread may hit another WARN() in the panic path. |
|---|
| 542 | | - * Resetting this prevents additional WARN() from panicking the |
|---|
| 543 | | - * system on this thread. Other threads are blocked by the |
|---|
| 544 | | - * panic_mutex in panic(). |
|---|
| 545 | | - */ |
|---|
| 546 | | - panic_on_warn = 0; |
|---|
| 547 | | - panic("panic_on_warn set ...\n"); |
|---|
| 548 | | - } |
|---|
| 549 | | - |
|---|
| 550 | 669 | print_modules(); |
|---|
| 551 | 670 | |
|---|
| 552 | 671 | if (regs) |
|---|
| 553 | 672 | show_regs(regs); |
|---|
| 554 | | - else |
|---|
| 673 | + |
|---|
| 674 | + check_panic_on_warn("kernel"); |
|---|
| 675 | + |
|---|
| 676 | + if (!regs) |
|---|
| 555 | 677 | dump_stack(); |
|---|
| 556 | 678 | |
|---|
| 557 | 679 | print_irqtrace_events(current); |
|---|
| .. | .. |
|---|
| 562 | 684 | add_taint(taint, LOCKDEP_STILL_OK); |
|---|
| 563 | 685 | } |
|---|
| 564 | 686 | |
|---|
| 565 | | -#ifdef WANT_WARN_ON_SLOWPATH |
|---|
| 566 | | -void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...) |
|---|
| 687 | +#ifndef __WARN_FLAGS |
|---|
| 688 | +void warn_slowpath_fmt(const char *file, int line, unsigned taint, |
|---|
| 689 | + const char *fmt, ...) |
|---|
| 567 | 690 | { |
|---|
| 568 | 691 | struct warn_args args; |
|---|
| 569 | 692 | |
|---|
| 570 | | - args.fmt = fmt; |
|---|
| 571 | | - va_start(args.args, fmt); |
|---|
| 572 | | - __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, |
|---|
| 573 | | - &args); |
|---|
| 574 | | - va_end(args.args); |
|---|
| 575 | | -} |
|---|
| 576 | | -EXPORT_SYMBOL(warn_slowpath_fmt); |
|---|
| 693 | + pr_warn(CUT_HERE); |
|---|
| 577 | 694 | |
|---|
| 578 | | -void warn_slowpath_fmt_taint(const char *file, int line, |
|---|
| 579 | | - unsigned taint, const char *fmt, ...) |
|---|
| 580 | | -{ |
|---|
| 581 | | - struct warn_args args; |
|---|
| 695 | + if (!fmt) { |
|---|
| 696 | + __warn(file, line, __builtin_return_address(0), taint, |
|---|
| 697 | + NULL, NULL); |
|---|
| 698 | + return; |
|---|
| 699 | + } |
|---|
| 582 | 700 | |
|---|
| 583 | 701 | args.fmt = fmt; |
|---|
| 584 | 702 | va_start(args.args, fmt); |
|---|
| 585 | 703 | __warn(file, line, __builtin_return_address(0), taint, NULL, &args); |
|---|
| 586 | 704 | va_end(args.args); |
|---|
| 587 | 705 | } |
|---|
| 588 | | -EXPORT_SYMBOL(warn_slowpath_fmt_taint); |
|---|
| 589 | | - |
|---|
| 590 | | -void warn_slowpath_null(const char *file, int line) |
|---|
| 591 | | -{ |
|---|
| 592 | | - pr_warn(CUT_HERE); |
|---|
| 593 | | - __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL); |
|---|
| 594 | | -} |
|---|
| 595 | | -EXPORT_SYMBOL(warn_slowpath_null); |
|---|
| 706 | +EXPORT_SYMBOL(warn_slowpath_fmt); |
|---|
| 596 | 707 | #else |
|---|
| 597 | 708 | void __warn_printk(const char *fmt, ...) |
|---|
| 598 | 709 | { |
|---|
| .. | .. |
|---|
| 618 | 729 | return 0; |
|---|
| 619 | 730 | } |
|---|
| 620 | 731 | |
|---|
| 621 | | -DEFINE_SIMPLE_ATTRIBUTE(clear_warn_once_fops, |
|---|
| 622 | | - NULL, |
|---|
| 623 | | - clear_warn_once_set, |
|---|
| 624 | | - "%lld\n"); |
|---|
| 732 | +DEFINE_DEBUGFS_ATTRIBUTE(clear_warn_once_fops, NULL, clear_warn_once_set, |
|---|
| 733 | + "%lld\n"); |
|---|
| 625 | 734 | |
|---|
| 626 | 735 | static __init int register_warn_debugfs(void) |
|---|
| 627 | 736 | { |
|---|
| 628 | 737 | /* Don't care about failure */ |
|---|
| 629 | | - debugfs_create_file("clear_warn_once", 0200, NULL, |
|---|
| 630 | | - NULL, &clear_warn_once_fops); |
|---|
| 738 | + debugfs_create_file_unsafe("clear_warn_once", 0200, NULL, NULL, |
|---|
| 739 | + &clear_warn_once_fops); |
|---|
| 631 | 740 | return 0; |
|---|
| 632 | 741 | } |
|---|
| 633 | 742 | |
|---|
| .. | .. |
|---|
| 640 | 749 | * Called when gcc's -fstack-protector feature is used, and |
|---|
| 641 | 750 | * gcc detects corruption of the on-stack canary value |
|---|
| 642 | 751 | */ |
|---|
| 643 | | -__visible void __stack_chk_fail(void) |
|---|
| 752 | +__visible noinstr void __stack_chk_fail(void) |
|---|
| 644 | 753 | { |
|---|
| 754 | + instrumentation_begin(); |
|---|
| 645 | 755 | panic("stack-protector: Kernel stack is corrupted in: %pB", |
|---|
| 646 | 756 | __builtin_return_address(0)); |
|---|
| 757 | + instrumentation_end(); |
|---|
| 647 | 758 | } |
|---|
| 648 | 759 | EXPORT_SYMBOL(__stack_chk_fail); |
|---|
| 649 | 760 | |
|---|
| 650 | 761 | #endif |
|---|
| 651 | 762 | |
|---|
| 652 | | -#ifdef CONFIG_ARCH_HAS_REFCOUNT |
|---|
| 653 | | -void refcount_error_report(struct pt_regs *regs, const char *err) |
|---|
| 654 | | -{ |
|---|
| 655 | | - WARN_RATELIMIT(1, "refcount_t %s at %pB in %s[%d], uid/euid: %u/%u\n", |
|---|
| 656 | | - err, (void *)instruction_pointer(regs), |
|---|
| 657 | | - current->comm, task_pid_nr(current), |
|---|
| 658 | | - from_kuid_munged(&init_user_ns, current_uid()), |
|---|
| 659 | | - from_kuid_munged(&init_user_ns, current_euid())); |
|---|
| 660 | | -} |
|---|
| 661 | | -#endif |
|---|
| 662 | | - |
|---|
| 663 | 763 | core_param(panic, panic_timeout, int, 0644); |
|---|
| 764 | +core_param(panic_print, panic_print, ulong, 0644); |
|---|
| 664 | 765 | core_param(pause_on_oops, pause_on_oops, int, 0644); |
|---|
| 665 | 766 | core_param(panic_on_warn, panic_on_warn, int, 0644); |
|---|
| 666 | 767 | core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644); |
|---|
| .. | .. |
|---|
| 674 | 775 | return 0; |
|---|
| 675 | 776 | } |
|---|
| 676 | 777 | early_param("oops", oops_setup); |
|---|
| 778 | + |
|---|
| 779 | +static int __init panic_on_taint_setup(char *s) |
|---|
| 780 | +{ |
|---|
| 781 | + char *taint_str; |
|---|
| 782 | + |
|---|
| 783 | + if (!s) |
|---|
| 784 | + return -EINVAL; |
|---|
| 785 | + |
|---|
| 786 | + taint_str = strsep(&s, ","); |
|---|
| 787 | + if (kstrtoul(taint_str, 16, &panic_on_taint)) |
|---|
| 788 | + return -EINVAL; |
|---|
| 789 | + |
|---|
| 790 | + /* make sure panic_on_taint doesn't hold out-of-range TAINT flags */ |
|---|
| 791 | + panic_on_taint &= TAINT_FLAGS_MAX; |
|---|
| 792 | + |
|---|
| 793 | + if (!panic_on_taint) |
|---|
| 794 | + return -EINVAL; |
|---|
| 795 | + |
|---|
| 796 | + if (s && !strcmp(s, "nousertaint")) |
|---|
| 797 | + panic_on_taint_nousertaint = true; |
|---|
| 798 | + |
|---|
| 799 | + pr_info("panic_on_taint: bitmask=0x%lx nousertaint_mode=%sabled\n", |
|---|
| 800 | + panic_on_taint, panic_on_taint_nousertaint ? "en" : "dis"); |
|---|
| 801 | + |
|---|
| 802 | + return 0; |
|---|
| 803 | +} |
|---|
| 804 | +early_param("panic_on_taint", panic_on_taint_setup); |
|---|