linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* CREAD ignored by almost all USB serial drivers
@ 2019-09-28 20:49 Harald Welte
  2019-10-07 11:06 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Harald Welte @ 2019-09-28 20:49 UTC (permalink / raw)
  To: linux-usb

[Copied on requst from https://bugzilla.kernel.org/show_bug.cgi?id=205033]

It seems that a lot of Linux kernel USB 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 and then call tcsetattr(), 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 classic serial 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 in 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.

Am I missing something here?  Please don't tell me that I just
discovered something that's broken for some 20-odd years, or at the very
least as far as normal linux.git history reaches back :/

Please keep me in Cc of any responses, I'm not subscribed to linux-usb.

Thanks!

Regards,
	Harald
-- 
- Harald Welte <laforge@gnumonks.org>           http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-08 15:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-28 20:49 CREAD ignored by almost all USB serial drivers Harald Welte
2019-10-07 11:06 ` Greg KH
2019-10-07 13:18   ` Harald Welte
2019-10-08 15:34     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).