linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] drivers:tty:pty: Fix a race causing data loss on close
@ 2020-11-24  0:49 minyard
  2020-11-24  0:49 ` [PATCH 1/2] tty: Export redirect release minyard
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: minyard @ 2020-11-24  0:49 UTC (permalink / raw)
  To: Jiri Slaby, Greg Kroah-Hartman; +Cc: LKML, Peter Hurley, brian.bloniarz

I finally got some time to spend with this issue, and I think I have a
good fix.  Not really a v2, this is a completely different fix.
Basically, calling tty_vhangup() on the slave when closing a pty master
is just a bad idea.

From what I can tell, the tty_vhangup() is there in case there was a
console redirect to the pty slave.  When you close the master, you need
to release the redirect.  I didn't see another reason for tty_vhangup().
So this has two parts, export the release of the tty redirect release
for the pty code to use, and call it from the pty code.

With this change, everything seems to work ok and no data is lost on the
slave side if the master closes with outstanding data.  I have updated
my test program to check that all written data is read, it's available
at https://sourceforge.net/projects/ser2net/files/tmp/testpty.c/download

But, this code is quite intricate and I certainly may have missed
something.

-corey



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

end of thread, other threads:[~2021-01-07 15:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24  0:49 [PATCH 0/2] drivers:tty:pty: Fix a race causing data loss on close minyard
2020-11-24  0:49 ` [PATCH 1/2] tty: Export redirect release minyard
2020-11-24  0:49 ` [PATCH 2/2] drivers:tty:pty: Fix a race causing data loss on close minyard
2021-01-02 14:41   ` Corey Minyard
2021-01-07 15:29     ` Greg Kroah-Hartman
2021-01-07 15:32 ` [PATCH 0/2] " Greg Kroah-Hartman

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).