Re: KASAN: use-after-free Read in si470x_int_in_callback (2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 27 Nov 2019, syzbot wrote:

> Hello,
> 
> syzbot has tested the proposed patch but the reproducer still triggered  
> crash:
> INFO: rcu detected stall in dummy_timer
> 
> radio-si470x 5-1:0.0: non-zero urb status (-71)
> radio-si470x 3-1:0.0: non-zero urb status (-71)
> rcu: INFO: rcu_sched self-detected stall on CPU
> rcu: 	1-....: (8213 ticks this GP) idle=4f6/1/0x4000000000000004  

Almost the same as Oliver's patch, but this one stops when the 
interrupt-IN URB gets an unrecognized error status.

Alan Stern

#syz test: https://github.com/google/kasan.git 22be26f7

Index: usb-devel/drivers/media/radio/si470x/radio-si470x-usb.c
===================================================================
--- usb-devel.orig/drivers/media/radio/si470x/radio-si470x-usb.c
+++ usb-devel/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -370,15 +370,14 @@ static void si470x_int_in_callback(struc
 	unsigned char tmpbuf[3];
 
 	if (urb->status) {
-		if (urb->status == -ENOENT ||
+		if (!(urb->status == -ENOENT ||
 				urb->status == -ECONNRESET ||
-				urb->status == -ESHUTDOWN) {
-			return;
-		} else {
+				urb->status == -ESHUTDOWN))
 			dev_warn(&radio->intf->dev,
-			 "non-zero urb status (%d)\n", urb->status);
-			goto resubmit; /* Maybe we can recover. */
-		}
+					"unrecognized urb status (%d)\n",
+					urb->status);
+		radio->int_in_running = 0;
+		return;
 	}
 
 	/* Sometimes the device returns len 0 packets */
@@ -542,6 +541,8 @@ static int si470x_start_usb(struct si470
 		radio->int_in_running = 0;
 	}
 	radio->status_rssi_auto_update = radio->int_in_running;
+	if (retval < 0)
+		return retval;
 
 	/* start radio */
 	retval = si470x_start(radio);
@@ -734,7 +735,8 @@ static int si470x_usb_driver_probe(struc
 	/* start radio */
 	retval = si470x_start_usb(radio);
 	if (retval < 0)
-		goto err_buf;
+		/* the urb may be running even after an error */
+		goto err_all;
 
 	/* set initial frequency */
 	si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
@@ -749,7 +751,7 @@ static int si470x_usb_driver_probe(struc
 
 	return 0;
 err_all:
-	usb_kill_urb(radio->int_in_urb);
+	usb_poison_urb(radio->int_in_urb);
 err_buf:
 	kfree(radio->buffer);
 err_ctrl:
@@ -824,7 +826,7 @@ static void si470x_usb_driver_disconnect
 	mutex_lock(&radio->lock);
 	v4l2_device_disconnect(&radio->v4l2_dev);
 	video_unregister_device(&radio->videodev);
-	usb_kill_urb(radio->int_in_urb);
+	usb_poison_urb(radio->int_in_urb);
 	usb_set_intfdata(intf, NULL);
 	mutex_unlock(&radio->lock);
 	v4l2_device_put(&radio->v4l2_dev);




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux