[PATCH 3/3] vt: order the vc_cons[] clear against console_callback()
From: Jaidev Shastri via B4 Relay
Date: Mon Sep 21 2026 - 21:31:31 EST
From: Jaidev Shastri <jaidevshastri@xxxxxx>
vc_deallocate() frees the console's screen buffer and unimap and then
clears vc_cons[currcons].d with a plain store. console_callback() reads
vc_cons[fg_console].d with a plain load.
Clear the slot with smp_store_release() and read it with
smp_load_acquire().
Found with MBCheck, a static herd7-based memory consistency checker.
Signed-off-by: Jaidev Shastri <jaidevshastri@xxxxxx>
---
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 726402167..66aa089bf 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1369,7 +1369,8 @@ struct vc_data *vc_deallocate(unsigned int currcons)
put_pid(vc->vt_pid);
vc_uniscr_set(vc, NULL);
kfree(vc->vc_screenbuf);
- vc_cons[currcons].d = NULL;
+ /* Pairs with the smp_load_acquire() in console_callback(). */
+ smp_store_release(&vc_cons[currcons].d, NULL);
if (vc->vc_saved_screen != NULL) {
kfree(vc->vc_saved_screen);
vc->vc_saved_screen = NULL;
@@ -3368,7 +3369,8 @@ static void console_callback(struct work_struct *ignored)
poke_blanked_console();
}
if (scrollback_delta) {
- struct vc_data *vc = vc_cons[fg_console].d;
+ /* Pairs with the smp_store_release() in vc_deallocate(). */
+ struct vc_data *vc = smp_load_acquire(&vc_cons[fg_console].d);
clear_selection();
if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta)
vc->vc_sw->con_scrolldelta(vc, scrollback_delta);
--
2.43.0