lists.openwall.net   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  linux-hardening  linux-cve-announce  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]
Message-ID: <CALqELGxuA+5Zqqrsw0XtXrDLua_rcD_odrYjV29fOXai+M0qaw@mail.gmail.com>
Date: Mon, 29 Sep 2025 09:39:23 +0100
From: Andrew Murray <amurray@...goodpenguin.co.uk>
To: Petr Mladek <pmladek@...e.com>
Cc: John Ogness <john.ogness@...utronix.de>, 
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Jiri Slaby <jirislaby@...nel.org>, 
	Sergey Senozhatsky <senozhatsky@...omium.org>, Steven Rostedt <rostedt@...dmis.org>, 
	Thomas Gleixner <tglx@...utronix.de>, Esben Haabendal <esben@...nix.com>, linux-serial@...r.kernel.org, 
	linux-kernel@...r.kernel.org, 
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, Arnd Bergmann <arnd@...db.de>, 
	Tony Lindgren <tony@...mide.com>, Niklas Schnelle <schnelle@...ux.ibm.com>, 
	Serge Semin <fancer.lancer@...il.com>
Subject: Re: [PATCH 2/3] printk/nbcon/panic: Allow printk kthread to sleep
 when the system is in panic

On Fri, 26 Sept 2025 at 13:50, Petr Mladek <pmladek@...e.com> wrote:
>
> The printk kthread might be running when there is a panic in progress.
> But it is not able to acquire the console ownership any longer.
>
> Prevent the desperate attempts to acquire the ownership and allow sleeping
> in panic. It would make it behave the same as when there is any CPU
> in an emergency context.
>
> Signed-off-by: Petr Mladek <pmladek@...e.com>
> ---
>  kernel/printk/internal.h | 1 +
>  kernel/printk/nbcon.c    | 6 ++++--
>  kernel/printk/printk.c   | 2 +-
>  3 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
> index ef282001f200..6e8578102fb3 100644
> --- a/kernel/printk/internal.h
> +++ b/kernel/printk/internal.h
> @@ -332,6 +332,7 @@ struct printk_message {
>         unsigned long           dropped;
>  };
>
> +bool panic_in_progress(void);
>  bool other_cpu_in_panic(void);
>  bool printk_get_next_message(struct printk_message *pmsg, u64 seq,
>                              bool is_extended, bool may_supress);
> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
> index 08b196e898cd..219ae0c8b5ed 100644
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
> @@ -1178,7 +1178,8 @@ static bool nbcon_kthread_should_wakeup(struct console *con, struct nbcon_contex
>          * where the context with a higher priority takes over the nbcon console
>          * ownership in the middle of a message.
>          */
> -       if (unlikely(atomic_read(&nbcon_cpu_emergency_cnt)))
> +       if (unlikely(atomic_read(&nbcon_cpu_emergency_cnt)) ||
> +           unlikely(panic_in_progress()))
>                 return false;
>
>         cookie = console_srcu_read_lock();
> @@ -1236,7 +1237,8 @@ static int nbcon_kthread_func(void *__console)
>                  * Block the kthread when the system is in an emergency or panic
>                  * mode. See nbcon_kthread_should_wakeup() for more details.
>                  */
> -               if (unlikely(atomic_read(&nbcon_cpu_emergency_cnt)))
> +               if (unlikely(atomic_read(&nbcon_cpu_emergency_cnt)) ||
> +                   unlikely(panic_in_progress()))
>                         goto wait_for_event;
>
>                 backlog = false;
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index ebf10352736f..174d42041594 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -345,7 +345,7 @@ static void __up_console_sem(unsigned long ip)
>  }
>  #define up_console_sem() __up_console_sem(_RET_IP_)
>
> -static bool panic_in_progress(void)
> +bool panic_in_progress(void)
>  {
>         return unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID);
>  }
> --
> 2.51.0
>

Reviewed-by: Andrew Murray <amurray@...goodpenguin.co.uk>

Thanks,

Andrew Murray

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