Skip to content
Snippets Groups Projects
  1. Dec 02, 2022
    • Kees Cook's avatar
      panic: Introduce warn_limit · 9fc9e278
      Kees Cook authored
      
      Like oops_limit, add warn_limit for limiting the number of warnings when
      panic_on_warn is not set.
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
      Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Huang Ying <ying.huang@intel.com>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: tangmeng <tangmeng@uniontech.com>
      Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: linux-doc@vger.kernel.org
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20221117234328.594699-5-keescook@chromium.org
      9fc9e278
    • Kees Cook's avatar
      panic: Consolidate open-coded panic_on_warn checks · 79cc1ba7
      Kees Cook authored
      
      Several run-time checkers (KASAN, UBSAN, KFENCE, KCSAN, sched) roll
      their own warnings, and each check "panic_on_warn". Consolidate this
      into a single function so that future instrumentation can be added in
      a single location.
      
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Ben Segall <bsegall@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
      Cc: Valentin Schneider <vschneid@redhat.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: David Gow <davidgow@google.com>
      Cc: tangmeng <tangmeng@uniontech.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: "Paul E. McKenney" <paulmck@kernel.org>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: kasan-dev@googlegroups.com
      Cc: linux-mm@kvack.org
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarMarco Elver <elver@google.com>
      Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Link: https://lore.kernel.org/r/20221117234328.594699-4-keescook@chromium.org
      79cc1ba7
  2. Dec 01, 2022
  3. Sep 01, 2022
    • Daniel Vetter's avatar
      kernel/panic: Drop unblank_screen call · 0a64ce6e
      Daniel Vetter authored
      
      console_unblank() does this too (called in both places right after),
      and with a lot more confidence inspiring approach to locking.
      
      Reconstructing this story is very strange:
      
      In b61312d3 ("oops handling: ensure that any oops is flushed to
      the mtdoops console") it is claimed that a printk(" "); flushed out
      the console buffer, which was removed in e3e8a75d ("[PATCH]
      Extract and use wake_up_klogd()"). In todays kernels this is done way
      earlier in console_flush_on_panic with some really nasty tricks. I
      didn't bother to fully reconstruct this all, least because the call to
      bust_spinlock(0); gets moved every few years, depending upon how the
      wind blows (or well, who screamed loudest about the various issue each
      call site caused).
      
      Before that commit the only calls to console_unblank() where in s390
      arch code.
      
      The other side here is the console->unblank callback, which was
      introduced in 2.1.31 for the vt driver. Which predates the
      console_unblank() function by a lot, which was added (without users)
      in 2.4.14.3. So pretty much impossible to guess at any motivation
      here. Also afaict the vt driver is the only (and always was the only)
      console driver implementing the unblank callback, so no idea why a
      call to console_unblank() was added for the mtdooops driver - the
      action actually flushing out the console buffers is done from
      console_unlock() only.
      
      Note that as prep for the s390 users the locking was adjusted in
      2.5.22 (I couldn't figure out how to properly reference the BK commit
      from the historical git trees) from a normal semaphore to a trylock.
      
      Note that a copy of the direct unblank_screen() call was added to
      panic() in c7c3f05e ("panic: avoid deadlocks in re-entrant console
      drivers"), which partially inlined the bust_spinlocks(0); call.
      
      Long story short, I have no idea why the direct call to unblank_screen
      survived for so long (the infrastructure to do it properly existed for
      years), nor why it wasn't removed when the console_unblank() call was
      finally added. But it makes a ton more sense to finally do that than
      not - it's just better encapsulation to go through the console
      functions instead of doing a direct call, so let's dare. Plus it
      really does not make much sense to call the only unblank
      implementation there is twice, once without, and once with appropriate
      locking.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jirislaby@kernel.org>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Xuezhi Zhang <zhangxuezhi1@coolpad.com>
      Cc: Yangxi Xiang <xyangxi5@gmail.com>
      Cc: nick black <dankamongmen@gmail.com>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
      Cc: Marco Elver <elver@google.com>
      Cc: John Ogness <john.ogness@linutronix.de>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: David Gow <davidgow@google.com>
      Cc: tangmeng <tangmeng@uniontech.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Link: https://lore.kernel.org/r/20220830145004.430545-1-daniel.vetter@ffwll.ch
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a64ce6e
  4. Jul 01, 2022
  5. Jun 23, 2022
  6. Jun 15, 2022
  7. May 08, 2022
  8. Apr 22, 2022
    • John Ogness's avatar
      printk: add functions to prefer direct printing · 2bb2b7b5
      John Ogness authored
      
      Once kthread printing is available, console printing will no longer
      occur in the context of the printk caller. However, there are some
      special contexts where it is desirable for the printk caller to
      directly print out kernel messages. Using pr_flush() to wait for
      threaded printers is only possible if the caller is in a sleepable
      context and the kthreads are active. That is not always the case.
      
      Introduce printk_prefer_direct_enter() and printk_prefer_direct_exit()
      functions to explicitly (and globally) activate/deactivate preferred
      direct console printing. The term "direct console printing" refers to
      printing to all enabled consoles from the context of the printk
      caller. The term "prefer" is used because this type of printing is
      only best effort. If the console is currently locked or other
      printers are already actively printing, the printk caller will need
      to rely on the other contexts to handle the printing.
      
      This preferred direct printing is how all printing has been handled
      until now (unless it was explicitly deferred).
      
      When kthread printing is introduced, there may be some unanticipated
      problems due to kthreads being unable to flush important messages.
      In order to minimize such risks, preferred direct printing is
      activated for the primary important messages when the system
      experiences general types of major errors. These are:
      
       - emergency reboot/shutdown
       - cpu and rcu stalls
       - hard and soft lockups
       - hung tasks
       - warn
       - sysrq
      
      Note that since kthread printing does not yet exist, no behavior
      changes result from this commit. This is only implementing the
      counter and marking the various places where preferred direct
      printing is active.
      
      Signed-off-by: default avatarJohn Ogness <john.ogness@linutronix.de>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Acked-by: Paul E. McKenney <paulmck@kernel.org> # for RCU
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Link: https://lore.kernel.org/r/20220421212250.565456-13-john.ogness@linutronix.de
      2bb2b7b5
  9. Apr 06, 2022
    • tangmeng's avatar
      kernel/panic: move panic sysctls to its own file · 9df91869
      tangmeng authored
      
      kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
      dishes, this makes it very difficult to maintain.
      
      To help with this maintenance let's start by moving sysctls to places
      where they actually belong.  The proc sysctl maintainers do not want to
      know what sysctl knobs you wish to add for your own piece of code, we
      just care about the core logic.
      
      All filesystem syctls now get reviewed by fs folks. This commit
      follows the commit of fs, move the oops_all_cpu_backtrace sysctl to
      its own file, kernel/panic.c.
      
      Signed-off-by: default avatartangmeng <tangmeng@uniontech.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      9df91869
  10. Mar 24, 2022
  11. Jan 20, 2022
  12. Jul 26, 2021
    • John Ogness's avatar
      printk: remove safe buffers · 93d102f0
      John Ogness authored
      
      With @logbuf_lock removed, the high level printk functions for
      storing messages are lockless. Messages can be stored from any
      context, so there is no need for the NMI and safe buffers anymore.
      Remove the NMI and safe buffers.
      
      Although the safe buffers are removed, the NMI and safe context
      tracking is still in place. In these contexts, store the message
      immediately but still use irq_work to defer the console printing.
      
      Since printk recursion tracking is in place, safe context tracking
      for most of printk is not needed. Remove it. Only safe context
      tracking relating to the console and console_owner locks is left
      in place. This is because the console and console_owner locks are
      needed for the actual printing.
      
      Signed-off-by: default avatarJohn Ogness <john.ogness@linutronix.de>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Link: https://lore.kernel.org/r/20210715193359.25946-4-john.ogness@linutronix.de
      93d102f0
  13. Jul 01, 2021
  14. Nov 14, 2020
    • Christophe Leroy's avatar
      panic: don't dump stack twice on warn · 2f31ad64
      Christophe Leroy authored
      
      Before commit 3f388f28 ("panic: dump registers on panic_on_warn"),
      __warn() was calling show_regs() when regs was not NULL, and show_stack()
      otherwise.
      
      After that commit, show_stack() is called regardless of whether
      show_regs() has been called or not, leading to duplicated Call Trace:
      
        ------------[ cut here ]------------
        WARNING: CPU: 0 PID: 1 at arch/powerpc/mm/nohash/8xx.c:186 mmu_mark_initmem_nx+0x24/0x94
        CPU: 0 PID: 1 Comm: swapper Not tainted 5.10.0-rc2-s3k-dev-01375-gf46ec0d3ecbd-dirty #4092
        NIP:  c00128b4 LR: c0010228 CTR: 00000000
        REGS: c9023e40 TRAP: 0700   Not tainted  (5.10.0-rc2-s3k-dev-01375-gf46ec0d3ecbd-dirty)
        MSR:  00029032 <EE,ME,IR,DR,RI>  CR: 24000424  XER: 00000000
      
        GPR00: c0010228 c9023ef8 c2100000 0074c000 ffffffff 00000000 c2151000 c07b3880
        GPR08: ff000900 0074c000 c8000000 c33b53a8 24000822 00000000 c0003a20 00000000
        GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
        GPR24: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00800000
        NIP [c00128b4] mmu_mark_initmem_nx+0x24/0x94
        LR [c0010228] free_initmem+0x20/0x58
        Call Trace:
          free_initmem+0x20/0x58
          kernel_init+0x1c/0x114
          ret_from_kernel_thread+0x14/0x1c
        Instruction dump:
        7d291850 7d234b78 4e800020 9421ffe0 7c0802a6 bfc10018 3fe0c060 3bff0000
        3fff4080 3bffffff 90010024 57ff0010 <0fe00000> 392001cd 7c3e0b78 953e0008
        CPU: 0 PID: 1 Comm: swapper Not tainted 5.10.0-rc2-s3k-dev-01375-gf46ec0d3ecbd-dirty #4092
        Call Trace:
          __warn+0x8c/0xd8 (unreliable)
          report_bug+0x11c/0x154
          program_check_exception+0x1dc/0x6e0
          ret_from_except_full+0x0/0x4
        --- interrupt: 700 at mmu_mark_initmem_nx+0x24/0x94
            LR = free_initmem+0x20/0x58
          free_initmem+0x20/0x58
          kernel_init+0x1c/0x114
          ret_from_kernel_thread+0x14/0x1c
        ---[ end trace 31702cd2a9570752 ]---
      
      Only call show_stack() when regs is NULL.
      
      Fixes: 3f388f28 ("panic: dump registers on panic_on_warn")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Link: https://lkml.kernel.org/r/e8c055458b080707f1bc1a98ff8bea79d0cec445.1604748361.git.christophe.leroy@csgroup.eu
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2f31ad64
  15. Oct 16, 2020
  16. Aug 12, 2020
  17. Jun 11, 2020
  18. Jun 08, 2020
    • Guilherme G. Piccoli's avatar
      panic: add sysctl to dump all CPUs backtraces on oops event · 60c958d8
      Guilherme G. Piccoli authored
      
      Usually when the kernel reaches an oops condition, it's a point of no
      return; in case not enough debug information is available in the kernel
      splat, one of the last resorts would be to collect a kernel crash dump
      and analyze it.  The problem with this approach is that in order to
      collect the dump, a panic is required (to kexec-load the crash kernel).
      When in an environment of multiple virtual machines, users may prefer to
      try living with the oops, at least until being able to properly shutdown
      their VMs / finish their important tasks.
      
      This patch implements a way to collect a bit more debug details when an
      oops event is reached, by printing all the CPUs backtraces through the
      usage of NMIs (on architectures that support that).  The sysctl added
      (and documented) here was called "oops_all_cpu_backtrace", and when set
      will (as the name suggests) dump all CPUs backtraces.
      
      Far from ideal, this may be the last option though for users that for
      some reason cannot panic on oops.  Most of times oopses are clear enough
      to indicate the kernel portion that must be investigated, but in virtual
      environments it's possible to observe hypervisor/KVM issues that could
      lead to oopses shown in other guests CPUs (like virtual APIC crashes).
      This patch hence aims to help debug such complex issues without
      resorting to kdump.
      
      Signed-off-by: default avatarGuilherme G. Piccoli <gpiccoli@canonical.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Luis Chamberlain <mcgrof@kernel.org>
      Cc: Iurii Zaikin <yzaikin@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Link: http://lkml.kernel.org/r/20200327224116.21030-1-gpiccoli@canonical.com
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      60c958d8
    • Rafael Aquini's avatar
      kernel: add panic_on_taint · db38d5c1
      Rafael Aquini authored
      
      Analogously to the introduction of panic_on_warn, this patch introduces
      a kernel option named panic_on_taint in order to provide a simple and
      generic way to stop execution and catch a coredump when the kernel gets
      tainted by any given flag.
      
      This is useful for debugging sessions as it avoids having to rebuild the
      kernel to explicitly add calls to panic() into the code sites that
      introduce the taint flags of interest.
      
      For instance, if one is interested in proceeding with a post-mortem
      analysis at the point a given code path is hitting a bad page (i.e.
      unaccount_page_cache_page(), or slab_bug()), a coredump can be collected
      by rebooting the kernel with 'panic_on_taint=0x20' amended to the
      command line.
      
      Another, perhaps less frequent, use for this option would be as a means
      for assuring a security policy case where only a subset of taints, or no
      single taint (in paranoid mode), is allowed for the running system.  The
      optional switch 'nousertaint' is handy in this particular scenario, as
      it will avoid userspace induced crashes by writes to sysctl interface
      /proc/sys/kernel/tainted causing false positive hits for such policies.
      
      [akpm@linux-foundation.org: tweak kernel-parameters.txt wording]
      
      Suggested-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarRafael Aquini <aquini@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Adrian Bunk <bunk@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Laura Abbott <labbott@redhat.com>
      Cc: Jeff Mahoney <jeffm@suse.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Takashi Iwai <tiwai@suse.de>
      Link: http://lkml.kernel.org/r/20200515175502.146720-1-aquini@redhat.com
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      db38d5c1
  19. Nov 25, 2019
  20. Oct 07, 2019
    • Will Deacon's avatar
      panic: ensure preemption is disabled during panic() · 20bb759a
      Will Deacon authored
      Calling 'panic()' on a kernel with CONFIG_PREEMPT=y can leave the
      calling CPU in an infinite loop, but with interrupts and preemption
      enabled.  From this state, userspace can continue to be scheduled,
      despite the system being "dead" as far as the kernel is concerned.
      
      This is easily reproducible on arm64 when booting with "nosmp" on the
      command line; a couple of shell scripts print out a periodic "Ping"
      message whilst another triggers a crash by writing to
      /proc/sysrq-trigger:
      
        | sysrq: Trigger a crash
        | Kernel panic - not syncing: sysrq triggered crash
        | CPU: 0 PID: 1 Comm: init Not tainted 5.2.15 #1
        | Hardware name: linux,dummy-virt (DT)
        | Call trace:
        |  dump_backtrace+0x0/0x148
        |  show_stack+0x14/0x20
        |  dump_stack+0xa0/0xc4
        |  panic+0x140/0x32c
        |  sysrq_handle_reboot+0x0/0x20
        |  __handle_sysrq+0x124/0x190
        |  write_sysrq_trigger+0x64/0x88
        |  proc_reg_write+0x60/0xa8
        |  __vfs_write+0x18/0x40
        |  vfs_write+0xa4/0x1b8
        |  ksys_write+0x64/0xf0
        |  __arm64_sys_write+0x14/0x20
        |  el0_svc_common.constprop.0+0xb0/0x168
        |  el0_svc_handler+0x28/0x78
        |  el0_svc+0x8/0xc
        | Kernel Offset: disabled
        | CPU features: 0x0002,24002004
        | Memory Limit: none
        | ---[ end Kernel panic - not syncing: sysrq triggered crash ]---
        |  Ping 2!
        |  Ping 1!
        |  Ping 1!
        |  Ping 2!
      
      The issue can also be triggered on x86 kernels if CONFIG_SMP=n,
      otherwise local interrupts are disabled in 'smp_send_stop()'.
      
      Disable preemption in 'panic()' before re-enabling interrupts.
      
      Link: http://lkml.kernel.org/r/20191002123538.22609-1-will@kernel.org
      Link: https://lore.kernel.org/r/BX1W47JXPMR8.58IYW53H6M5N@dragonstone
      
      
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Reported-by: default avatarXogium <contact@xogium.me>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      20bb759a
  21. Sep 26, 2019
    • Kees Cook's avatar
      bug: consolidate __WARN_FLAGS usage · 2da1ead4
      Kees Cook authored
      Instead of having separate tests for __WARN_FLAGS, merge the two #ifdef
      blocks and replace the synonym WANT_WARN_ON_SLOWPATH macro.
      
      Link: http://lkml.kernel.org/r/20190819234111.9019-7-keescook@chromium.org
      
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Drew Davenport <ddavenport@chromium.org>
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2da1ead4
    • Kees Cook's avatar
      bug: lift "cut here" out of __warn() · d38aba49
      Kees Cook authored
      In preparation for cleaning up "cut here", move the "cut here" logic up
      out of __warn() and into callers that pass non-NULL args.  For anyone
      looking closely, there are two callers that pass NULL args: one already
      explicitly prints "cut here".  The remaining case is covered by how a WARN
      is built, which will be cleaned up in the next patch.
      
      Link: http://lkml.kernel.org/r/20190819234111.9019-5-keescook@chromium.org
      
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Drew Davenport <ddavenport@chromium.org>
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d38aba49
    • Kees Cook's avatar
      bug: consolidate warn_slowpath_fmt() usage · f2f84b05
      Kees Cook authored
      Instead of having a separate helper for no printk output, just consolidate
      the logic into warn_slowpath_fmt().
      
      Link: http://lkml.kernel.org/r/20190819234111.9019-4-keescook@chromium.org
      
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Drew Davenport <ddavenport@chromium.org>
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f2f84b05
    • Kees Cook's avatar
      bug: refactor away warn_slowpath_fmt_taint() · ee871133
      Kees Cook authored
      Patch series "Clean up WARN() "cut here" handling", v2.
      
      Christophe Leroy noticed that the fix for missing "cut here" in the WARN()
      case was adding explicit printk() calls instead of teaching the exception
      handler to add it.  This refactors the bug/warn infrastructure to pass
      this information as a new BUGFLAG.
      
      Longer details repeated from the last patch in the series:
      
      bug: move WARN_ON() "cut here" into exception handler
      
      The original cleanup of "cut here" missed the WARN_ON() case (that does
      not have a printk message), which was fixed recently by adding an explicit
      printk of "cut here".  This had the downside of adding a printk() to every
      WARN_ON() caller, which reduces the utility of using an instruction
      exception to streamline the resulting code.  By making this a new BUGFLAG,
      all of these can be removed and "cut here" can be handled by the exception
      handler.
      
      This was very pronounced on PowerPC, but the effect can be seen on x86 as
      well.  The resulting text size of a defconfig build shows some small
      savings from this patch:
      
         text    data     bss     dec     hex filename
      19691167        5134320 1646664 26472151        193eed7 vmlinux.before
      19676362        5134260 1663048 26473670        193f4c6 vmlinux.after
      
      This change also opens the door for creating something like BUG_MSG(),
      where a custom printk() before issuing BUG(), without confusing the "cut
      here" line.
      
      This patch (of 7):
      
      There's no reason to have specialized helpers for passing the warn taint
      down to __warn().  Consolidate and refactor helper macros, removing
      __WARN_printf() and warn_slowpath_fmt_taint().
      
      Link: http://lkml.kernel.org/r/20190819234111.9019-2-keescook@chromium.org
      
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Drew Davenport <ddavenport@chromium.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ee871133
    • Douglas Anderson's avatar
      kgdb: don't use a notifier to enter kgdb at panic; call directly · 7d92bda2
      Douglas Anderson authored
      Right now kgdb/kdb hooks up to debug panics by registering for the panic
      notifier.  This works OK except that it means that kgdb/kdb gets called
      _after_ the CPUs in the system are taken offline.  That means that if
      anything important was happening on those CPUs (like something that might
      have contributed to the panic) you can't debug them.
      
      Specifically I ran into a case where I got a panic because a task was
      "blocked for more than 120 seconds" which was detected on CPU 2.  I nicely
      got shown stack traces in the kernel log for all CPUs including CPU 0,
      which was running 'PID: 111 Comm: kworker/0:1H' and was in the middle of
      __mmc_switch().
      
      I then ended up at the kdb prompt where switched over to kgdb to try to
      look at local variables of the process on CPU 0.  I found that I couldn't.
      Digging more, I found that I had no info on any tasks running on CPUs
      other than CPU 2 and that asking kdb for help showed me "Error: no saved
      data for this cpu".  This was because all the CPUs were offline.
      
      Let's move the entry of kdb/kgdb to a direct call from panic() and stop
      using the generic notifier.  Putting a direct call in allows us to order
      things more properly and it also doesn't seem like we're breaking any
      abstractions by calling into the debugger from the panic function.
      
      Daniel said:
      
      : This patch changes the way kdump and kgdb interact with each other.
      : However it would seem rather odd to have both tools simultaneously armed
      : and, even if they were, the user still has the option to use panic_timeout
      : to force a kdump to happen.  Thus I think the change of order is
      : acceptable.
      
      Link: http://lkml.kernel.org/r/20190703170354.217312-1-dianders@chromium.org
      
      
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
      Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7d92bda2
  22. Jul 15, 2019
  23. May 21, 2019
  24. May 18, 2019
  25. May 15, 2019
  26. May 02, 2019
    • Martin Schwidefsky's avatar
      s390: simplify disabled_wait · 98587c2d
      Martin Schwidefsky authored
      
      The disabled_wait() function uses its argument as the PSW address when
      it stops the CPU with a wait PSW that is disabled for interrupts.
      The different callers sometimes use a specific number like 0xdeadbeef
      to indicate a specific failure, the early boot code uses 0 and some
      other calls sites use __builtin_return_address(0).
      
      At the time a dump is created the current PSW and the registers of a
      CPU are written to lowcore to make them avaiable to the dump analysis
      tool. For a CPU stopped with disabled_wait the PSW and the registers
      do not really make sense together, the PSW address does not point to
      the function the registers belong to.
      
      Simplify disabled_wait() by using _THIS_IP_ for the PSW address and
      drop the argument to the function.
      
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      98587c2d
  27. Mar 08, 2019
Loading