Commit c776b77a authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Revert "drivers:tty:pty: Fix a race causing data loss on close"

This reverts commit 33d4ae98.

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 33d4ae98 ("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: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/00154592-c5ee-aaba-956e-b265473b53bc@linux.intel.com
Cc: Corey Minyard <cminyard@mvista.com>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Mark Brown <broonie@kernel.org>,
Fixes: 33d4ae98 ("drivers:tty:pty: Fix a race causing data loss on close")
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2334de19
...@@ -66,8 +66,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp) ...@@ -66,8 +66,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
wake_up_interruptible(&tty->link->read_wait); wake_up_interruptible(&tty->link->read_wait);
wake_up_interruptible(&tty->link->write_wait); wake_up_interruptible(&tty->link->write_wait);
if (tty->driver->subtype == PTY_TYPE_MASTER) { if (tty->driver->subtype == PTY_TYPE_MASTER) {
struct file *f; set_bit(TTY_OTHER_CLOSED, &tty->flags);
#ifdef CONFIG_UNIX98_PTYS #ifdef CONFIG_UNIX98_PTYS
if (tty->driver == ptm_driver) { if (tty->driver == ptm_driver) {
mutex_lock(&devpts_mutex); mutex_lock(&devpts_mutex);
...@@ -76,17 +75,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp) ...@@ -76,17 +75,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
mutex_unlock(&devpts_mutex); mutex_unlock(&devpts_mutex);
} }
#endif #endif
tty_vhangup(tty->link);
/*
* This hack is required because a program can open a
* pty and redirect a console to it, but if the pty is
* closed and the console is not released, then the
* slave side will never close. So release the
* redirect when the master closes.
*/
f = tty_release_redirect(tty->link);
if (f)
fput(f);
} }
} }
......
...@@ -544,9 +544,7 @@ EXPORT_SYMBOL_GPL(tty_wakeup); ...@@ -544,9 +544,7 @@ EXPORT_SYMBOL_GPL(tty_wakeup);
* @tty: tty device * @tty: tty device
* *
* This is available to the pty code so if the master closes, if the * This is available to the pty code so if the master closes, if the
* slave is a redirect it can release the redirect. It returns the * slave is a redirect it can release the redirect.
* filp for the redirect, which must be fput when the operations on
* the tty are completed.
*/ */
struct file *tty_release_redirect(struct tty_struct *tty) struct file *tty_release_redirect(struct tty_struct *tty)
{ {
...@@ -561,6 +559,7 @@ struct file *tty_release_redirect(struct tty_struct *tty) ...@@ -561,6 +559,7 @@ struct file *tty_release_redirect(struct tty_struct *tty)
return f; return f;
} }
EXPORT_SYMBOL_GPL(tty_release_redirect);
/** /**
* __tty_hangup - actual handler for hangup events * __tty_hangup - actual handler for hangup events
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment