The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Longxing Li <coregee2000@gmail.com>
Cc: syzkaller@googlegroups.com, jirislaby@kernel.org,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [Kernel Bug] INFO: task hung in show_cons_active
Date: Tue, 30 Jun 2026 16:20:37 +0200	[thread overview]
Message-ID: <2026063012-equal-scroll-080b@gregkh> (raw)
In-Reply-To: <CAHPqNmxJfSC73Liogt=vr=YR_wX0VFTAMphejesodE=85Aeuvg@mail.gmail.com>

On Tue, Jun 30, 2026 at 08:30:39PM +0800, Longxing Li wrote:
>  Dear maintainers,
> 
> Here's my fix and patch of the bug.
> 
> Fix Summary:
> 
>   The deadlock occurs because unregister_console() holds console_list_lock
>   while __pr_flush() blocks on console_sem. show_cons_active() has the same
>   lock -> sem ordering (holds mutex, waits for sem), creating a potential
>   ABBA when any printer path needs the mutex.
> 
>   Fix: restructure unregister_console() into three phases:
> 
>     Phase 1 (list lock):   Disable console (clear CON_ENABLED).
>     Phase 2 (NO lock):     __pr_flush() waits for pending output.
>                            Safe because console is already disabled.
>     Phase 3 (list lock):   Remove from list + cleanup.
> 
>   This ensures __pr_flush() is never called while holding console_list_lock,
>   eliminating the lock inversion.
> 
>   Full patch is as follows and also attached in the link.
> 
> =====================================================
> From: Longxing Li <coregee2000@gmail.com>
> Date: Tue, 30 Jun 2026
> Subject: [PATCH] printk: fix potential deadlock in unregister_console()
> 
> unregister_console() holds console_list_lock while calling __pr_flush(),
> which blocks on console_sem. show_cons_active() holds console_mutex (the
> same lock) while also waiting for console_sem. This creates a potential
> ABBA deadlock when any console output path needs console_mutex.
> 
> Fix by restructuring unregister_console() so __pr_flush() is called WITHOUT
> holding console_list_lock:
> 
>   Phase 1 (list lock):    Disable console (clear CON_ENABLED).
>   Phase 2 (no lock):      __pr_flush() drains pending output.
>   Phase 3 (list lock):    Remove from list + cleanup.
> 
> Reported-by: Longxing Li

You are the author, noneed for a reported-by

> Suggested-by: Greg KH <gregkh@linuxfoundation.org>

I did?

> Signed-off-by: Longxing Li <coregee2000@gmail.com>
> ---
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -4235,28 +4235,15 @@
>   struct console *c;
>   int res;
> 
>   lockdep_assert_console_list_lock_held();
> 
> - con_printk(KERN_INFO, console, "disabled\n");
> -

Patch is corruupted and can not be applied :(

      reply	other threads:[~2026-06-30 14:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09 11:49 [Kernel Bug] INFO: task hung in show_cons_active Longxing Li
2026-06-09 12:10 ` Greg KH
2026-06-22 13:53   ` Longxing Li
2026-06-22 14:02     ` Greg KH
2026-06-30 12:30       ` Longxing Li
2026-06-30 14:20         ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2026063012-equal-scroll-080b@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=coregee2000@gmail.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=syzkaller@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox