The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH printk] printk: Fix possible console use-after-free
Date: Tue, 7 Jul 2026 15:05:00 +0200	[thread overview]
Message-ID: <akz5fElnOdUFe2fA@pathway.suse.cz> (raw)
In-Reply-To: <20260703141521.202813-1-john.ogness@linutronix.de>

On Fri 2026-07-03 16:20:31, John Ogness wrote:
> When emitting a record via legacy printing, it is possible that a handover
> to another legacy printing context occurs. When a context has performed a
> handover, the console SRCU read lock is released and the pointer to the
> console struct might now be invalid. Therefore, after calling
> nbcon_legacy_emit_next_record() or console_emit_next_record(), it is
> necessary to check if a handover occurred _before_ further @con usage.
> 
> Sashiko pointed out that console_flush_one_record() was not doing this.
> 
> In console_flush_one_record(), after emitting a record, move the further
> usage of @con after the handover check.
> 
> Fixes: c158834b223f ("printk: nbcon: Use nbcon consoles in console_flush_all()")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/lkml/20260630170903.099D61F000E9@smtp.kernel.org
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Great catch!

The fix it straightfoward:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Now, the question is whether I should rush it into 7.2-rcX or
it might wait for 7.3.

IMHO, it can wait for 7.3 because it is very hard to trigger.
All console drivers have "struct console" defined in the static .data
section. It can disappear only when it is added as a module and
the module gets removed. Which is a rather complicated and long
process.

Best Regards,
Petr

  reply	other threads:[~2026-07-07 13:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 14:14 [PATCH printk] printk: Fix possible console use-after-free John Ogness
2026-07-07 13:05 ` Petr Mladek [this message]
2026-07-07 13:20   ` John Ogness
2026-07-09 13:59 ` Petr Mladek

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=akz5fElnOdUFe2fA@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sashiko-bot@kernel.org \
    --cc=senozhatsky@chromium.org \
    /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