mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/8] tty: Fix race in the flush for some ldiscs
Date: Thu, 15 Jan 2009 13:30:25 +0000	[thread overview]
Message-ID: <20090115133000.21366.28884.stgit@localhost.localdomain> (raw)
In-Reply-To: <20090115132718.21366.56187.stgit@localhost.localdomain>

From: Alan Cox <alan@redhat.com>

If you issue an ioctl to flush a tty as the line discipline is changing or
otherwise unplugged you can get a crash. The bug is very old but the rest
of the BKL lock dropping and some very "good" luck on Ingo's part caught
an example.

Use the correct ldisc_ref form so that we wait for the ldisc change to
complete and then flush

Signed-off-by: Alan Cox <alan@redhat.com>
---

 drivers/char/tty_ioctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index a408c8e..6f4c7d0 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -1057,7 +1057,7 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
 	if (retval)
 		return retval;
 
-	ld = tty_ldisc_ref(tty);
+	ld = tty_ldisc_ref_wait(tty);
 	switch (arg) {
 	case TCIFLUSH:
 		if (ld && ld->ops->flush_buffer)


  reply	other threads:[~2009-01-15 13:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-15 13:29 [PATCH 0/8] Series short description Alan Cox
2009-01-15 13:30 ` Alan Cox [this message]
2009-01-15 13:30 ` [PATCH 2/8] 8250_pci: add support for netmos 9835 IBM devices Alan Cox
2009-01-15 13:30 ` [PATCH 3/8] serial: Add SupraExpress 336i PnP Voice Modem Alan Cox
2009-01-15 13:30 ` [PATCH 4/8] When a break signal is detected, the next character should be ignored Alan Cox
2009-01-15 13:31 ` [PATCH 5/8] ftdi_sio: fix kref leak Alan Cox
2009-01-15 13:31 ` [PATCH 6/8] tty: Fix a kref leak in the HSO driver on re-open Alan Cox
2009-01-15 13:31 ` [PATCH 7/8] tty: Fix double grabbing of a spinlock Alan Cox
2009-01-15 13:31 ` [PATCH 8/8] hso serial throttled tty kref fix Alan Cox

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=20090115133000.21366.28884.stgit@localhost.localdomain \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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

Powered by JetHome