• Kees Cook's avatar
    lib/bug.c: exclude non-BUG/WARN exceptions from report_bug() · 1b4cfe3c
    Kees Cook authored
    Commit b8347c21 ("x86/debug: Handle warnings before the notifier
    chain, to fix KGDB crash") changed the ordering of fixups, and did not
    take into account the case of x86 processing non-WARN() and non-BUG()
    exceptions.  This would lead to output of a false BUG line with no other
    information.
    
    In the case of a refcount exception, it would be immediately followed by
    the refcount WARN(), producing very strange double-"cut here":
    
      lkdtm: attempting bad refcount_inc() overflow
      ------------[ cut here ]------------
      Kernel BUG at 0000000065f29de5 [verbose debug info unavailable]
      ------------[ cut here ]------------
      refcount_t overflow at lkdtm_REFCOUNT_INC_OVERFLOW+0x6b/0x90 in cat[3065], uid/euid: 0/0
      WARNING: CPU: 0 PID: 3065 at kernel/panic.c:657 refcount_error_report+0x9a/0xa4
      ...
    
    In the prior ordering, exceptions were searched first:
    
       do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
       ...
                    if (f...
    1b4cfe3c
bug.c 5.48 KB