Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5743232ybe; Tue, 17 Sep 2019 12:45:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhM/qglPPS2IEqbVaDLincYePhiOlov5L1KjVUb13uBg6ZRlOrsvufrVEaDFC7MyWQF9JN X-Received: by 2002:aa7:ce02:: with SMTP id d2mr6567304edv.270.1568749538651; Tue, 17 Sep 2019 12:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568749538; cv=none; d=google.com; s=arc-20160816; b=DpwikJq7g8ti3AQQySF+TlexHstJeTQsqI+8vchyIhKYVgN7pEpceo3TRVahR4L7C5 4+GVlfZPFF5TyYN6ygDP099MzbY5nmvX7nUFXGVON536wdAqy1ivIZ7LUr5I2OW0e7rZ qW74kDc9gaVAAfjxXCNU1ocyRTnHJRk7V1fO3xpxdnowBOa0jUwfMDqnJXl0uF6ZPd11 Klr7A0rBcmracFfLqb1bOtViNdXCVqXzZw2KmQ3S0fkGyHXeFTDckvXSsjh46hMd2oXt 0KSzrGPjDnPvvNCckmbdeQemd4MiK1wzUjIXK/gWLGsOJPyx9p5ElDK/yQ+rPjqz3ICs PLPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=wQ8YTO0kMS/xLeG8bkfn0WB75o/GWMqEp3R2RNZZsWI=; b=T4qntC1dFccH9JeAIgVkDfXmYiV7COKmoQp3aTbY74OfN/8L5sFMqKfKYK+scP468Z 5mEjfS42PSM25w0n5uem+j9ChM+9v1IGe3SOA7DtKBZPW2JC4bFZGOtv54fkIUgs0oez nTdCkBZ9oKsX5tM5hoVXkeP3bJo78SqQvq9w99JRMNSTMbHjpMnugsMVHPWx0geY789c 0X7Oqsw0ih3fiI4KwGDu0Yqi5wvLFM0jWCOS0kIiQnL9G2kQZ9HP0KtXlGafA8b4blyT l4qRTOH2E20PAr8zXQsDTsGGHlZsFOqaP/CHj9XoaOpmjHqxuN5J6GUi/iKBRPa7nwp3 j9vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q28si1903142eda.322.2019.09.17.12.45.14; Tue, 17 Sep 2019 12:45:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727270AbfIQSbb (ORCPT + 99 others); Tue, 17 Sep 2019 14:31:31 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:39308 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726505AbfIQSbb (ORCPT ); Tue, 17 Sep 2019 14:31:31 -0400 Received: (qmail 7234 invoked by uid 2102); 17 Sep 2019 14:31:30 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 17 Sep 2019 14:31:30 -0400 Date: Tue, 17 Sep 2019 14:31:30 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: syzbot cc: andreyknvl@google.com, , , , , , , Subject: Re: general protection fault in usb_set_interface In-Reply-To: <000000000000e08e490592c3b2c4@google.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Sep 2019, syzbot wrote: > Hello, > > syzbot tried to test the proposed patch but build/boot failed: Oops. Typo. #syz test: https://github.com/google/kasan.git f0df5c1b drivers/media/usb/usbvision/usbvision-video.c | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) Index: usb-devel/drivers/media/usb/usbvision/usbvision-video.c =================================================================== --- usb-devel.orig/drivers/media/usb/usbvision/usbvision-video.c +++ usb-devel/drivers/media/usb/usbvision/usbvision-video.c @@ -314,6 +314,10 @@ static int usbvision_v4l2_open(struct fi if (mutex_lock_interruptible(&usbvision->v4l2_lock)) return -ERESTARTSYS; + if (usbvision->remove_pending) { + err_code = -ENODEV; + goto unlock; + } if (usbvision->user) { err_code = -EBUSY; } else { @@ -377,6 +381,7 @@ unlock: static int usbvision_v4l2_close(struct file *file) { struct usb_usbvision *usbvision = video_drvdata(file); + int r; PDEBUG(DBG_IO, "close"); @@ -391,9 +396,10 @@ static int usbvision_v4l2_close(struct f usbvision_scratch_free(usbvision); usbvision->user--; + r = usbvision->remove_pending; mutex_unlock(&usbvision->v4l2_lock); - if (usbvision->remove_pending) { + if (r) { printk(KERN_INFO "%s: Final disconnect\n", __func__); usbvision_release(usbvision); return 0; @@ -453,6 +459,9 @@ static int vidioc_querycap(struct file * { struct usb_usbvision *usbvision = video_drvdata(file); + if (!usbvision->dev) + return -ENODEV; + strscpy(vc->driver, "USBVision", sizeof(vc->driver)); strscpy(vc->card, usbvision_device_data[usbvision->dev_model].model_string, @@ -1073,6 +1082,11 @@ static int usbvision_radio_open(struct f if (mutex_lock_interruptible(&usbvision->v4l2_lock)) return -ERESTARTSYS; + + if (usbvision->remove_pending) { + err_code = -ENODEV; + goto out; + } err_code = v4l2_fh_open(file); if (err_code) goto out; @@ -1105,21 +1119,24 @@ out: static int usbvision_radio_close(struct file *file) { struct usb_usbvision *usbvision = video_drvdata(file); + int r; PDEBUG(DBG_IO, ""); mutex_lock(&usbvision->v4l2_lock); /* Set packet size to 0 */ usbvision->iface_alt = 0; - usb_set_interface(usbvision->dev, usbvision->iface, + if (usbvision->dev) + usb_set_interface(usbvision->dev, usbvision->iface, usbvision->iface_alt); usbvision_audio_off(usbvision); usbvision->radio = 0; usbvision->user--; + r = usbvision->remove_pending; mutex_unlock(&usbvision->v4l2_lock); - if (usbvision->remove_pending) { + if (r) { printk(KERN_INFO "%s: Final disconnect\n", __func__); v4l2_fh_release(file); usbvision_release(usbvision); @@ -1551,6 +1568,7 @@ err_usb: static void usbvision_disconnect(struct usb_interface *intf) { struct usb_usbvision *usbvision = to_usbvision(usb_get_intfdata(intf)); + int u; PDEBUG(DBG_PROBE, ""); @@ -1567,13 +1585,14 @@ static void usbvision_disconnect(struct v4l2_device_disconnect(&usbvision->v4l2_dev); usbvision_i2c_unregister(usbvision); usbvision->remove_pending = 1; /* Now all ISO data will be ignored */ + u = usbvision->user; usb_put_dev(usbvision->dev); usbvision->dev = NULL; /* USB device is no more */ mutex_unlock(&usbvision->v4l2_lock); - if (usbvision->user) { + if (u) { printk(KERN_INFO "%s: In use, disconnect pending\n", __func__); wake_up_interruptible(&usbvision->wait_frame);