pty/pty02: new test for hang involving EXTPROC|ICANON terminal mode
PATCH 1/1 pty/pty02: new test for hang involving EXTPROC|ICANON terminal mode
From: Eric Biggers <[email protected]>
Test for a bug in the kernel's tty layer where an infinite loop could occur if the EXTPROC and ICANON terminal modes were combined. This bug was found by the syzkaller fuzzer and was fixed in v4.15.
--- runtest/pty | 1 + testcases/kernel/pty/.gitignore | 1 + testcases/kernel/pty/pty02.c | 58 +++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 testcases/kernel/pty/pty02.c
runtest/pty +1 -0
@@ -1,5 +1,6 @@ #DESCRIPTION:Terminal type stress pty01 pty01 +pty02 pty02 ptem01 ptem01 hangup01 hangup01
testcases/kernel/pty/.gitignore +1 -0
@@ -1,3 +1,4 @@ /hangup01 /ptem01 /pty01 +/pty02
testcases/kernel/pty/pty02.c new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.17.0
PATCH 1/1 pty/pty02: new test for hang involving EXTPROC|ICANON terminal mode
Hi!
testcases/kernel/pty/pty02.c line 52
Quoted 2 lines
testcases/kernel/pty/pty02.c new file +2
-0+tst_res (TINFO ,"Calling FIONREAD, this will hang in n_tty_ioctl() if the bug is present..." ); +SAFE_IOCTL (pts,FIONREAD , &nbytes);
I've added two SAFE_CLOSE() here so that the test works with the -i 1000 as well and pushed, thanks.
Quoted 2 lines
testcases/kernel/pty/pty02.c new file +2
-0+tst_res (TPASS ,"Got to the end without hanging" ); +}
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 pty/pty02: new test for hang involving EXTPROC|ICANON terminal mode
In reply to Eric Biggers----- Original Message -----
Quoted 9 lines
+ * Regression test for commit
966031f340185("n_tty: fix EXTPROC vs ICANON
+ * interaction with TIOCINQ (aka FIONREAD)"). The test reproduces a hang
+ * (infinite loop in the kernel) after a pseudoterminal is put in both canonical
+ * (ICANON) and external processing (EXTPROC) mode, some data is written to the
+ * master and read from the slave, and the FIONREAD ioctl is called on the
+ * slave. This is simplified from a syzkaller-generated reproducer.
+ */
testcases/kernel/pty/pty02.c line 34
Quoted 9 lines
testcases/kernel/pty/pty02.c new file +9
-0+ +#include <stdlib.h> +#include <termio.h> + +#include "tst_test.h" + +static void do_test (void ) +{ +struct termios io = { .c_lflag =EXTPROC |ICANON };
Hi,
I'm running into compilation errors on older distros (RHEL5/6) with this test:
pty02.c: In function ‘do_test’:
pty02.c:34: error: ‘EXTPROC’ undeclared (first use in this function) pty02.c:34: error: (Each undeclared identifier is reported only once pty02.c:34: error: for each function it appears in.)
make: *** [pty02] Error 1
We should probably ifdef the test, because adding define to LAPI still makes it fail:
tst_test.c:1015: INFO: Timeout per run is 0h 05m 00s pty02.c:44: BROK: tcsetattr() failed: EINVAL
Regards,
Jan
PATCH 1/1 pty/pty02: new test for hang involving EXTPROC|ICANON terminal mode
Hi Jan,
Quoted 31 lines · Jan Stancek
----- Original Message -----
Quoted 1 line
+ * Regression test for commit
966031f340185("n_tty: fix EXTPROC vsICANON
Quoted 1 line
+ * interaction with TIOCINQ (aka FIONREAD)"). The test reproduces a
hang
Quoted 3 lines
+ * (infinite loop in the kernel) after a pseudoterminal is put in both canonical
+ * (ICANON) and external processing (EXTPROC) mode, some data iswritten to
Quoted 2 lines
the
+ * master and read from the slave, and the FIONREAD ioctl is called onthe
testcases/kernel/pty/pty02.c line 34
Quoted 11 lines
+ * slave. This is simplified from a syzkaller-generated reproducer.
+ */testcases/kernel/pty/pty02.c new file +9
-0+ +#include <stdlib.h> +#include <termio.h> + +#include "tst_test.h" + +static void do_test (void ) +{ +struct termios io = { .c_lflag =EXTPROC |ICANON };Hi,
I'm running into compilation errors on older distros (RHEL5/6) with this test:
Quoted 9 lines
pty02.c: In function ‘do_test’:
pty02.c:34: error: ‘EXTPROC’ undeclared (first use in this function) pty02.c:34: error: (Each undeclared identifier is reported only once pty02.c:34: error: for each function it appears in.)
make: *** [pty02] Error 1We should probably ifdef the test, because adding define to LAPI still makes it fail:
Xiao and I have also noticed this, beside the undefine issue, there are still
other problems in pty02 test.
The discuss is here:
http://lists.linux.it/pipermail/ltp/2018-May/008253.html
Quoted 10 lines
tst_test.c:1015: INFO: Timeout per run is 0h 05m 00s pty02.c:44: BROK:
tcsetattr()failed: EINVALRegards,
Jan--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20180601/bb2bbfb8/attachment-0001.html>
PATCH 1/1 pty/pty02: new test for hang involving EXTPROC|ICANON terminal mode
In reply to Jan StancekHi!
Quoted 9 lines
I'm running into compilation errors on older distros (RHEL5/6) with this test:
pty02.c: In function ???do_test???:
pty02.c:34: error: ???EXTPROC??? undeclared (first use in this function) pty02.c:34: error: (Each undeclared identifier is reported only once pty02.c:34: error: for each function it appears in.)
make: *** [pty02] Error 1
Quoted 5 lines
We should probably ifdef the test, because adding define to LAPI still makes it fail:
tst_test.c:1015: INFO: Timeout per run is 0h 05m 00s pty02.c:44: BROK:
tcsetattr()failed: EINVAL
Or we can return TCONF on EINVAL since EINVAL means unsupported value anyway...
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 pty/pty02: new test for hang involving EXTPROC|ICANON terminal mode
Quoted 10 lines · Cyril Hrubis
Hi!
Quoted 9 lines
I'm running into compilation errors on older distros (RHEL5/6) with this test:
pty02.c: In function ???do_test???:
pty02.c:34: error: ???EXTPROC??? undeclared (first use in this function) pty02.c:34: error: (Each undeclared identifier is reported only once pty02.c:34: error: for each function it appears in.)
make: *** [pty02] Error 1
Quoted 9 lines
Quoted 5 lines
We should probably ifdef the test, because adding define to LAPI still makes it fail:
tst_test.c:1015: INFO: Timeout per run is 0h 05m 00s pty02.c:44: BROK:
tcsetattr()failed: EINVALOr we can return TCONF on EINVAL since EINVAL means unsupported value anyway...
​Maybe at least we should do more try before skipping it when getting EINVAL. Because sometimes it also fails with EINVAL when using a termios structure that was not obtained using tcgeaatr(). tcsetattr() should use only a termios structure that was obtained by tcgetattr().
pty02.c works fine on mainline kernel-v4.17 after applying this:
http://lists.linux.it/pipermail/ltp/2018-May/008253.html
What do you think?
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20180605/936fccfa/attachment.html>