diff mbox series

[1/2] pty07: Resize console to the same size as before

Message ID 20220519121056.1181-1-mdoucha@suse.cz
State Accepted
Headers show
Series [1/2] pty07: Resize console to the same size as before | expand

Commit Message

Martin Doucha May 19, 2022, 12:10 p.m. UTC
Resizing console to 1x1 breaks some QA automation systems. Keep the original
console dimensions throughout the test.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/kernel/pty/pty07.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Petr Vorel May 20, 2022, 9:05 a.m. UTC | #1
Hi all,

> Resizing console to 1x1 breaks some QA automation systems. Keep the original
> console dimensions throughout the test.

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Martin, thanks a lot for fixing.

LGTM. If you don't mind, I'd merge this patchset later today to get into the
release.

Kind regards,
Petr
Cyril Hrubis May 20, 2022, 9:26 a.m. UTC | #2
Hi!
> Resizing console to 1x1 breaks some QA automation systems. Keep the original
> console dimensions throughout the test.

Good catch.

I guess that the actual size we pass to VT_RESIZEX does not matter when
we attempt to trigger the race.

Reviwed-by: Cyril Hrubis <chrubis@suse.cz>
Martin Doucha May 20, 2022, 9:33 a.m. UTC | #3
On 20. 05. 22 11:26, Cyril Hrubis wrote:
> I guess that the actual size we pass to VT_RESIZEX does not matter when
> we attempt to trigger the race.

I've tested this on SLE-15SP1 GM kernel which is older than the fix and
this version still triggers the crash. Technically we could even pass
all zeroes which would simply leave all console parameters unchanged and
it'd still work because the ioctl implementation sets a flag in the
freed memory anyway. But that behavior might change in the future so
I've decided to just set the rows and cols to the values queried from
kernel.
Petr Vorel May 20, 2022, 11:50 a.m. UTC | #4
> On 20. 05. 22 11:26, Cyril Hrubis wrote:
> > I guess that the actual size we pass to VT_RESIZEX does not matter when
> > we attempt to trigger the race.

> I've tested this on SLE-15SP1 GM kernel which is older than the fix and
> this version still triggers the crash. Technically we could even pass
> all zeroes which would simply leave all console parameters unchanged and
> it'd still work because the ioctl implementation sets a flag in the
> freed memory anyway. But that behavior might change in the future so
> I've decided to just set the rows and cols to the values queried from
> kernel.

+1. Merged this one, thank you!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/pty/pty07.c b/testcases/kernel/pty/pty07.c
index c63b71c89..ae600b692 100644
--- a/testcases/kernel/pty/pty07.c
+++ b/testcases/kernel/pty/pty07.c
@@ -40,6 +40,7 @@  static int test_tty_port = 8;
 static int fd = -1;
 static struct tst_fzsync_pair fzp;
 
+static struct vt_consize consize;
 static unsigned short vt_active;
 
 static void *open_close(void *unused)
@@ -60,13 +61,12 @@  static void *open_close(void *unused)
 
 static void do_test(void)
 {
-	struct vt_consize sz = { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 };
 
 	tst_fzsync_pair_reset(&fzp, open_close);
 
 	while (tst_fzsync_run_a(&fzp)) {
 		tst_fzsync_start_race_a(&fzp);
-		ioctl(fd, VT_RESIZEX, &sz);
+		ioctl(fd, VT_RESIZEX, &consize);
 		tst_fzsync_end_race_a(&fzp);
 		if (tst_taint_check()) {
 			tst_res(TFAIL, "Kernel is buggy");
@@ -79,6 +79,7 @@  static void do_test(void)
 static void setup(void)
 {
 	struct vt_stat stat;
+	struct winsize wsize;
 
 	sprintf(tty_path, "/dev/tty%d", test_tty_port);
 	if (access(tty_path, F_OK))
@@ -90,6 +91,9 @@  static void setup(void)
 
 	tst_res(TINFO, "Saving active console %i", vt_active);
 
+	SAFE_IOCTL(fd, TIOCGWINSZ, &wsize);
+	consize.v_rows = wsize.ws_row;
+	consize.v_cols = wsize.ws_col;
 	tst_fzsync_pair_init(&fzp);
 }