From: John Ogness <john.ogness@linutronix.de>
To: sashiko-reviews@lists.linux.dev,
Andrew Murray <amurray@thegoodpenguin.co.uk>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code
Date: Fri, 03 Jul 2026 15:09:03 +0206 [thread overview]
Message-ID: <87wlvcw7i0.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <20260630170903.099D61F000E9@smtp.kernel.org>
On 2026-06-30, sashiko-bot@kernel.org wrote:
>> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c
>
> [ ... ]
>
>> @@ -3211,6 +3208,8 @@ static bool console_emit_next_record(struct console *con, bool *handover, int co
>> *handover = console_lock_spinning_disable_and_check(cookie);
>> printk_safe_exit_irqrestore(flags);
>> }
>> + printk_delay(true);
>> +
>
> [Severity: Critical]
> This isn't a bug introduced by this patch, but does the expanded delay
> create a use-after-free window for the con pointer in console_flush_all()?
>
> In console_emit_next_record(), if a lock handover occurs,
> console_lock_spinning_disable_and_check() releases the SRCU read lock.
>
> This patch inserts printk_delay(true) immediately after this lock release,
> adding a multi-millisecond busy-wait delay.
>
> During this expanded window, another CPU can unregister and free the console
> because the SRCU lock is no longer held.
>
> When console_emit_next_record() returns to console_flush_all(), it
> unconditionally dereferences con->seq before checking if a handover occurred:
>
> if (!console_emit_next_record(con, &handover, cookie))
> continue;
> printk_seq = con->seq;
>
> Could this massive delay guarantee a use-after-free if a console is
> unregistered under contention?
This is a legitimate bug report (even without this series). I will post
a patch for this.
John Ogness
next prev parent reply other threads:[~2026-07-03 13:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 16:35 [PATCH v2 0/4] printk: nbcon: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-06-30 16:35 ` [PATCH v2 1/4] printk: remove BOOT_PRINTK_DELAY config option Andrew Murray
2026-06-30 17:08 ` sashiko-bot
2026-06-30 16:35 ` [PATCH v2 2/4] printk: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-06-30 16:49 ` sashiko-bot
2026-06-30 16:35 ` [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code Andrew Murray
2026-06-30 17:09 ` sashiko-bot
2026-07-03 13:03 ` John Ogness [this message]
2026-07-03 12:57 ` John Ogness
2026-07-03 14:56 ` Benedikt Spranger
2026-06-30 16:36 ` [PATCH v2 4/4] Documentation/kernel-parameters: add/update printk_delay/boot_delay Andrew Murray
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=87wlvcw7i0.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=amurray@thegoodpenguin.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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