lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 27 Feb 2019 10:46:55 +0100
From:   Petr Mladek <>
To:     John Ogness <>
        Peter Zijlstra <>,
        Sergey Senozhatsky <>,
        Steven Rostedt <>,
        Daniel Wang <>,
        Andrew Morton <>,
        Linus Torvalds <>,
        Greg Kroah-Hartman <>,
        Alan Cox <>,
        Jiri Slaby <>,
        Peter Feiner <>,,
        Sergey Senozhatsky <>
Subject: Re: [RFC PATCH v1 20/25] serial: 8250: implement write_atomic

On Tue 2019-02-12 15:29:58, John Ogness wrote:
> Implement a non-sleeping NMI-safe write_atomic console function in
> order to support emergency printk messages.

It uses console_atomic_lock() added in 18th patch. That one uses
prb_lock() added by 2nd patch.

Now, prb_lock() allows recursion on the same CPU. But it still needs
to wait until it is released on another CPU.

It means that it is not completely save when NMIs happen on more CPUs in
parallel, for example, when calling nmi_trigger_cpumask_backtrace().

OK, it would be safe when prb_lock() is the only lock taken
in the NMI handler. But printk() should not make such limitation
to the rest of the system. Not to say, that we would most
likely need to add a lock back into nmi_cpu_backtrace()
to keep the output sane.

Peter Zijlstra several times talked about fully lockless
consoles. He is using the early console for debugging, see
the patchset

I am not sure if it is always possible. I personally see
the following way:

   1. Make the printk ring buffer fully lockless. Then we reduce
      the problem only to console locking. And we could
      have a per-console-driver lock (no the big lock like

   2. I am afraid that we need to add some locking between CPUs
      to avoid mixing characters from directly printed messages.
      This would be safe everywhere expect in NMI. Then we could
      either risk ignoring the lock in NMI (there should be few
      messages anyway, the backtraces would get synchronized
      another way). Or we might need a compromise between
      handling console using the current owner and offload.

Best Regards,

Powered by blists - more mailing lists