patch "USB: serial: cyberjack: fix write-URB completion race" added to usb-linus
Subsystems (3)
This is a note to let you know that I've just added the patch titled
USB: serial: cyberjack: fix write-URB completion race
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 985616f0457d9f555fff417d0da56174f70cc14f Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Mon, 26 Oct 2020 09:25:48 +0100
Subject: USB: serial: cyberjack: fix write-URB completion race
The write-URB busy flag was being cleared before the completion handler was done with the URB, something which could lead to corrupt transfers due to a racing write request if the URB is resubmitted.
--- drivers/usb/serial/cyberjack.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/serial/cyberjack.c +6 -1
@@ -357,11 +357,12 @@ static void cyberjack_write_bulk_callback(struct urb *urb)struct device *dev = &port->dev;int status = urb->status;unsigned long flags; +bool resubmitted = false; -set_bit (0 , &port->write_urbs_free);if (status) {dev_dbg (dev,"%s - nonzero write bulk status received: %d\n" , __func__, status); +set_bit (0 , &port->write_urbs_free);return ; }
@@ -394,6 +395,8 @@ static void cyberjack_write_bulk_callback(struct urb *urb) goto exit; } + resubmitted = true; +dev_dbg (dev,"%s - priv->wrsent=%d\n" , __func__, priv->wrsent);dev_dbg (dev,"%s - priv->wrfilled=%d\n" , __func__, priv->wrfilled);
@@ -410,6 +413,8 @@ static void cyberjack_write_bulk_callback(struct urb *urb) exit:spin_unlock_irqrestore (&priv->lock, flags); +if (!resubmitted) +set_bit (0 , &port->write_urbs_free);usb_serial_port_softint (port); }
Signature · 1 line
2.29.2