From: sashiko-bot@kernel.org
To: "Jaidev Shastri" <jaidevshastri@vt.edu>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH 3/3] vt: order the vc_cons[] clear against console_callback()
Date: Tue, 22 Sep 2026 01:38:10 +0000 [thread overview]
Message-ID: <20260922013810.6D7B71F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921-mb-vt-v1-3-71b7990c26c1@vt.edu>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] tty: vt: unnecessary and flawed lockless synchronization under console_lock
--
commit 49da38d5b190153cd048046d7ba8249893ec05f7
Author: Jaidev Shastri <jaidevshastri@vt.edu>
vt: order the vc_cons[] clear against console_callback()
This commit replaces plain stores and loads of vc_cons[].d with
smp_store_release() and smp_load_acquire() in vc_deallocate() and
console_callback(). It aims to resolve a static memory consistency checker
warning.
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 7264021672baa..66aa089bff43a 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);
[Severity: Medium]
Are these memory barriers necessary? Both vc_deallocate() and
console_callback() execute strictly under console_lock. vc_deallocate()
asserts this via WARN_CONSOLE_UNLOCKED(), and console_callback() acquires
it via guard(console_lock)() at the top of the function.
Furthermore, does this unpublish the pointer too late for a lockless reader?
Since it is unpublished after freeing resources like vc_screenbuf, wouldn't
this create a use-after-free window for any hypothetical lockless reader?
> 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);
[Severity: Medium]
Since console_lock is held here, is this acquire barrier needed?
Also, doesn't console_callback() still contain plain loads of this same
variable that bypass this acquire barrier? For example, earlier in the
function:
hide_cursor(vc_cons[fg_console].d);
And later in the function:
notify_update(vc_cons[fg_console].d);
This appears to leave the lockless synchronization incomplete if it were
actually needed.
> clear_selection();
> if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta)
> vc->vc_sw->con_scrolldelta(vc, scrollback_delta);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921-mb-vt-v1-0-71b7990c26c1@vt.edu?part=3
prev parent reply other threads:[~2026-09-22 1:38 UTC|newest]
Thread overview: 12+ 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
2026-09-22 1:27 ` 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
2026-09-22 1:27 ` Jaidev Shastri via B4 Relay
2026-09-22 1:45 ` sashiko-bot
2026-09-23 12:50 ` Greg Kroah-Hartman
2026-09-22 1:27 ` [PATCH 2/3] vt: order console_blanked between blanking and unblanking Jaidev Shastri
2026-09-22 1:27 ` Jaidev Shastri via B4 Relay
2026-09-22 1:38 ` sashiko-bot
2026-09-22 1:27 ` [PATCH 3/3] vt: order the vc_cons[] clear against console_callback() Jaidev Shastri
2026-09-22 1:27 ` Jaidev Shastri via B4 Relay
2026-09-22 1:38 ` sashiko-bot [this message]
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=20260922013810.6D7B71F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jaidevshastri@vt.edu \
--cc=linux-serial@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.