[PATCH 1/1] linux/termios: clear c_cflag & CIBAUD for non-split speed
Florian Weimer
fweimer@redhat.com
Mon Sep 8 15:43:34 GMT 2025
* H. Peter Anvin:
> After getting more experience with the various broken direct-to-ioctl
> termios2 hacks using Fedora 43 beta, I have found a fair number of
> cases where the software would fail to set, or clear CIBAUD for
> non-split-speed operation.
>
> Therefore, I think it will help improve compatibility to clear the
> CIBAUD flags for non-split-speed operation, rather than having it
> equal CIBAUD.
>
> This change is in tcsetattr() rather than
> ___termios2_canonicalize_speeds(), as it should not be run for
> tcgetattr(); that would break split speed support for the legacy
> interface versions of cfgetispeed() and cfsetispeed().
>
> When writing the code that went into glibc 2.42 I had considered this
> issue, and had to make an educated guess which way would be more
> likely to break fewer things. Unfortunately, it appears I guessed
> wrong.
Can we get a test case for this?
> + /*
> + * For compatibility with broken workaround hacks for the lack
> + * of arbitrary speed support in previous versions of glibc,
> + * clear CIBAUD if only one speed is used.
> + *
> + * This is also necessary for the Alpha compatibility hack below.
> + */
> + if (k_termios.c_ospeed == k_termios.c_ispeed)
> + k_termios.c_cflag &= ~CIBAUD;
> +
> + /*
> + * Choose the proper ioctl number to invoke.
> + *
> + * Alpha got TCSETS2 late (Linux 4.20), but has the same structure
> + * format, and it only needs TCSETS2 if either it needs to use
> + * __BOTHER or split speed. All other architectures have TCSETS2 as
> + * far back as the current glibc supports. Calling TCSETS with
> + * __BOTHER causes unpredictable results on old Alpha kernels and
> + * could even crash them.
> + */
The glibc comment style doesn't use leading *, and the comment text
starts on the first line of the comment.
Does it fix bug 33340?
Thanks,
Florian
More information about the Libc-alpha
mailing list