linux_dsm_epyc7002/drivers/usb/serial
Johan Hovold 3f5edd58d0 USB: serial: fix unthrottle races
Fix two long-standing bugs which could potentially lead to memory
corruption or leave the port throttled until it is reopened (on weakly
ordered systems), respectively, when read-URB completion races with
unthrottle().

First, the URB must not be marked as free before processing is complete
to prevent it from being submitted by unthrottle() on another CPU.

	CPU 1				CPU 2
	================		================
	complete()			unthrottle()
	  process_urb();
	  smp_mb__before_atomic();
	  set_bit(i, free);		  if (test_and_clear_bit(i, free))
	  					  submit_urb();

Second, the URB must be marked as free before checking the throttled
flag to prevent unthrottle() on another CPU from failing to observe that
the URB needs to be submitted if complete() sees that the throttled flag
is set.

	CPU 1				CPU 2
	================		================
	complete()			unthrottle()
	  set_bit(i, free);		  throttled = 0;
	  smp_mb__after_atomic();	  smp_mb();
	  if (throttled)		  if (test_and_clear_bit(i, free))
	  	  return;			  submit_urb();

Note that test_and_clear_bit() only implies barriers when the test is
successful. To handle the case where the URB is still in use an explicit
barrier needs to be added to unthrottle() for the second race condition.

