+ nmi_backtrace-use-printk_safe_flush_on_panic-when-triggering-backtraces.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: lib/nmi_backtrace,c: use printk_safe_flush_on_panic when triggering backtraces
has been added to the -mm tree.  Its filename is
     nmi_backtrace-use-printk_safe_flush_on_panic-when-triggering-backtraces.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/nmi_backtrace-use-printk_safe_flush_on_panic-when-triggering-backtraces.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/nmi_backtrace-use-printk_safe_flush_on_panic-when-triggering-backtraces.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Hoeun Ryu <hoeun.ryu@xxxxxxx>
Subject: lib/nmi_backtrace,c: use printk_safe_flush_on_panic when triggering backtraces

Use printk_safe_flush_on_panic() in nmi_trigger_cpumask_backtrace().

nmi_trigger_cpumask_backtrace() can be called in NMI context.  For example
the function is called in watchdog_overflow_callback() if the flag of
hardlockup backtrace (sysctl_hardlockup_all_cpu_backtrace) is true and
watchdog_overflow_callback() function is called in NMI context on some
architectures.

printk_safe_flush() eventually tries to lock logbuf_lock in vprintk_emit()
but the logbuf_lock can be already locked in preempted contexts (task or
irq in this case) or by other CPUs and it may cause deadlocks.

By using printk_safe_flush_on_panic() instead of printk_safe_flush() in in
nmi_trigger_cpumask_backtrace(), the backtrace triggering CPU can access
the lock safely as the lock is reinitialized before calling
printk_safe_flush().  The messages in logbuf can be corrupted if the NMI
context preempts other contexts or ignores the lock held by other CPUs
writing the buffer.

Link: http://lkml.kernel.org/r/1527232247-31693-1-git-send-email-hoeun.ryu@xxxxxxxxxxx
Signed-off-by: Hoeun Ryu <hoeun.ryu@xxxxxxx>
Cc: Petr Mladek <pmladek@xxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Philippe Ombredanne <pombredanne@xxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: "Liu, Changcheng" <changcheng.liu@xxxxxxxxx>
Cc: Hoeun Ryu <hoeun.ryu@xxxxxxx>
Cc: Kate Stewart <kstewart@xxxxxxxxxxxxxxxxxxx>
Cc: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 lib/nmi_backtrace.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff -puN lib/nmi_backtrace.c~nmi_backtrace-use-printk_safe_flush_on_panic-when-triggering-backtraces lib/nmi_backtrace.c
--- a/lib/nmi_backtrace.c~nmi_backtrace-use-printk_safe_flush_on_panic-when-triggering-backtraces
+++ a/lib/nmi_backtrace.c
@@ -78,8 +78,11 @@ void nmi_trigger_cpumask_backtrace(const
 	/*
 	 * Force flush any remote buffers that might be stuck in IRQ context
 	 * and therefore could not run their irq_work.
+	 * Call nmi-safe version of printk_safe_flush() because this function can be
+	 * called in NMI context like watchdog_overflow_callback() if
+	 * sysctl_hardlockup_all_cpu_backtrace is true.
 	 */
-	printk_safe_flush();
+	printk_safe_flush_on_panic();
 
 	clear_bit_unlock(0, &backtrace_flag);
 	put_cpu();
_

Patches currently in -mm which might be from hoeun.ryu@xxxxxxx are

nmi_backtrace-use-printk_safe_flush_on_panic-when-triggering-backtraces.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux