]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.110/usb-cdc-acm-fix-race-during-wakeup-blocking-tx-traffic.patch
Linux 4.9.167
[thirdparty/kernel/stable-queue.git] / releases / 4.14.110 / usb-cdc-acm-fix-race-during-wakeup-blocking-tx-traffic.patch
1 From 93e1c8a638308980309e009cc40b5a57ef87caf1 Mon Sep 17 00:00:00 2001
2 From: Romain Izard <romain.izard.pro@gmail.com>
3 Date: Fri, 22 Mar 2019 16:53:02 +0100
4 Subject: usb: cdc-acm: fix race during wakeup blocking TX traffic
5
6 From: Romain Izard <romain.izard.pro@gmail.com>
7
8 commit 93e1c8a638308980309e009cc40b5a57ef87caf1 upstream.
9
10 When the kernel is compiled with preemption enabled, the URB completion
11 handler can run in parallel with the work responsible for waking up the
12 tty layer. If the URB handler sets the EVENT_TTY_WAKEUP bit during the
13 call to tty_port_tty_wakeup() to signal that there is room for additional
14 input, it will be cleared at the end of this call. As a result, TX traffic
15 on the upper layer will be blocked.
16
17 This can be seen with a kernel configured with CONFIG_PREEMPT, and a fast
18 modem connected with PPP running over a USB CDC-ACM port.
19
20 Use test_and_clear_bit() instead, which ensures that each wakeup requested
21 by the URB completion code will trigger a call to tty_port_tty_wakeup().
22
23 Fixes: 1aba579f3cf5 cdc-acm: handle read pipe errors
24 Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
25 Cc: stable <stable@vger.kernel.org>
26 Acked-by: Oliver Neukum <oneukum@suse.com>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28
29 ---
30 drivers/usb/class/cdc-acm.c | 4 +---
31 1 file changed, 1 insertion(+), 3 deletions(-)
32
33 --- a/drivers/usb/class/cdc-acm.c
34 +++ b/drivers/usb/class/cdc-acm.c
35 @@ -570,10 +570,8 @@ static void acm_softint(struct work_stru
36 clear_bit(EVENT_RX_STALL, &acm->flags);
37 }
38
39 - if (test_bit(EVENT_TTY_WAKEUP, &acm->flags)) {
40 + if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags))
41 tty_port_tty_wakeup(&acm->port);
42 - clear_bit(EVENT_TTY_WAKEUP, &acm->flags);
43 - }
44 }
45
46 /*