[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <84plca5pez.fsf@jogness.linutronix.de>
Date: Mon, 01 Sep 2025 14:33:00 +0206
From: John Ogness <john.ogness@...utronix.de>
To: Petr Mladek <pmladek@...e.com>
Cc: Marcos Paulo de Souza <mpdesouza@...e.com>, Daniel Thompson
<daniel@...cstar.com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Steven Rostedt <rostedt@...dmis.org>, Sergey Senozhatsky
<senozhatsky@...omium.org>, Jason Wessel <jason.wessel@...driver.com>,
Daniel Thompson <danielt@...nel.org>, Douglas Anderson
<dianders@...omium.org>, linux-kernel@...r.kernel.org,
kgdb-bugreport@...ts.sourceforge.net
Subject: Re: [PATCH v2 3/3] kdb: Adapt kdb_msg_write to work with NBCON
consoles
On 2025-09-01, Petr Mladek <pmladek@...e.com> wrote:
> What about the following race?
>
> kdb_printf_cpu = -1 (0xffffffff)
>
> CPU 0xff CPU 0x1
>
> panic()
>
> printk()
> nbcon_atomic_flush_pending()
> nbcon_context_try_acquire_direct()
> # load low byte of kdb_printf_cpu
> val = 0xff
>
> vkdb_printf()
> cmpxchg(&kdb_printf_cpu, ...)
> kdb_printf_cpu == 0x1
>
> # load higher byte of kdb_printf_cpu
> val = 0xff
>
> Result: CPU 0xff would be allowed to acquire the nbcon context
> because it thinks that vkdb_printf() got locked on this CPU.
>
> It is not fully artificial, see
> https://lwn.net/Articles/793253/#Load%20Tearing
>
> The above race is not critical. CPU 0x1 still could wait for CPU 0xff
> and acquire the nbcon context later.
>
> But it is something unexpected. I would feel more comfortable if
> we used the READ_ONCE() and be on the safe side.
Agreed.
John
Powered by blists - more mailing lists