mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Daniel Mack <daniel@caiaq.de>,
	Kernel development list <linux-kernel@vger.kernel.org>,
	USB list <linux-usb@vger.kernel.org>
Subject: Re: [PATCH] [usb-serial] fix Ooops on uplug
Date: Tue, 21 Jul 2009 17:16:25 +0100	[thread overview]
Message-ID: <20090721171625.6e2c54e4@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0907211141180.2652-100000@iolanthe.rowland.org>

> > If that is occuring then the bug is elsewhere. The hang up sequence
> > reconnects the user space to the hung up tty ops and no longer references
> > the hardware.
> 
> I got something similar with a pl2303 device, though not a crash.  I 
> plugged in the device, opened /dev/ttyUSB0, unplugged the device, then 
> tried to read from the open file descriptor.  The read provoked this:

That looks like it occurs after the read, however that trace shows the
close() method being called off sys_close() which in turn means a hang up
didn't occur when it was unplugged.

> This is only a lockdep warning, and I don't understand its
> significance.  Even worse, when I plugged in a USB flash drive
> afterward this appeared:

Looks like something freed the resources but didn't hang up when the
disconnect occurred

> So it looks like something really is wrong, some sort of 
> use-after-free.  Maybe a refcounting imbalance.

A tty getting destructed before it should have been would perhaps do some
of it but it doesn't explain how the close path got where it did.

What should be occurring is

	USB disconnect
		usb_serial_disconnect(interface)
		tty_hangup(tty)   [this is buggy and commented as such in
		the USB code as it should do it synchronously]

	tty_hangup()
	do_tty_hangup()

	file->f_ops = &hung_up_tty_ops;

		(so the USB close will never be called)

	ldisc hangup
	tty->ops->hangup (no-op on USB serial)

so the trace to me implies that the usb_serial_disconnect is not
happening. That in turn leads the close method to be called on a
disconnected port which in turn crashes stuff.

(and it also explains why Daniel's change although bogus stops the crash)



  parent reply	other threads:[~2009-07-21 16:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090720155502.50b84ae9@lxorguk.ukuu.org.uk>
2009-07-20 17:51 ` Daniel Mack
2009-07-20 22:48   ` Alan Cox
2009-07-20 21:58     ` Daniel Mack
2009-07-20 23:45       ` Alan Cox
2009-07-21 15:53         ` Alan Stern
2009-07-21 15:56           ` Daniel Mack
2009-07-21 16:00             ` Alan Cox
2009-07-21 16:11               ` Alan Stern
2009-07-21 16:18                 ` Alan Cox
2009-07-21 16:16           ` Alan Cox [this message]
2009-07-21 16:19             ` Daniel Mack
2009-07-21 16:28               ` Alan Cox
2009-07-21 18:36             ` Alan Stern
2009-07-21 19:21               ` Alan Cox
2009-07-21 21:38                 ` Alan Stern
2009-07-21 22:55                   ` Alan Cox
2009-07-22 14:44                     ` Alan Stern
2009-07-22 16:17                       ` Alan Cox
2009-07-22 18:21                         ` Alan Stern
2009-07-22 22:35                           ` Alan Cox
2009-07-22 22:45                             ` Alan Stern
2009-07-22 22:48                               ` Alan Cox
2009-07-20 23:32   ` 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=20090721171625.6e2c54e4@lxorguk.ukuu.org.uk \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=daniel@caiaq.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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

all inboxes | Powered by JetHome®