From: Peter Hurley <peter@hurleysoftware.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>,
linux-kernel@vger.kernel.org,
Peter Hurley <peter@hurleysoftware.com>
Subject: [PATCH v2 00/19] Fix driver crashes on hangup
Date: Sat, 9 Jan 2016 20:40:51 -0800 [thread overview]
Message-ID: <1452400870-6005-1-git-send-email-peter@hurleysoftware.com> (raw)
In-Reply-To: <1448660356-6328-1-git-send-email-peter@hurleysoftware.com>
Changes for v2:
Rebased on top of current tty-next
Reduced changes/re-titled patch 19
NB: Marcel already picked up "bluetooth: hci_ldisc: Remove dead code" for
bluetooth-next
---
Hi Greg,
This series fixes the underlying design problem that leads to driver crashes
during hangup (eg., Andi Kleen's report https://lkml.org/lkml/2015/11/9/786).
Quoting from patch 17/19:
Currently, when the tty is hungup, the ldisc is re-instanced; ie., the
current instance is destroyed and a new instance is created. The purpose
of this design was to guarantee a valid, open ldisc for the lifetime of
the tty.
However, now that tty buffers are owned by and have lifetime equivalent
to the tty_port (since v3.10), any data received immediately after the
ldisc is re-instanced may cause continued driver i/o operations
concurrently with the driver's hangup() operation. For drivers that
shutdown h/w on hangup, this is unexpected and usually bad. For example,
the serial core may free the xmit buffer page concurrently with an
in-progress write() operation (triggered by echo).
With the existing stable and robust ldisc reference handling, the
cleaned-up tty_reopen(), the straggling unsafe ldisc use cleaned up, and
the preparation to properly handle a NULL tty->ldisc, the ldisc instance
can be destroyed and only re-instanced when the tty is re-opened.
With this patch series, the tty core now guarantees no further driver/ldisc
interactions after hangup.
Patch 1-4 remove direct tty->ldisc access outside the tty core.
Patch 5 removes the defunct chars_in_buffer() ldisc method (which has been
deprecated since 3.12)
Patch 6 & 7 fix unsafe ldisc uses which coincidentally have been discovered
to cause crashes (https://lkml.org/lkml/2015/11/26/173 and
https://lkml.org/lkml/2015/11/26/253). These have been tagged for
-stable.
Patch 8-16 are preparations; documenting existing functions and refactoring.
Patch 12 adds handling for the possibility of NULL ldisc references
after tty_ldisc_ref_wait(); that commit log details the logic of
why/how that works.
Patch 17 implements the fix: the ldisc instance is killed and left dead.
At tty_reopen() if the tty->ldisc is NULL, a new ldisc is instanced.
Patch 18-19 are minor add-ons.
Regards,
Peter Hurley (19):
staging: digi: Replace open-coded tty_wakeup()
serial: 68328: Remove bogus ldisc reset
bluetooth: hci_ldisc: Remove dead code
NFC: nci: Remove dead code
tty: Remove chars_in_buffer() line discipline method
tty: Fix unsafe ldisc reference via ioctl(TIOCGETD)
n_tty: Fix unsafe reference to "other" ldisc
tty: Reset c_line from driver's init_termios
staging/speakup: Use tty_ldisc_ref() for paste kworker
tty: Fix comments for tty_ldisc_get()
tty: Fix comments for tty_ldisc_release()
tty: Prepare for destroying line discipline on hangup
tty: Handle NULL tty->ldisc
tty: Move tty_ldisc_kill()
tty: Use 'disc' for line discipline index name
tty: Refactor tty_ldisc_reinit() for reuse
tty: Destroy ldisc instance on hangup
tty: Document c_line == N_TTY initial condition
tty: Avoid unnecessary temporaries for tty->ldisc
Documentation/serial/tty.txt | 3 -
drivers/bluetooth/hci_ldisc.c | 8 +-
drivers/staging/dgap/dgap.c | 28 ++----
drivers/staging/dgnc/dgnc_tty.c | 18 +---
drivers/staging/speakup/selection.c | 4 +-
drivers/tty/amiserial.c | 6 +-
drivers/tty/cyclades.c | 8 +-
drivers/tty/n_gsm.c | 16 ----
drivers/tty/n_tty.c | 30 +------
drivers/tty/rocket.c | 6 +-
drivers/tty/serial/68328serial.c | 12 +--
drivers/tty/serial/crisv10.c | 12 ++-
drivers/tty/tty_io.c | 64 +++++++++++---
drivers/tty/tty_ldisc.c | 171 ++++++++++++++++++++----------------
drivers/tty/vt/selection.c | 2 +
include/linux/tty.h | 5 +-
include/linux/tty_ldisc.h | 7 --
net/nfc/nci/uart.c | 9 +-
18 files changed, 179 insertions(+), 230 deletions(-)
--
2.7.0
next prev parent reply other threads:[~2016-01-10 4:41 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 21:38 [PATCH 00/19] Fix driver crashes on hangup Peter Hurley
2015-11-27 21:38 ` [PATCH 01/19] staging: digi: Replace open-coded tty_wakeup() Peter Hurley
2015-11-27 21:38 ` [PATCH 02/19] serial: 68328: Remove bogus ldisc reset Peter Hurley
2015-11-27 21:39 ` [PATCH 03/19] bluetooth: hci_ldisc: Remove dead code Peter Hurley
2015-12-02 7:47 ` Marcel Holtmann
2015-11-27 21:39 ` [PATCH 04/19] NFC: nci: " Peter Hurley
2015-11-27 21:39 ` [PATCH 05/19] tty: Remove chars_in_buffer() line discipline method Peter Hurley
2015-11-27 21:39 ` [PATCH 06/19] tty: Fix unsafe ldisc reference via ioctl(TIOCGETD) Peter Hurley
2015-11-27 21:39 ` [PATCH 07/19] n_tty: Fix unsafe reference to "other" ldisc Peter Hurley
2015-11-27 21:39 ` [PATCH 08/19] tty: Reset c_line from driver's init_termios Peter Hurley
2015-11-27 21:39 ` [PATCH 09/19] staging/speakup: Use tty_ldisc_ref() for paste kworker Peter Hurley
2015-11-27 21:39 ` [PATCH 10/19] tty: Fix comments for tty_ldisc_get() Peter Hurley
2015-11-27 21:39 ` [PATCH 11/19] tty: Fix comments for tty_ldisc_release() Peter Hurley
2015-11-27 21:39 ` [PATCH 12/19] tty: Prepare for destroying line discipline on hangup Peter Hurley
2015-11-27 21:39 ` [PATCH 13/19] tty: Handle NULL tty->ldisc Peter Hurley
2015-11-27 21:39 ` [PATCH 14/19] tty: Move tty_ldisc_kill() Peter Hurley
2015-11-27 21:39 ` [PATCH 15/19] tty: Use 'disc' for line discipline index name Peter Hurley
2015-11-27 21:39 ` [PATCH 16/19] tty: Refactor tty_ldisc_reinit() for reuse Peter Hurley
2015-11-27 21:39 ` [PATCH 17/19] tty: Destroy ldisc instance on hangup Peter Hurley
2015-11-27 21:39 ` [PATCH 18/19] tty: Document c_line == N_TTY initial condition Peter Hurley
2015-11-27 21:39 ` [PATCH 19/19] tty: Touch up style issues in ldisc core Peter Hurley
2016-01-10 4:40 ` Peter Hurley [this message]
2016-01-10 4:40 ` [PATCH v2 01/19] staging: digi: Replace open-coded tty_wakeup() Peter Hurley
2016-01-10 4:40 ` [PATCH v2 02/19] serial: 68328: Remove bogus ldisc reset Peter Hurley
2016-01-10 4:40 ` [PATCH v2 03/19] bluetooth: hci_ldisc: Remove dead code Peter Hurley
2016-01-10 4:40 ` [PATCH v2 04/19] NFC: nci: " Peter Hurley
2016-01-10 4:40 ` [PATCH v2 05/19] tty: Remove chars_in_buffer() line discipline method Peter Hurley
2016-01-10 4:40 ` [PATCH v2 06/19] tty: Fix unsafe ldisc reference via ioctl(TIOCGETD) Peter Hurley
2016-01-10 5:24 ` Peter Hurley
2016-01-10 4:40 ` [PATCH v2 07/19] n_tty: Fix unsafe reference to "other" ldisc Peter Hurley
2016-01-10 5:26 ` Peter Hurley
2016-01-10 4:40 ` [PATCH v2 08/19] tty: Reset c_line from driver's init_termios Peter Hurley
2016-01-10 4:41 ` [PATCH v2 09/19] staging/speakup: Use tty_ldisc_ref() for paste kworker Peter Hurley
2016-01-10 23:16 ` Ben Hutchings
2016-01-11 0:25 ` Peter Hurley
2016-01-11 5:40 ` Peter Hurley
2016-01-11 10:37 ` Ben Hutchings
2016-01-10 4:41 ` [PATCH v2 10/19] tty: Fix comments for tty_ldisc_get() Peter Hurley
2016-01-10 4:41 ` [PATCH v2 11/19] tty: Fix comments for tty_ldisc_release() Peter Hurley
2016-01-10 4:41 ` [PATCH v2 12/19] tty: Prepare for destroying line discipline on hangup Peter Hurley
2016-01-10 4:41 ` [PATCH v2 13/19] tty: Handle NULL tty->ldisc Peter Hurley
2016-01-10 4:41 ` [PATCH v2 14/19] tty: Move tty_ldisc_kill() Peter Hurley
2016-01-10 4:41 ` [PATCH v2 15/19] tty: Use 'disc' for line discipline index name Peter Hurley
2016-01-10 4:41 ` [PATCH v2 16/19] tty: Refactor tty_ldisc_reinit() for reuse Peter Hurley
2016-01-10 4:41 ` [PATCH v2 17/19] tty: Destroy ldisc instance on hangup Peter Hurley
2016-01-10 6:24 ` kbuild test robot
2016-01-10 6:24 ` [PATCH] tty: fix badzero.cocci warnings kbuild test robot
2016-01-10 7:02 ` Peter Hurley
2016-01-10 4:41 ` [PATCH v2 18/19] tty: Document c_line == N_TTY initial condition Peter Hurley
2016-01-10 4:41 ` [PATCH v2 19/19] tty: Avoid unnecessary temporaries for tty->ldisc Peter Hurley
2016-01-11 6:40 ` [PATCH v3 00/19] Fix driver crashes on hangup Peter Hurley
2016-01-11 6:40 ` [PATCH v3 01/19] staging: digi: Replace open-coded tty_wakeup() Peter Hurley
2016-01-11 6:40 ` [PATCH v3 02/19] serial: 68328: Remove bogus ldisc reset Peter Hurley
2016-01-11 14:12 ` One Thousand Gnomes
2016-01-11 6:40 ` [PATCH v3 03/19] bluetooth: hci_ldisc: Remove dead code Peter Hurley
2016-01-11 6:40 ` [PATCH v3 04/19] NFC: nci: " Peter Hurley
2016-01-11 6:40 ` [PATCH v3 05/19] tty: Remove chars_in_buffer() line discipline method Peter Hurley
2016-01-11 6:40 ` [PATCH v3 06/19] tty: Fix unsafe ldisc reference via ioctl(TIOCGETD) Peter Hurley
2016-01-11 6:40 ` [PATCH v3 07/19] n_tty: Fix unsafe reference to "other" ldisc Peter Hurley
2016-01-11 6:40 ` [PATCH v3 08/19] tty: Reset c_line from driver's init_termios Peter Hurley
2016-01-11 6:40 ` [PATCH v3 09/19] staging/speakup: Use tty_ldisc_ref() for paste kworker Peter Hurley
2016-01-11 6:40 ` [PATCH v3 10/19] tty: Fix comments for tty_ldisc_get() Peter Hurley
2016-01-11 6:41 ` [PATCH v3 11/19] tty: Fix comments for tty_ldisc_release() Peter Hurley
2016-01-11 6:41 ` [PATCH v3 12/19] tty: Prepare for destroying line discipline on hangup Peter Hurley
2016-01-11 6:41 ` [PATCH v3 13/19] tty: Handle NULL tty->ldisc Peter Hurley
2016-01-11 6:41 ` [PATCH v3 14/19] tty: Move tty_ldisc_kill() Peter Hurley
2016-01-11 6:41 ` [PATCH v3 15/19] tty: Use 'disc' for line discipline index name Peter Hurley
2016-01-11 6:41 ` [PATCH v3 16/19] tty: Refactor tty_ldisc_reinit() for reuse Peter Hurley
2016-01-11 6:41 ` [PATCH v3 17/19] tty: Destroy ldisc instance on hangup Peter Hurley
2016-01-11 6:41 ` [PATCH v3 18/19] tty: Document c_line == N_TTY initial condition Peter Hurley
2016-01-11 6:41 ` [PATCH v3 19/19] tty: Avoid unnecessary temporaries for tty->ldisc Peter Hurley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452400870-6005-1-git-send-email-peter@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).