From nobody Thu Sep 24 17:02:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4835B37269A; Tue, 22 Sep 2026 01:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040440; cv=none; b=gFoJJ1mwOrHdqt5dy9+1axE1mRyqhDB2JCojwzTl6j1CpIM9Phe+820SweljOC4O27YHuH6KCoW65M025xtowlRb4sb+fa7sSWnB/Nx8umOxjv3D+LlskeX0Qrs964N66jZdPEpdZQXWjpzHUxSWyK3JhFcr58UjUEflMZLSDcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040440; c=relaxed/simple; bh=k6PVgik6pJNUc/FKNT3s50C9vrgLpeG7Wr/Mobsafz4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OhGJzhtDod2qtJ/xVqOGHuSnXYECBCSDNiZDooDo2khhD6l0+wfSjlbW2dWLo/Lbv+H/ZzpQIzBYw/pvjtnt5XPONEbkkWb150yFluxCzPq6lsDeg0VcZGPlN3fPfH5qKg3ns5Ey+T/VEu2DjthzcqFcKIlfngK/tr/5yr3Y9tw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=khRHjdk0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="khRHjdk0" Received: by smtp.kernel.org (Postfix) with ESMTPS id E1F85C2BCFC; Tue, 22 Sep 2026 01:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1790040439; bh=k6PVgik6pJNUc/FKNT3s50C9vrgLpeG7Wr/Mobsafz4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=khRHjdk0sgCDQ5qo8S6U9G59INoG9jIsnUGOFKWVgGYDYAWD7gwzZPQIFvKBanOQ4 bUSJ1vKgqNZGSSVZOI5mxKCksbknXBlDRhGetU+c0eP3SXNjdYwlVUjsQeLknu9Sm5 SXSAAJzIFXiRaePF9R5Fc/z+pVcnCV+wrJ8Ase9Hysi38P+zjNi/P9yFkhZU0e2MfZ Bdx6vm3u8c4xcHQlICrikCCOn8k6zAGDRwJfMo2HIFje9FznUrsone2rQr/XGx7L13 /FoiBzavWayjKA1KSRUnTVugJLofJhBwzggTkfaqt3aIQaR85l8TDc7KUPbgkJxvo2 Or+pOUQnrlJVg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4DDDC982FC; Tue, 22 Sep 2026 01:27:19 +0000 (UTC) From: Jaidev Shastri via B4 Relay Date: Mon, 21 Sep 2026 21:27:14 -0400 Subject: [PATCH 1/3] vt: order the fg_console switch against vt_console_print() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260921-mb-vt-v1-1-71b7990c26c1@vt.edu> References: <20260921-mb-vt-v1-0-71b7990c26c1@vt.edu> In-Reply-To: <20260921-mb-vt-v1-0-71b7990c26c1@vt.edu> To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Jaidev Shastri X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790040439; l=1552; i=jaidevshastri@vt.edu; s=20260921; h=from:subject:message-id; bh=t3w49a+qfe39Dk2oPAqqzDMPS4oixsoA4+DLTHcPzWQ=; b=gREHg8oU0b+2dX6YOKClDz3gXZ9k/R+gxQhItKMJW2tnsE2PJTZ9ViDqHLlkcePX7de3mQ0bE iSvsIHnZs09BQ4GN1h2RKFDPWKvx2K7i80tCVWpsRFySn/Gr+nJmEiw X-Developer-Key: i=jaidevshastri@vt.edu; a=ed25519; pk=J7+xYJRlTPds+pv5hbqFFRqGCpDeJDzmZT1ggRwj7/0= X-Endpoint-Received: by B4 Relay for jaidevshastri@vt.edu/20260921 with auth_id=1044 X-Original-From: Jaidev Shastri Reply-To: jaidevshastri@vt.edu From: Jaidev Shastri 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 --- 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 =3D 1; *vc->vc_display_fg =3D vc; - fg_console =3D vc->vc_num; + /* Pairs with the smp_load_acquire() in vt_console_print(). */ + smp_store_release(&fg_console, vc->vc_num); hide_cursor(old_vc); if (!con_is_visible(old_vc)) { save_screen(old_vc); @@ -3447,7 +3448,8 @@ int vt_kmsg_redirect(int new) =20 static void vt_console_print(struct console *co, const char *b, unsigned c= ount) { - struct vc_data *vc =3D vc_cons[fg_console].d; + /* Pairs with the smp_store_release() in redraw_screen(). */ + struct vc_data *vc =3D vc_cons[smp_load_acquire(&fg_console)].d; unsigned char c; static DEFINE_SPINLOCK(printing_lock); const ushort *start; --=20 2.43.0 From nobody Thu Sep 24 17:02:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 389A736E466; Tue, 22 Sep 2026 01:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040440; cv=none; b=ep7vSc5DAwylEOiOIJib5dKjs2AQxAgGV0h1JBauvClBX+WEllUNuPuqcGSYC8MFsT5kcMgs2EsmGaZlimTRCeZTc7IMr88NknxLKRxBjXIe8IG7Bnz17od/pgdP707lW2soJ4hh0dcrEZdwXNOoX5mn6XivQQ7Wb4Q5SZ7v8mQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040440; c=relaxed/simple; bh=ERsm8yne7OE0oXzLqAtSUDwW8UVIyoGFIy32VZoQ+Fw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aG4e8GS5xm9m2DJpgJHLlKvoxxijT6rg7iZTTNZaxhYzpIgyVsbW+vBItQ7bqG6Z7Q3RTC4k96GaeB8CvU/k63J1sBPp4olINmZFYN0jVdtvIcEstd0m3qMXpZH8XR6v6xWdh45ZWsRrumqP0HmSb0EwSOR41hf+ZYhqhmqQlgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TvXMqkQ4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TvXMqkQ4" Received: by smtp.kernel.org (Postfix) with ESMTPS id DE891C2BCF7; Tue, 22 Sep 2026 01:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1790040439; bh=ERsm8yne7OE0oXzLqAtSUDwW8UVIyoGFIy32VZoQ+Fw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=TvXMqkQ4I5N3zRvAmnuW3YnlelWWFnylmKXnMRTjBuB+jDX3rQCavSNqE7bTBmVLW kvmHuV1DyvHY2nlcZ8gWvOqZNj+u8FOlUa/JZBVHF9JAgLeFNN97YKhy8OCx2R+bzd guQk60MOwAxv5N+luBiWRWmJ87rIZIMfBeMP2S8Y7F0Xa+3xPDQmgWSWwzjgxXja3t kVMhM1/WECrFd/ai3UNx976Mr/DarJ5KykPusIyC9OgJJDOrB3a7+PnYfhuZ5UAQ/0 ic/zym8+S9QOWy3JQVz0GGPmep7ADKW8b+mSwCuvkBfk2wCKBu/mrRWLr0NkOJ+Oc2 EHNhX24Qb6GeQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0481C982FF; Tue, 22 Sep 2026 01:27:19 +0000 (UTC) From: Jaidev Shastri via B4 Relay Date: Mon, 21 Sep 2026 21:27:15 -0400 Subject: [PATCH 2/3] vt: order console_blanked between blanking and unblanking Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260921-mb-vt-v1-2-71b7990c26c1@vt.edu> References: <20260921-mb-vt-v1-0-71b7990c26c1@vt.edu> In-Reply-To: <20260921-mb-vt-v1-0-71b7990c26c1@vt.edu> To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Jaidev Shastri X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790040439; l=2137; i=jaidevshastri@vt.edu; s=20260921; h=from:subject:message-id; bh=kWl2d17xXxJJ8s7vN2eawZUFTwGBKmwR9FBaN+SterI=; b=puDUrOD62COIIKtRmhFJsjOVKQExiVWpSnLNaL38LxHzsnr0wLXrLhGLReZv6IpXKzqnU31R5 BtS4vK8wEvZDCMqRemObqmiOpf4yhBv++LdnAqTOpEznhl1WXEyHGC8 X-Developer-Key: i=jaidevshastri@vt.edu; a=ed25519; pk=J7+xYJRlTPds+pv5hbqFFRqGCpDeJDzmZT1ggRwj7/0= X-Endpoint-Received: by B4 Relay for jaidevshastri@vt.edu/20260921 with auth_id=1044 X-Original-From: Jaidev Shastri Reply-To: jaidevshastri@vt.edu From: Jaidev Shastri do_blank_screen() records the blanked console in console_blanked with a plain store, after blank_state and the console state have been updated. do_unblank_screen() tests console_blanked with a plain load before it uses that state. Store it 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 --- drivers/tty/vt/vt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 3abbd6cf9..726402167 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4683,7 +4683,8 @@ void do_blank_screen(int entering_gfx) hide_cursor(vc); save_screen(vc); vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1); - console_blanked =3D fg_console + 1; + /* Pairs with the smp_load_acquire() in do_unblank_screen(). */ + smp_store_release(&console_blanked, fg_console + 1); blank_state =3D blank_off; set_origin(vc); return; @@ -4693,7 +4694,8 @@ void do_blank_screen(int entering_gfx) =20 /* don't blank graphics */ if (vc->vc_mode !=3D KD_TEXT) { - console_blanked =3D fg_console + 1; + /* Pairs with the smp_load_acquire() in do_unblank_screen(). */ + smp_store_release(&console_blanked, fg_console + 1); return; } =20 @@ -4705,7 +4707,8 @@ void do_blank_screen(int entering_gfx) /* In case we need to reset origin, blanking hook returns 1 */ i =3D vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_VSYNC_SUSPEND : (vesa_blank_mode + 1), 0); - console_blanked =3D fg_console + 1; + /* Pairs with the smp_load_acquire() in do_unblank_screen(). */ + smp_store_release(&console_blanked, fg_console + 1); if (i) set_origin(vc); =20 @@ -4737,7 +4740,8 @@ void do_unblank_screen(int leaving_gfx) WARN_CONSOLE_UNLOCKED(); =20 ignore_poke =3D 0; - if (!console_blanked) + /* Pairs with the smp_store_release() in do_blank_screen(). */ + if (!smp_load_acquire(&console_blanked)) return; if (!vc_cons_allocated(fg_console)) { /* impossible */ --=20 2.43.0 From nobody Thu Sep 24 17:02:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 495DD374745; Tue, 22 Sep 2026 01:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040440; cv=none; b=LOsq4kftCiMM9OQi+a1Ls9p8nhefEv1Kbenj4RpQ3NKV1CIceFuq/EU0QMAfR7AqhRgFM2Nig936QBrWSACKComZ9YYJl+L9a9RnpPIMabDvXR5RpoVxZYyasbJtaqfVgiXgsef9RwJLjgjujZ7gkL3rEPO44QnJf7IGczg3Br0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790040440; c=relaxed/simple; bh=7eA8feO7whFlNxG6uPOTpe0nEmA+jk1VeeJHVW+2aXY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e9ASsiW6gdc2c1hr+JAYKnrQcchvvSSvgv+E+q/ucI60FeUnBrL41REQeHZQfEIj/5VBxNR1tKBWXMJkyayhePImrn8J4OG6ichOGX4Zo3wJxuAe5J6h3N4GIV7ltd/PeZ0gjiQGyPtFsEeM9YxroNrU5VmMlc84r6iRRvsH3v0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wwe9dTu/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wwe9dTu/" Received: by smtp.kernel.org (Postfix) with ESMTPS id E8988C2BCF6; Tue, 22 Sep 2026 01:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1790040439; bh=7eA8feO7whFlNxG6uPOTpe0nEmA+jk1VeeJHVW+2aXY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Wwe9dTu/swGLGsZ2wZf2Qscxqta7e5/RjPS9NmfOXUOq9EIKsnzwe80PmmB0OVvRu 81utNjLQzfKGSYlJBraCMOETC+MD1C97NH3cGEf5ZETC9TfIiTZFwqaM5b1i1ymAPl eGviwYzXb7N4A8nMXU1ejv5ga5CHUdzaFk+lx5MFqv+4RW/sy8v+Tor5YiYj6G4P7H wC94lTJlo1D1P4SRkVPiRnkV/OjVQ0l7qdkTeF3i9WJ84rM5kg3d5C0XBFtlkSHaiJ +yOdpDy+CB6yG7dY8qHIKbACaxAzd9lXcp4GTmgQkBy5gdyeyHOmiyblUwHOuRegt/ phpjo87JUdCVA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC921C982FE; Tue, 22 Sep 2026 01:27:19 +0000 (UTC) From: Jaidev Shastri via B4 Relay Date: Mon, 21 Sep 2026 21:27:16 -0400 Subject: [PATCH 3/3] vt: order the vc_cons[] clear against console_callback() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260921-mb-vt-v1-3-71b7990c26c1@vt.edu> References: <20260921-mb-vt-v1-0-71b7990c26c1@vt.edu> In-Reply-To: <20260921-mb-vt-v1-0-71b7990c26c1@vt.edu> To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Jaidev Shastri X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790040439; l=1520; i=jaidevshastri@vt.edu; s=20260921; h=from:subject:message-id; bh=n064wC3Fdt35/BuS9qHKcc8lilea0y9ChG1ooSTcVBk=; b=Cyt/0YbOQE8rFx7wYIzQ8vqzJBMtdzlsL/BBKnz9w9AzPzpGW72AsY5HktLYXJ+9ocVbqB4jJ XjrdM5P/lGsB+HepieQVYNFM54YzSadx3wlB5bHuRj/i0NXCxQAGUno X-Developer-Key: i=jaidevshastri@vt.edu; a=ed25519; pk=J7+xYJRlTPds+pv5hbqFFRqGCpDeJDzmZT1ggRwj7/0= X-Endpoint-Received: by B4 Relay for jaidevshastri@vt.edu/20260921 with auth_id=1044 X-Original-From: Jaidev Shastri Reply-To: jaidevshastri@vt.edu From: Jaidev Shastri 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 --- 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 =3D NULL; + /* Pairs with the smp_load_acquire() in console_callback(). */ + smp_store_release(&vc_cons[currcons].d, NULL); if (vc->vc_saved_screen !=3D NULL) { kfree(vc->vc_saved_screen); vc->vc_saved_screen =3D NULL; @@ -3368,7 +3369,8 @@ static void console_callback(struct work_struct *igno= red) poke_blanked_console(); } if (scrollback_delta) { - struct vc_data *vc =3D vc_cons[fg_console].d; + /* Pairs with the smp_store_release() in vc_deallocate(). */ + struct vc_data *vc =3D smp_load_acquire(&vc_cons[fg_console].d); clear_selection(); if (vc->vc_mode =3D=3D KD_TEXT && vc->vc_sw->con_scrolldelta) vc->vc_sw->con_scrolldelta(vc, scrollback_delta); --=20 2.43.0