* [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it
@ 2018-05-28 10:39 Li Wang
2018-05-29 7:03 ` Xiao Yang
0 siblings, 1 reply; 6+ messages in thread
From: Li Wang @ 2018-05-28 10:39 UTC (permalink / raw)
To: ltp
To fix this error:
tst_test.c:1015: INFO: Timeout per run is 0h 50m 00s
pty02.c:42: BROK: tcsetattr() failed: EINVAL
POSIX.1 General description:
Changes the attributes associated with a terminal. New attributes are
specified with a termios control structure. Programs should always
issue a tcgetattr() first, modify the desired fields, and then issue
a tcsetattr(). tcsetattr() should never be issued using a termios
structure that was not obtained using tcgetattr(). tcsetattr() should
use only a termios structure that was obtained by tcgetattr().
Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Cyril Hrubis <chrubis@suse.cz>
---
testcases/kernel/pty/pty02.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/pty/pty02.c b/testcases/kernel/pty/pty02.c
index fd3d26b..0cedca8 100644
--- a/testcases/kernel/pty/pty02.c
+++ b/testcases/kernel/pty/pty02.c
@@ -31,13 +31,18 @@
static void do_test(void)
{
- struct termios io = { .c_lflag = EXTPROC | ICANON };
+ struct termios io;
int ptmx, pts;
char c = 'A';
int nbytes;
ptmx = SAFE_OPEN("/dev/ptmx", O_WRONLY);
+ if (tcgetattr(ptmx, &io) != 0)
+ tst_brk(TBROK | TERRNO, "tcgetattr() failed");
+
+ io.c_lflag = EXTPROC | ICANON;
+
if (tcsetattr(ptmx, TCSANOW, &io) != 0)
tst_brk(TBROK | TERRNO, "tcsetattr() failed");
--
2.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it
2018-05-28 10:39 [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it Li Wang
@ 2018-05-29 7:03 ` Xiao Yang
2018-05-30 9:52 ` Li Wang
0 siblings, 1 reply; 6+ messages in thread
From: Xiao Yang @ 2018-05-29 7:03 UTC (permalink / raw)
To: ltp
Hi Li,
We found other issues by running pty02:
1) The undefined EXTPROC flag led to complier error on RHEL5/6.
2) Based on the fix, reading pts blocked on RHEL6 because we didn't write newline('\n') to ptmx,
but it worked well on RHEL7. I am not sure which kernel patch changed this behavior.
According canonical mode description:
In canonical mode:
* Input is made available line by line. An input line is available when one of the line
delimiters is typed (NL, EOL, EOL2; or EOF at the start of line). Except in the case of EOF,
the line delimiter is included in the buffer returned by read(2).
3) Based on the fix, tcsetattr(3) cannot detect invalid EXTPROC flag on RHEL5/6.
Thanks,
Xiao Yang
On 2018/05/28 18:39, Li Wang wrote:
> To fix this error:
> tst_test.c:1015: INFO: Timeout per run is 0h 50m 00s
> pty02.c:42: BROK: tcsetattr() failed: EINVAL
>
> POSIX.1 General description:
> Changes the attributes associated with a terminal. New attributes are
> specified with a termios control structure. Programs should always
> issue a tcgetattr() first, modify the desired fields, and then issue
> a tcsetattr(). tcsetattr() should never be issued using a termios
> structure that was not obtained using tcgetattr(). tcsetattr() should
> use only a termios structure that was obtained by tcgetattr().
>
> Signed-off-by: Li Wang<liwang@redhat.com>
> Cc: Eric Biggers<ebiggers@google.com>
> Cc: Cyril Hrubis<chrubis@suse.cz>
> ---
> testcases/kernel/pty/pty02.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/pty/pty02.c b/testcases/kernel/pty/pty02.c
> index fd3d26b..0cedca8 100644
> --- a/testcases/kernel/pty/pty02.c
> +++ b/testcases/kernel/pty/pty02.c
> @@ -31,13 +31,18 @@
>
> static void do_test(void)
> {
> - struct termios io = { .c_lflag = EXTPROC | ICANON };
> + struct termios io;
> int ptmx, pts;
> char c = 'A';
> int nbytes;
>
> ptmx = SAFE_OPEN("/dev/ptmx", O_WRONLY);
>
> + if (tcgetattr(ptmx,&io) != 0)
> + tst_brk(TBROK | TERRNO, "tcgetattr() failed");
> +
> + io.c_lflag = EXTPROC | ICANON;
> +
> if (tcsetattr(ptmx, TCSANOW,&io) != 0)
> tst_brk(TBROK | TERRNO, "tcsetattr() failed");
>
^ permalink raw reply [flat|nested] 6+ messages in thread* [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it
2018-05-29 7:03 ` Xiao Yang
@ 2018-05-30 9:52 ` Li Wang
2018-08-15 10:50 ` Cyril Hrubis
0 siblings, 1 reply; 6+ messages in thread
From: Li Wang @ 2018-05-30 9:52 UTC (permalink / raw)
To: ltp
Hi Xiao,
On Tue, May 29, 2018 at 3:03 PM, Xiao Yang <yangx.jy@cn.fujitsu.com> wrote:
> Hi Li,
>
> We found other issues by running pty02:
> 1) The undefined EXTPROC flag led to complier error on RHEL5/6.
> 2) Based on the fix, reading pts blocked on RHEL6 because we didn't write
> newline('\n') to ptmx,
> but it worked well on RHEL7. I am not sure which kernel patch changed
> this behavior.
> According canonical mode description:
> In canonical mode:
> * Input is made available line by line. An input line is available
> when one of the line
> delimiters is typed (NL, EOL, EOL2; or EOF at the start of
> line). Except in the case of EOF,
> the line delimiter is included in the buffer returned by read(2).
> 3) Based on the fix,
>
> tcsetattr(3) cannot detect invalid EXTPROC flag on RHEL5/6.
>
AFAIK, values of the c_lflag field describe the control of various
functions in struct termios,
but it not defined in POSIX and not supported under all Linux. So
tcsetattr() cannot detect valid EXTPROC on RHEL5/6 is acceptable I think.
Also, the ICANON has different behavior on some kind of UNIX OS too.
To solve these problem, maybe we have to define the EXTPROC in lapi, and
skip this test on kernel without that support.
That's what I can think of, if anything wrong, plz correct me.
Thanks,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180530/dd3bf31c/attachment.html>
^ permalink raw reply [flat|nested] 6+ messages in thread* [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it
2018-05-30 9:52 ` Li Wang
@ 2018-08-15 10:50 ` Cyril Hrubis
2018-08-16 4:49 ` Li Wang
0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2018-08-15 10:50 UTC (permalink / raw)
To: ltp
Hi!
I'm looking into these patches now, so if I get it right we should:
* Add EXTPROC into lapi
* Get the termios value, or it with the requested flags, then apply
tcsetattr()
* Exit the test with TCONF if we get EINVAL from tcsetattr()
Would that work for both of you?
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it
2018-08-15 10:50 ` Cyril Hrubis
@ 2018-08-16 4:49 ` Li Wang
2018-08-16 7:58 ` Li Wang
0 siblings, 1 reply; 6+ messages in thread
From: Li Wang @ 2018-08-16 4:49 UTC (permalink / raw)
To: ltp
On Wed, Aug 15, 2018 at 6:50 PM, Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
> I'm looking into these patches now, so if I get it right we should:
>
Thanks for taking care of this.
>
> * Add EXTPROC into lapi
> * Get the termios value, or it with the requested flags, then apply
> tcsetattr()
> * Exit the test with TCONF if we get EINVAL from tcsetattr()
>
> Would that work for both of you?
>
I think that's right.
But maybe we have to handle the ICANON nonuniform behavior too.
As YangXiao mentioned that, reading pts will be blocked on rhel6 forever if
we don't give
newline('\n') to ptmx, but this issue not exist on rhel7.
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180816/151d0126/attachment-0001.html>
^ permalink raw reply [flat|nested] 6+ messages in thread* [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it
2018-08-16 4:49 ` Li Wang
@ 2018-08-16 7:58 ` Li Wang
0 siblings, 0 replies; 6+ messages in thread
From: Li Wang @ 2018-08-16 7:58 UTC (permalink / raw)
To: ltp
On Thu, Aug 16, 2018 at 12:49 PM, Li Wang <liwang@redhat.com> wrote:
>
>
> On Wed, Aug 15, 2018 at 6:50 PM, Cyril Hrubis <chrubis@suse.cz> wrote:
>
>> Hi!
>> I'm looking into these patches now, so if I get it right we should:
>>
>
> Thanks for taking care of this.
>
>
>>
>> * Add EXTPROC into lapi
>> * Get the termios value, or it with the requested flags, then apply
>> tcsetattr()
>> * Exit the test with TCONF if we get EINVAL from tcsetattr()
>>
>> Would that work for both of you?
>>
>
> I think that's right.
>
> But maybe we have to handle the ICANON nonuniform behavior too.
>
> As YangXiao mentioned that, reading pts will be blocked on rhel6 forever
> if we don't give
> newline('\n') to ptmx, but this issue not exist on rhel7.
>
>
To avoid the block issue we can just add newline('\n') in the test
forwardly, I have confirmed that
won't have any impact on the bug's reproducible in bad(< kernel-4.15)
kernel.
I will resend a new patch to fix all these issues above.
--
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20180816/69b733b6/attachment.html>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-08-16 7:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-28 10:39 [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it Li Wang
2018-05-29 7:03 ` Xiao Yang
2018-05-30 9:52 ` Li Wang
2018-08-15 10:50 ` Cyril Hrubis
2018-08-16 4:49 ` Li Wang
2018-08-16 7:58 ` Li Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox