Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maximilian Immanuel Brandtner" <maxbr@linux.ibm.com>
Cc: linux-s390@vger.kernel.org,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH v2 2/2] s390/sclp: Implement resize for sclp-vt220 console
Date: Tue, 22 Sep 2026 10:08:53 +0000	[thread overview]
Message-ID: <20260922100853.6D5471F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922095903.1595794-3-maxbr@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] s390/sclp: lost terminal resize event due to TOCTOU race
--

commit 66ee01928776071bac37719344cd6f2a8ad2ae89
Author: Maximilian Immanuel Brandtner <maxbr@linux.ibm.com>

s390/sclp: Implement resize for sclp-vt220 console

This commit adds support for sclp vt220 resize events to enable
host-initiated terminal resizing when using the sclp-vt220 console. This
allows QEMU to dynamically resize the console.

> diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
> index 7c168a66e4afe..a5a9ac1b1fe07 100644
> --- a/drivers/s390/char/sclp_vt220.c
> +++ b/drivers/s390/char/sclp_vt220.c

[ ... ]

> @@ -552,12 +603,15 @@ static void sclp_vt220_receiver_fn(struct evbuf_header *evbuf)
>  static int
>  sclp_vt220_open(struct tty_struct *tty, struct file *filp)
>  {
> +	struct winsize ws;
> +
>  	if (tty->count == 1) {
> +		spin_lock_irq(&sclp_vt220_lock);
> +		ws = sclp_vt220_winsize;
> +		spin_unlock_irq(&sclp_vt220_lock);
> +
>  		tty_port_tty_set(&sclp_vt220_port, tty);
> -		if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
> -			tty->winsize.ws_row = 24;
> -			tty->winsize.ws_col = 80;
> -		}
> +		tty_do_resize(tty, &ws);

[Severity: Medium]
Could this sequence result in a lost terminal resize event due to a TOCTOU
race?

If a host resize event arrives exactly after sclp_vt220_open() has read the
cached window size into ws, but before it attaches the tty to the port:

sclp_vt220_open()
    ws = sclp_vt220_winsize;
    // Host resize event arrives here, updates sclp_vt220_winsize
    // and schedules sclp_vt220_resize_work

The resize worker could execute immediately:

sclp_vt220_resize()
    tty = tty_port_tty_get(&sclp_vt220_port);
    if (!tty)
        return; // Worker aborts silently because tty is not set yet

Then sclp_vt220_open() continues:

sclp_vt220_open()
    tty_port_tty_set(&sclp_vt220_port, tty);
    tty_do_resize(tty, &ws);

Would this cause the terminal to be unconditionally overwritten with the stale
cached size, permanently desynchronizing it from the emulator's size until
manually resized?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260922095903.1595794-1-maxbr@linux.ibm.com?part=2

      reply	other threads:[~2026-09-22 10:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  9:59 [PATCH v2 0/2] s390/sclp: Resize for sclp-vt220 console Maximilian Immanuel Brandtner
2026-09-22  9:59 ` [PATCH v2 1/2] s390/sclp: Introduce dedicated sclp-vt220 event buffer type Maximilian Immanuel Brandtner
2026-09-22 10:08   ` sashiko-bot
2026-09-22  9:59 ` [PATCH v2 2/2] s390/sclp: Implement resize for sclp-vt220 console Maximilian Immanuel Brandtner
2026-09-22 10:08   ` 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=20260922100853.6D5471F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=maxbr@linux.ibm.com \
    --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