Bug 205033 - CREAD ignored by almost all USB serial drivers
Summary: CREAD ignored by almost all USB serial drivers
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: USB (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Greg Kroah-Hartman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-28 19:00 UTC by Harald Welte
Modified: 2019-09-29 08:46 UTC (History)
0 users

See Also:
Kernel Version: 5.2.0
Tree: Mainline
Regression: No


Attachments

Description Harald Welte 2019-09-28 19:00:34 UTC
It seems that a lot of Linux kernel serial device drivers are ignoring the CREAD setting of termios.c_cflag.

The man page is quite clear:

       CREAD  Enable receiver.

The glibc man page at 
https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter/libc_17.html states:

"Macro: tcflag_t CREAD - If this bit is set, input can be read from the terminal. Otherwise, input is discarded when it arrives."

When I mask this bit, I'm still receiving input characters, at least on a pl2303 USB UART.  Looking at the source code of drivers/usb/serial/, the *only* driver appearing to respect CREAD is digi_acceleport.c.  All others seem to ignore it.  To the contrary, most drivers in drivers/tty/serial seem to implement it.

In absence of low-level support in individual drivers to actually disable the receiver in hardware, I would have at least expected the core tty/serial layer to drop/discard any characters received by the hardware while CREAD is not set.  But that also doesn't appear to be the case.

What's even more worrying is that the tcsetattr() call succeeds, i.e. it is a silent error.  I would expect the kernel to either implement the functionalty ino one way or another, or simply return tcsetattr() with an error if an unsupported combination (i.e. CFLAG not set) is configured.

This is not a theoretical issue.  Anyone implementing a half-duplex protocol with shared Rx and Tx line will face the same issue.
Comment 1 Greg Kroah-Hartman 2019-09-28 20:40:49 UTC
On Sat, Sep 28, 2019 at 07:00:34PM +0000, bugzilla-daemon@bugzilla.kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=205033
> 
>             Bug ID: 205033
>            Summary: CREAD ignored by almost all USB serial drivers
>            Product: Drivers
>            Version: 2.5
>     Kernel Version: 5.2.0


All USB bugs should be sent to the linux-usb@vger.kernel.org mailing
list, and not entered into bugzilla.  Please bring this issue up there,
if it is still a problem in the latest kernel release.
Comment 2 Harald Welte 2019-09-29 08:46:36 UTC
(In reply to Greg Kroah-Hartman from comment #1)
> All USB bugs should be sent to the linux-usb@vger.kernel.org mailing
> list, and not entered into bugzilla.  Please bring this issue up there,
> if it is still a problem in the latest kernel release.

Done: https://marc.info/?l=linux-usb&m=156971819526633&w=2 is the link for reference, in case anyone sees this ticket and wants to see where follow-up is happening.

Note You need to log in before you can comment on or make changes to this bug.