synchronization in usb_serial_put
authorBenny Halevy <bhalevy@panasas.com>
Tue, 15 May 2007 08:15:27 +0000 (11:15 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 12 Jul 2007 23:34:31 +0000 (16:34 -0700)
commit52f6b5e1f15fa8c06efa69a4b5faa69c04707c92
tree3918f4d76adad79172ce42de5691bfc8c4781d40
parentefdff60885e36b5091cdc47742dd5768ff4119be
synchronization in usb_serial_put

I think there is a race between usb_serial_put() and
usb_serial_get_by_index() (and get_free_serial()) with regards
to handling the serial port refcount.

usb_serial_get_by_index() gets a reference on the serial port under
table_lock while return_serial releases all the returned ports
from the table under the same lock.  However, the table_lock is not
taken around the call to kref_put, theoretically allowing to sneak
in and grab a reference after kref_put has already determined that
the reference count is zero (and before calling destroy_serial)
causing use after free.

Signed-off-by: Benny Halevy <bhalevy@ns1.bhalevy.com>
Cc: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/usb-serial.c