Fixes: d83b405383 ("USB: serial: add support for multiple read urbs")
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-04-30 10:23:28 +02:00
..
aircable.c USB: serial: fix module-license macros 2017-11-04 11:58:00 +01:00
ark3116.c USB: serial: ark3116: drop redundant init_termios 2019-04-26 08:37:53 +02:00
belkin_sa.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
belkin_sa.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
bus.c USB: serial: use tty_port_register_device() 2018-05-17 11:22:00 +02:00
ch341.c USB: serial: ch341: fix type promotion bug in ch341_control_in() 2018-07-04 15:40:54 +02:00
console.c USB: serial: console: fix reported terminal settings 2018-12-05 11:29:10 +01:00
cp210x.c USB: serial: cp210x: add new device id 2019-03-28 08:59:49 +01:00
cyberjack.c USB: serial: cyberjack: use irqsave() in USB's complete callback 2018-06-26 14:13:53 +02:00
cypress_m8.c USB: serial: cypress_m8: clean up initial-termios handling 2019-04-26 08:37:59 +02:00
cypress_m8.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
digi_acceleport.c USB: serial: digi_acceleport: clean up set_termios 2019-04-21 14:24:12 +02:00
empeg.c USB: serial: fix module-license macros 2017-11-04 11:58:00 +01:00
ezusb_convert.pl License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
f81232.c f81232: switch to ->get_serial() 2018-10-13 00:50:35 -04:00
f81534.c USB: serial: f81534: fix reading old/new IC config 2018-11-20 18:25:44 +01:00
ftdi_sio_ids.h USB: serial: ftdi_sio: add additional NovaTech products 2019-03-19 10:37:26 +01:00
ftdi_sio.c USB: serial: ftdi_sio: add additional NovaTech products 2019-03-19 10:37:26 +01:00
ftdi_sio.h USB: serial: ftdi_sio: add support for FT232R CBUS gpios 2018-10-05 08:57:06 +02:00
garmin_gps.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
generic.c USB: serial: fix unthrottle races 2019-04-30 10:23:28 +02:00
io_16654.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
io_edgeport.c io_edgeport: switch to ->get_serial() 2018-10-13 00:50:37 -04:00
io_edgeport.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
io_ionsp.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
io_ti.c io_ti: switch to ->get_serial() 2018-10-13 00:50:38 -04:00
io_ti.h USB: serial: io_ti: fix array underflow in completion handler 2018-08-27 11:52:34 +02:00
io_usbvend.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
ipaq.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
ipw.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
ir-usb.c USB: serial: cast sizeof() to int when comparing with error code 2018-06-25 10:34:31 +02:00
iuu_phoenix.c USB: serial: iuu_phoenix: simplify init_termios 2019-04-26 08:38:00 +02:00
iuu_phoenix.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
Kconfig USB: add missing SPDX lines to Kconfig and Makefiles 2019-01-22 09:08:17 +01:00
keyspan_pda.c USB: serial: keyspan_pda: fix modem-status error handling 2018-07-06 10:32:14 +02:00
keyspan_usa26msg.h USB: serial: keyspan_usa: add proper SPDX lines for .h files 2019-01-18 11:09:32 +01:00
keyspan_usa28msg.h USB: serial: keyspan_usa: add proper SPDX lines for .h files 2019-01-18 11:09:32 +01:00
keyspan_usa49msg.h USB: serial: keyspan_usa: add proper SPDX lines for .h files 2019-01-18 11:09:32 +01:00
keyspan_usa67msg.h USB: serial: keyspan_usa: add proper SPDX lines for .h files 2019-01-18 11:09:32 +01:00
keyspan_usa90msg.h USB: serial: keyspan_usa: add proper SPDX lines for .h files 2019-01-18 11:09:32 +01:00
keyspan.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
kl5kusb105.c USB: serial: kl5kusb105: remove KLSI device id 2018-07-11 10:11:29 +02:00
kl5kusb105.h USB: serial: kl5kusb105: remove KLSI device id 2018-07-11 10:11:29 +02:00
kobil_sct.c USB: serial: kobil_sct: add missing version error handling 2018-07-06 10:42:42 +02:00
kobil_sct.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile-keyspan_pda_fw USB: add SPDX identifiers to all remaining Makefiles 2017-11-07 15:53:48 +01:00
mct_u232.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
mct_u232.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
metro-usb.c USB: serial: fix module-license macros 2017-11-04 11:58:00 +01:00
mos7720.c USB: serial: mos7720: fix mos_parport refcount imbalance on error path 2019-03-20 13:58:42 +01:00
mos7840.c USB: serial: mos7840: remove set but not used variables 'number, serial' 2018-12-10 10:20:44 +01:00
mxuport.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
navman.c USB: serial: fix module-license macros 2017-11-04 11:58:00 +01:00
omninet.c USB: serial: fix module-license macros 2017-11-04 11:58:00 +01:00
opticon.c opticon: switch to ->get_serial() 2018-10-13 00:50:39 -04:00
option.c USB: serial: option: add Olicard 600 2019-03-28 09:27:22 +01:00
oti6858.c USB: serial: oti6858: simplify init_termios 2019-04-26 08:38:00 +02:00
oti6858.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
pl2303.c USB: serial: pl2303: fix tranceiver suspend mode 2019-04-03 09:46:50 +02:00
pl2303.h USB: serial: pl2303: add new PID to support PL2303TB 2019-01-17 17:24:39 +01:00
qcaux.c USB: serial: fix module-license macros 2017-11-04 11:58:00 +01:00
qcserial.c USB: serial: qcserial: add Sierra Wireless EM7565 2017-12-15 09:41:46 +01:00
quatech2.c USB: serial: quatech2: remove set but not used variable 'port_priv' 2018-11-12 10:08:10 +01:00
safe_serial.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
sierra.c USB: serial: sierra: use irqsave() in USB's complete callback 2018-06-26 15:22:25 +02:00
spcp8x5.c USB: serial: spcp8x5: simplify init_termios 2019-04-26 08:38:02 +02:00
ssu100.c ssu100: switch to ->get_serial() 2018-10-13 00:50:41 -04:00
symbolserial.c USB: serial: symbolserial: use irqsave() in USB's complete callback 2018-06-26 15:25:01 +02:00
ti_usb_3410_5052.c Merge branch 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2018-10-24 14:43:41 +01:00
upd78f0730.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
usb_debug.c USB: serial: usb_debug: add new USB device id 2017-11-28 09:54:11 +01:00
usb_wwan.c usb_wwan: switch to ->[sg]et_serial() 2018-10-13 00:50:42 -04:00
usb-serial-simple.c USB: serial: simple: add Motorola Tetra TPG2200 device id 2019-01-07 16:37:52 +01:00
usb-serial.c USB: serial: fix initial-termios handling 2019-04-26 08:37:53 +02:00
usb-wwan.h usb_wwan: switch to ->[sg]et_serial() 2018-10-13 00:50:42 -04:00
visor.c USB: serial: visor: handle potential invalid device configuration 2018-05-02 09:37:19 +02:00
visor.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
whiteheat.c whiteheat: switch to ->get_serial() 2018-10-13 00:50:42 -04:00
whiteheat.h USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
wishbone-serial.c USB: serial: Remove redundant license text 2017-11-04 11:55:38 +01:00
xsens_mt.c USB: serial: fix module-license macros 2017-11-04 11:58:00 +01:00