mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: jaidevshastri@vt.edu
Cc: Jiri Slaby <jirislaby@kernel.org>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH 1/3] vt: order the fg_console switch against vt_console_print()
Date: Wed, 23 Sep 2026 14:50:52 +0200	[thread overview]
Message-ID: <2026092324-unlocked-step-9443@gregkh> (raw)
In-Reply-To: <20260921-mb-vt-v1-1-71b7990c26c1@vt.edu>

On Mon, Sep 21, 2026 at 09:27:14PM -0400, Jaidev Shastri via B4 Relay wrote:
> From: Jaidev Shastri <jaidevshastri@vt.edu>
> 
> redraw_screen() switches fg_console with a plain store once the new
> console's state is set up. vt_console_print(), the printk console
> callback, indexes vc_cons[] with fg_console before it takes
> printing_lock.
> 
> Store the new index with smp_store_release() and read it with
> smp_load_acquire(), so that the printk path cannot reach the slot before
> the console it denotes is complete.
> 
> Found with MBCheck, a static herd7-based memory consistency checker.
> 
> Signed-off-by: Jaidev Shastri <jaidevshastri@vt.edu>
> ---
>  drivers/tty/vt/vt.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 57edf3749..3abbd6cf9 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -973,7 +973,8 @@ void redraw_screen(struct vc_data *vc, int is_switch)
>  		if (!con_is_visible(vc))
>  			redraw = 1;
>  		*vc->vc_display_fg = vc;
> -		fg_console = vc->vc_num;
> +		/* Pairs with the smp_load_acquire() in vt_console_print(). */
> +		smp_store_release(&fg_console, vc->vc_num);

Using these functions are almost always wrong.  Fix things properly, do
not pepper these types of calls all over the kernel, that way lies
madness.

greg k-h

  reply	other threads:[~2026-09-23 12:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  1:27 [PATCH 0/3] vt: make the console_lock ordering explicit for three variables Jaidev Shastri via B4 Relay
2026-09-22  1:27 ` [PATCH 1/3] vt: order the fg_console switch against vt_console_print() Jaidev Shastri via B4 Relay
2026-09-23 12:50   ` Greg Kroah-Hartman [this message]
2026-09-22  1:27 ` [PATCH 2/3] vt: order console_blanked between blanking and unblanking Jaidev Shastri via B4 Relay
2026-09-22  1:27 ` [PATCH 3/3] vt: order the vc_cons[] clear against console_callback() Jaidev Shastri via B4 Relay

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=2026092324-unlocked-step-9443@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=jaidevshastri@vt.edu \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.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

all inboxes | Powered by JetHome®