kernel-fxtec-pro1x/drivers/usb/serial
Johan Hovold a65a6f14dc USB: serial: fix race between probe and open
Fix race between probe and open by making sure that the disconnected
flag is not cleared until all ports have been registered.

A call to tty_open while probe is running may get a reference to the
serial structure in serial_install before its ports have been
registered. This may lead to usb_serial_core calling driver open before
port is fully initialised.

With ftdi_sio this result in the following NULL-pointer dereference as
the private data has not been initialised at open:

[  199.698286] IP: [<f811a089>] ftdi_open+0x59/0xe0 [ftdi_sio]
[  199.698297] *pde = 00000000
[  199.698303] Oops: 0000 [#1] PREEMPT SMP
[  199.698313] Modules linked in: ftdi_sio usbserial
[  199.698323]
[  199.698327] Pid: 1146, comm: ftdi_open Not tainted 3.2.11 #70 Dell Inc. Vostro 1520/0T816J
[  199.698339] EIP: 0060:[<f811a089>] EFLAGS: 00010286 CPU: 0
[  199.698344] EIP is at ftdi_open+0x59/0xe0 [ftdi_sio]
[  199.698348] EAX: 0000003e EBX: f5067000 ECX: 00000000 EDX: 80000600
[  199.698352] ESI: f48d8800 EDI: 00000001 EBP: f515dd54 ESP: f515dcfc
[  199.698356]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[  199.698361] Process ftdi_open (pid: 1146, ti=f515c000 task=f481e040 task.ti=f515c000)
[  199.698364] Stack:
[  199.698368]  f811a9fe f811a9e0 f811b3ef 00000000 00000000 00001388 00000000 f4a86800
[  199.698387]  00000002 00000000 f806e68e 00000000 f532765c f481e040 00000246 22222222
[  199.698479]  22222222 22222222 22222222 f5067004 f5327600 f5327638 f515dd74 f806e6ab
[  199.698496] Call Trace:
[  199.698504]  [<f806e68e>] ? serial_activate+0x2e/0x70 [usbserial]
[  199.698511]  [<f806e6ab>] serial_activate+0x4b/0x70 [usbserial]
[  199.698521]  [<c126380c>] tty_port_open+0x7c/0xd0
[  199.698527]  [<f806e660>] ? serial_set_termios+0xa0/0xa0 [usbserial]
[  199.698534]  [<f806e76f>] serial_open+0x2f/0x70 [usbserial]
[  199.698540]  [<c125d07c>] tty_open+0x20c/0x510
[  199.698546]  [<c10e9eb7>] chrdev_open+0xe7/0x230
[  199.698553]  [<c10e48f2>] __dentry_open+0x1f2/0x390
[  199.698559]  [<c144bfec>] ? _raw_spin_unlock+0x2c/0x50
[  199.698565]  [<c10e4b76>] nameidata_to_filp+0x66/0x80
[  199.698570]  [<c10e9dd0>] ? cdev_put+0x20/0x20
[  199.698576]  [<c10f3e08>] do_last+0x198/0x730
[  199.698581]  [<c10f4440>] path_openat+0xa0/0x350
[  199.698587]  [<c10f47d5>] do_filp_open+0x35/0x80
[  199.698593]  [<c144bfec>] ? _raw_spin_unlock+0x2c/0x50
[  199.698599]  [<c10ff110>] ? alloc_fd+0xc0/0x100
[  199.698605]  [<c10f0b72>] ? getname_flags+0x72/0x120
[  199.698611]  [<c10e4450>] do_sys_open+0xf0/0x1c0
[  199.698617]  [<c11fcc08>] ? trace_hardirqs_on_thunk+0xc/0x10
[  199.698623]  [<c10e458e>] sys_open+0x2e/0x40
[  199.698628]  [<c144c990>] sysenter_do_call+0x12/0x36
[  199.698632] Code: 85 89 00 00 00 8b 16 8b 4d c0 c1 e2 08 c7 44 24 14 88 13 00 00 81 ca 00 00 00 80 c7 44 24 10 00 00 00 00 c7 44 24 0c 00 00 00 00 <0f> b7 41 78 31 c9 89 44 24 08 c7 44 24 04 00 00 00 00 c7 04 24
[  199.698884] EIP: [<f811a089>] ftdi_open+0x59/0xe0 [ftdi_sio] SS:ESP 0068:f515dcfc
[  199.698893] CR2: 0000000000000078
[  199.698925] ---[ end trace 77c43ec023940cff ]---

Reported-and-tested-by: Ken Huang <csuhgw@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-10 13:35:53 -07:00
..
aircable.c USB: serial: aircable.c: use module_usb_serial_driver 2012-02-28 13:11:32 -08:00
ark3116.c USB: serial: ark3116.c: use module_usb_serial_driver 2012-02-28 13:11:35 -08:00
belkin_sa.c USB: serial: belkin_sa.c: use module_usb_serial_driver 2012-02-28 13:11:35 -08:00
belkin_sa.h
bus.c USB: fix bug in serial driver unregistration 2012-04-09 15:36:20 -07:00
ch341.c USB: serial: ch341.c: use module_usb_serial_driver 2012-02-28 13:11:37 -08:00
console.c
cp210x.c usb: cp210x: Update to support CP2105 and multiple interface devices 2012-03-02 16:19:16 -08:00
cyberjack.c USB: serial: cyberjack.c: use module_usb_serial_driver 2012-02-28 13:11:40 -08:00
cypress_m8.c USB: serial: cypress_m8.c: use module_usb_serial_driver 2012-02-28 13:11:41 -08:00
cypress_m8.h
digi_acceleport.c USB: serial: digi_acceleport.c: use module_usb_serial_driver 2012-02-28 13:11:41 -08:00
empeg.c USB: serial: empeg.c: use module_usb_serial_driver 2012-02-28 13:11:42 -08:00
ezusb.c
ezusb_convert.pl
f81232.c USB: serial: add Fintek F81232 usb to serial driver 2012-02-28 13:36:35 -08:00
ftdi_sio.c USB: ftdi_sio: fix race condition in TIOCMIWAIT, and abort of TIOCMIWAIT when the device is removed 2012-04-09 15:41:40 -07:00
ftdi_sio.h USB: ftdi_sio: add support for FT-X series devices 2012-03-14 15:43:05 -07:00
ftdi_sio_ids.h USB: ftdi_sio: new PID: LUMEL PD12 2012-03-15 12:34:30 -07:00
funsoft.c USB: serial: funsoft.c: use module_usb_serial_driver 2012-02-28 13:11:44 -08:00
garmin_gps.c USB: serial: garmin_gps.c: use module_usb_serial_driver 2012-02-28 13:11:46 -08:00
generic.c usb-serial: new API for driver registration 2012-02-24 12:39:17 -08:00
hp4x.c USB: serial: hp4x.c: use module_usb_serial_driver 2012-02-28 13:11:49 -08:00
io_16654.h
io_edgeport.c USB: serial: io_edgeport.c: use module_usb_serial_driver 2012-02-28 13:11:51 -08:00
io_edgeport.h
io_ionsp.h
io_tables.h usb-serial: use new registration API in [i-j]* drivers 2012-02-24 12:39:18 -08:00
io_ti.c USB: serial: io_ti.c: use module_usb_serial_driver 2012-02-28 13:11:53 -08:00
io_ti.h
io_usbvend.h
ipaq.c usb-serial: use new registration API in [i-j]* drivers 2012-02-24 12:39:18 -08:00
ipw.c USB: serial: ipw.c: use module_usb_serial_driver 2012-02-28 13:11:56 -08:00
ir-usb.c usb-serial: use new registration API in [i-j]* drivers 2012-02-24 12:39:18 -08:00
iuu_phoenix.c USB: serial: iuu_phoenix.c: use module_usb_serial_driver 2012-02-28 13:11:58 -08:00
iuu_phoenix.h
Kconfig USB: serial: metro-usb: add to the build 2012-03-08 13:34:01 -08:00
keyspan.c USB: serial: keyspan.c: use module_usb_serial_driver 2012-02-28 13:11:59 -08:00
keyspan.h usb-serial: use new registration API in [k-m]* drivers 2012-02-24 12:39:19 -08:00
keyspan_pda.c USB: serial: keyspan_pda.c: use module_usb_serial_driver 2012-02-28 13:11:59 -08:00
keyspan_usa26msg.h
keyspan_usa28msg.h
keyspan_usa49msg.h
keyspan_usa67msg.h
keyspan_usa90msg.h
kl5kusb105.c USB: serial: kl5kusb105.c: use module_usb_serial_driver 2012-02-28 13:12:00 -08:00
kl5kusb105.h
kobil_sct.c USB: serial: kobil_sct.c: use module_usb_serial_driver 2012-02-28 13:12:02 -08:00
kobil_sct.h
Makefile USB: serial: metro-usb: add to the build 2012-03-08 13:34:01 -08:00
Makefile-keyspan_pda_fw
mct_u232.c USB: serial: mct_u232.c: use module_usb_serial_driver 2012-02-28 13:12:05 -08:00
mct_u232.h
metro-usb.c USB: serial: metro-usb: Fix idProduct for Uni-Directional mode. 2012-04-09 15:36:20 -07:00
mos7720.c USB: serial: mos7720.c: use module_usb_serial_driver 2012-02-28 13:12:07 -08:00
mos7840.c USB: serial: mos7840: Fixed MCS7820 device attach problem 2012-03-14 12:25:26 -07:00
moto_modem.c USB: serial: moto_modem.c: use module_usb_serial_driver 2012-02-28 13:12:12 -08:00
navman.c USB: serial: navman.c: use module_usb_serial_driver 2012-02-28 13:12:14 -08:00
omninet.c USB: serial: omninet.c: use module_usb_serial_driver 2012-02-28 13:12:17 -08:00
opticon.c USB: serial: opticon.c: use module_usb_serial_driver 2012-02-28 13:12:19 -08:00
option.c USB: option: re-add NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED to option_id array 2012-04-09 15:36:20 -07:00
oti6858.c USB: serial: oti6858.c: use module_usb_serial_driver 2012-02-28 13:12:22 -08:00
oti6858.h
pl2303.c USB: pl2303: fix DTR/RTS being raised on baud rate change 2012-04-09 15:36:20 -07:00
pl2303.h USB: serial: pl2303: rm duplicate id 2011-11-15 10:06:15 -08:00
qcaux.c USB: serial: qcaux.c: use module_usb_serial_driver 2012-02-28 13:12:24 -08:00
qcserial.c USB: serial: qcserial.c: use module_usb_serial_driver 2012-02-28 13:12:26 -08:00
safe_serial.c usb-serial: use new registration API in [q-s]* drivers 2012-02-24 12:39:20 -08:00
siemens_mpi.c USB: serial: siemens_mpi.c: use module_usb_serial_driver 2012-02-28 13:12:29 -08:00
sierra.c USB: sierra: add support for Sierra Wireless MC7710 2012-04-09 15:42:25 -07:00
spcp8x5.c USB: serial: spcp8x5.c: use module_usb_serial_driver 2012-02-28 13:12:34 -08:00
ssu100.c USB: serial: ssu100.c: use module_usb_serial_driver 2012-02-28 13:12:36 -08:00
symbolserial.c USB: serial: symbolserial.c: use module_usb_serial_driver 2012-02-28 13:12:38 -08:00
ti_usb_3410_5052.c usb-serial: use new registration API in [t-z]* drivers 2012-02-24 12:39:21 -08:00
ti_usb_3410_5052.h USB: Serial: ti_usb_3410_5052: Add Abbot Diabetes Care cable id 2012-02-21 16:29:15 -08:00
usb-serial.c USB: serial: fix race between probe and open 2012-04-10 13:35:53 -07:00
usb-wwan.h
usb_debug.c USB: serial: usb_debug.c: use module_usb_serial_driver 2012-02-28 13:12:41 -08:00
usb_wwan.c module_param: make bool parameters really bool (drivers & misc) 2012-01-13 09:32:20 +10:30
visor.c usb-serial: use new registration API in [t-z]* drivers 2012-02-24 12:39:21 -08:00
visor.h
vivopay-serial.c USB: serial: vivopay-serial.c: use module_usb_serial_driver 2012-02-28 13:12:43 -08:00
whiteheat.c USB: serial: whiteheat.c: use module_usb_serial_driver 2012-02-28 13:12:44 -08:00
whiteheat.h
zio.c USB: serial: zio.c: use module_usb_serial_driver 2012-02-28 13:12:46 -08:00