[opensuse-kernel] question on tcsetattr
we have in glibc a patch that reverts this commit: 2003-02-20 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Remove obsolete patch to check for system call errors. I don't have a comment why the patch is needed. Both Fedora and us have the patch in their current glibc versions. Can any of you comment on whether we still need this with recent (2.6.32 or newer) kernels or not? Andreas Index: sysdeps/unix/sysv/linux/tcsetattr.c =================================================================== --- sysdeps/unix/sysv/linux/tcsetattr.c.orig +++ sysdeps/unix/sysv/linux/tcsetattr.c @@ -49,6 +49,7 @@ tcsetattr (fd, optional_actions, termios { struct __kernel_termios k_termios; unsigned long int cmd; + int retval; switch (optional_actions) { @@ -80,6 +81,35 @@ tcsetattr (fd, optional_actions, termios memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0], __KERNEL_NCCS * sizeof (cc_t)); - return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios); + retval = INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios); + + if (retval == 0 && cmd == TCSETS) + { + /* The Linux kernel has a bug which silently ignore the invalid + c_cflag on pty. We have to check it here. */ + int save = errno; + retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios); + if (retval) + { + /* We cannot verify if the setting is ok. We don't return + an error (?). */ + __set_errno (save); + retval = 0; + } + else if ((termios_p->c_cflag & (PARENB | CREAD)) + != (k_termios.c_cflag & (PARENB | CREAD)) + || ((termios_p->c_cflag & CSIZE) + && ((termios_p->c_cflag & CSIZE) + != (k_termios.c_cflag & CSIZE)))) + { + /* It looks like the Linux kernel silently changed the + PARENB/CREAD/CSIZE bits in c_cflag. Report it as an + error. */ + __set_errno (EINVAL); + retval = -1; + } + } + } + + return retval; -- Andreas Jaeger, Program Manager openSUSE aj@{novell.com,suse.com,opensuse.org} Twitter/Identica: jaegerandi SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
Hi; Am Thu 26 May 2011 08:53:01 PM CEST schrieb Andreas Jaeger <aj@novell.com>:
we have in glibc a patch that reverts this commit: 2003-02-20 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Remove obsolete patch to check for system call errors.
I don't have a comment why the patch is needed. Both Fedora and us have the patch in their current glibc versions.
Can any of you comment on whether we still need this with recent (2.6.32 or newer) kernels or not?
Andreas
Index: sysdeps/unix/sysv/linux/tcsetattr.c =================================================================== --- sysdeps/unix/sysv/linux/tcsetattr.c.orig +++ sysdeps/unix/sysv/linux/tcsetattr.c @@ -49,6 +49,7 @@ tcsetattr (fd, optional_actions, termios { struct __kernel_termios k_termios; unsigned long int cmd; + int retval;
switch (optional_actions) { @@ -80,6 +81,35 @@ tcsetattr (fd, optional_actions, termios memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0], __KERNEL_NCCS * sizeof (cc_t));
- return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios); + retval = INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios); + + if (retval == 0 && cmd == TCSETS) + { + /* The Linux kernel has a bug which silently ignore the invalid + c_cflag on pty. We have to check it here. */ + int save = errno; + retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios); + if (retval) + { + /* We cannot verify if the setting is ok. We don't return + an error (?). */ + __set_errno (save); + retval = 0; + } + else if ((termios_p->c_cflag & (PARENB | CREAD)) + != (k_termios.c_cflag & (PARENB | CREAD)) + || ((termios_p->c_cflag & CSIZE) + && ((termios_p->c_cflag & CSIZE) + != (k_termios.c_cflag & CSIZE)))) + { + /* It looks like the Linux kernel silently changed the + PARENB/CREAD/CSIZE bits in c_cflag. Report it as an + error. */ + __set_errno (EINVAL); + retval = -1; + } + } + } + + return retval;
Looks like someone else wondered the same in 2003 [0] , Roland[1] and Ulrich [2] agrees that the patch is unneeded and possibly wrong. Regards, ismail - who is lurking in the -kernel list [0] http://sources.redhat.com/ml/libc-alpha/2003-02/msg00117.html [1] http://sources.redhat.com/ml/libc-alpha/2003-02/msg00130.html [2] http://sources.redhat.com/ml/libc-alpha/2003-02/msg00161.html -- Ismail Dönmez - openSUSE Booster SUSE LINUX Products GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
On Thursday, May 26, 2011 09:09:54 PM Ismail Doenmez wrote:
Hi;
Am Thu 26 May 2011 08:53:01 PM CEST schrieb Andreas Jaeger <aj@novell.com>:
we have in glibc a patch that reverts this commit: 2003-02-20 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Remove obsolete patch to check for system call errors.
I don't have a comment why the patch is needed. Both Fedora and us have the patch in their current glibc versions.
Can any of you comment on whether we still need this with recent (2.6.32 or newer) kernels or not?
Andreas
Index: sysdeps/unix/sysv/linux/tcsetattr.c =================================================================== --- sysdeps/unix/sysv/linux/tcsetattr.c.orig +++ sysdeps/unix/sysv/linux/tcsetattr.c @@ -49,6 +49,7 @@ tcsetattr (fd, optional_actions, termios
{
struct __kernel_termios k_termios; unsigned long int cmd;
+ int retval;
switch (optional_actions)
{
@@ -80,6 +81,35 @@ tcsetattr (fd, optional_actions, termios
memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0],
__KERNEL_NCCS * sizeof (cc_t));
- return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios); + retval = INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios); + + if (retval == 0 && cmd == TCSETS) + { + /* The Linux kernel has a bug which silently ignore the invalid + c_cflag on pty. We have to check it here. */ + int save = errno; + retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios); + if (retval) + { + /* We cannot verify if the setting is ok. We don't return + an error (?). */ + __set_errno (save); + retval = 0; + } + else if ((termios_p->c_cflag & (PARENB | CREAD)) + != (k_termios.c_cflag & (PARENB | CREAD)) + || ((termios_p->c_cflag & CSIZE) + && ((termios_p->c_cflag & CSIZE) + != (k_termios.c_cflag & CSIZE)))) + { + /* It looks like the Linux kernel silently changed the + PARENB/CREAD/CSIZE bits in c_cflag. Report it as an + error. */ + __set_errno (EINVAL); + retval = -1; + } + } + } + + return retval;
Looks like someone else wondered the same in 2003 [0] , Roland[1] and Ulrich [2] agrees that the patch is unneeded and possibly wrong.
I wonder why it's still enabled in our and Fedora's tree then - without a comment in the changelog ;-( Ok, disabled now and see what breaks ;) thanks, Andreas
Regards, ismail - who is lurking in the -kernel list
[0] http://sources.redhat.com/ml/libc-alpha/2003-02/msg00117.html [1] http://sources.redhat.com/ml/libc-alpha/2003-02/msg00130.html [2] http://sources.redhat.com/ml/libc-alpha/2003-02/msg00161.html
-- Andreas Jaeger, Program Manager openSUSE aj@{novell.com,suse.com,opensuse.org} Twitter/Identica: jaegerandi SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
participants (2)
-
Andreas Jaeger
-
Ismail Doenmez