USB: ftdi_sio: fix use-after-free in TIOCMIWAIT
authorJohan Hovold <jhovold@gmail.com>
Tue, 19 Mar 2013 08:21:15 +0000 (09:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Apr 2014 13:44:24 +0000 (06:44 -0700)
commit6929b79f07d57ddb86cb9083a5aac6c5f2c7ee0b
tree5a5366190a4f500696252437a2ba6c7371b0b671
parentee49ee869ce7af67ba38a1e989dd4d7670393d0c
USB: ftdi_sio: fix use-after-free in TIOCMIWAIT

commit 71ccb9b01981fabae27d3c98260ea4613207618e upstream.

Use the port wait queue and make sure to check the serial disconnected
flag before accessing private port data after waking up.

This is is needed as the private port data (including the wait queue
itself) can be gone when waking up after a disconnect.

When switching to tty ports, some lifetime assumptions were changed.
Specifically, close can now be called before the final tty reference is
dropped as part of hangup at device disconnect. Even with the ftdi
private-data refcounting this means that the port private data can be
freed while a process is sleeping on modem-status changes and thus
cannot be relied on to detect disconnects when woken up.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/serial/ftdi_sio.c