Skip to content

Commit c776b77

Browse files
committed
Revert "drivers:tty:pty: Fix a race causing data loss on close"
This reverts commit 33d4ae9. Pierre-Louis writes: Our SOF/audio CI shows an across-the-board regression when we try v5.12-rc1, specifically on pause/resume tests with an interactive terminal running 'aplay -i' commands managed by expect to simulate the user pressing the space bar to pause/unpause. It turns out the processes are not longer killed and the audio devices remain busy (see publicly available test results listed below). git bisect points to commit 33d4ae9 ("drivers:tty:pty: Fix a race causing data loss on close"). Reverting the patch fixes the issue on all test devices. Further analysis with Corey Minyard points to a problem where a slave tty will not get a SIGHUP when the master is closed. So revert this for now: Reported-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: Corey Minyard <[email protected]> Cc: Jiri Slaby <[email protected]> Cc: Mark Brown <[email protected]>, Fixes: 33d4ae9 ("drivers:tty:pty: Fix a race causing data loss on close") Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2334de1 commit c776b77

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

drivers/tty/pty.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
6666
wake_up_interruptible(&tty->link->read_wait);
6767
wake_up_interruptible(&tty->link->write_wait);
6868
if (tty->driver->subtype == PTY_TYPE_MASTER) {
69-
struct file *f;
70-
69+
set_bit(TTY_OTHER_CLOSED, &tty->flags);
7170
#ifdef CONFIG_UNIX98_PTYS
7271
if (tty->driver == ptm_driver) {
7372
mutex_lock(&devpts_mutex);
@@ -76,17 +75,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
7675
mutex_unlock(&devpts_mutex);
7776
}
7877
#endif
79-
80-
/*
81-
* This hack is required because a program can open a
82-
* pty and redirect a console to it, but if the pty is
83-
* closed and the console is not released, then the
84-
* slave side will never close. So release the
85-
* redirect when the master closes.
86-
*/
87-
f = tty_release_redirect(tty->link);
88-
if (f)
89-
fput(f);
78+
tty_vhangup(tty->link);
9079
}
9180
}
9281

drivers/tty/tty_io.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,7 @@ EXPORT_SYMBOL_GPL(tty_wakeup);
544544
* @tty: tty device
545545
*
546546
* This is available to the pty code so if the master closes, if the
547-
* slave is a redirect it can release the redirect. It returns the
548-
* filp for the redirect, which must be fput when the operations on
549-
* the tty are completed.
547+
* slave is a redirect it can release the redirect.
550548
*/
551549
struct file *tty_release_redirect(struct tty_struct *tty)
552550
{
@@ -561,6 +559,7 @@ struct file *tty_release_redirect(struct tty_struct *tty)
561559

562560
return f;
563561
}
562+
EXPORT_SYMBOL_GPL(tty_release_redirect);
564563

565564
/**
566565
* __tty_hangup - actual handler for hangup events

0 commit comments

Comments
 (0)