Stable Archive on
 help / color / Atom feed
* patch "USB: iowarrior: fix use-after-free on disconnect" added to usb-linus
@ 2019-10-10 10:45 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2019-10-10 10:45 UTC (permalink / raw)
  To: johan, gregkh, stable

This is a note to let you know that I've just added the patch titled

    USB: iowarrior: fix use-after-free on disconnect

to my usb git tree which can be found at
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 edc4746f253d907d048de680a621e121517f484b Mon Sep 17 00:00:00 2001
From: Johan Hovold <>
Date: Wed, 9 Oct 2019 12:48:41 +0200
Subject: USB: iowarrior: fix use-after-free on disconnect

A recent fix addressing a deadlock on disconnect introduced a new bug
by moving the present flag out of the critical section protected by the
driver-data mutex. This could lead to a racing release() freeing the
driver data before disconnect() is done with it.

Due to insufficient locking a related use-after-free could be triggered
also before the above mentioned commit. Specifically, the driver needs
to hold the driver-data mutex also while checking the opened flag at

Fixes: c468a8aa790e ("usb: iowarrior: fix deadlock on disconnect")
Fixes: 946b960d13c1 ("USB: add driver for iowarrior devices.")
Cc: stable <>	# 2.6.21
Signed-off-by: Johan Hovold <>
Signed-off-by: Greg Kroah-Hartman <>
 drivers/usb/misc/iowarrior.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index f5bed9f29e56..4fe1d3267b3c 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -866,8 +866,6 @@ static void iowarrior_disconnect(struct usb_interface *interface)
 	dev = usb_get_intfdata(interface);
 	usb_set_intfdata(interface, NULL);
-	/* prevent device read, write and ioctl */
-	dev->present = 0;
 	minor = dev->minor;
@@ -878,8 +876,7 @@ static void iowarrior_disconnect(struct usb_interface *interface)
 	/* prevent device read, write and ioctl */
-	mutex_unlock(&dev->mutex);
+	dev->present = 0;
 	if (dev->opened) {
 		/* There is a process that holds a filedescriptor to the device ,
@@ -889,8 +886,10 @@ static void iowarrior_disconnect(struct usb_interface *interface)
+		mutex_unlock(&dev->mutex);
 	} else {
 		/* no process is using the device, cleanup now */
+		mutex_unlock(&dev->mutex);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10 10:45 patch "USB: iowarrior: fix use-after-free on disconnect" added to usb-linus gregkh

Stable Archive on

Archives are clonable:
	git clone --mirror stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ \
	public-inbox-index stable

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox