Merge tag 'printk-for-6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux

Pull printk fix from Petr Mladek:

 - Prevent softlockup by restoring IRQs in atomic flush after each
   record

* tag 'printk-for-6.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux:
  printk/nbcon: Restore IRQ in atomic flush after each emitted record
This commit is contained in:
Linus Torvalds
2026-01-16 09:46:59 -08:00

View File

@@ -1557,18 +1557,27 @@ static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq)
ctxt->allow_unsafe_takeover = nbcon_allow_unsafe_takeover();
while (nbcon_seq_read(con) < stop_seq) {
if (!nbcon_context_try_acquire(ctxt, false))
return -EPERM;
/*
* nbcon_emit_next_record() returns false when the console was
* handed over or taken over. In both cases the context is no
* longer valid.
* Atomic flushing does not use console driver synchronization
* (i.e. it does not hold the port lock for uart consoles).
* Therefore IRQs must be disabled to avoid being interrupted
* and then calling into a driver that will deadlock trying
* to acquire console ownership.
*/
if (!nbcon_emit_next_record(&wctxt, true))
return -EAGAIN;
scoped_guard(irqsave) {
if (!nbcon_context_try_acquire(ctxt, false))
return -EPERM;
nbcon_context_release(ctxt);
/*
* nbcon_emit_next_record() returns false when
* the console was handed over or taken over.
* In both cases the context is no longer valid.
*/
if (!nbcon_emit_next_record(&wctxt, true))
return -EAGAIN;
nbcon_context_release(ctxt);
}
if (!ctxt->backlog) {
/* Are there reserved but not yet finalized records? */
@@ -1595,22 +1604,11 @@ static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq)
static void nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq)
{
struct console_flush_type ft;
unsigned long flags;
int err;
again:
/*
* Atomic flushing does not use console driver synchronization (i.e.
* it does not hold the port lock for uart consoles). Therefore IRQs
* must be disabled to avoid being interrupted and then calling into
* a driver that will deadlock trying to acquire console ownership.
*/
local_irq_save(flags);
err = __nbcon_atomic_flush_pending_con(con, stop_seq);
local_irq_restore(flags);
/*
* If there was a new owner (-EPERM, -EAGAIN), that context is
* responsible for completing.