Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6003589ybc; Wed, 27 Nov 2019 13:13:49 -0800 (PST) X-Google-Smtp-Source: APXvYqz0aSOw3cONfOzIcP1ULcsWfmB81a4ASue017TX/Q4wnRadQu24aPU6GESQQi5tCqIN+66O X-Received: by 2002:a05:6402:17ac:: with SMTP id j12mr2987722edy.233.1574889229139; Wed, 27 Nov 2019 13:13:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574889229; cv=none; d=google.com; s=arc-20160816; b=axCN4wLaK/0GbZfEZYiiAs8AoM1W/018s5gLugZdneZy4zcvpq486khsSVO8YrO/V8 UUj9uD9ILcVxC/QpYlzWLOf6i9ZiBfZy6gw3CZJX5YgQVJRLO3cg5XuZSjzBSsg8GXoB lKwmAJEodbQ9jenZEt/KjKb0t/chTqkp4OX8pKHvWp9bUu24ERtKMHqPcabgkaeliOmv HVOYuPJZskj7BaFD5KqaNasP5klSihDgH9+N7cFWkPmCdWqlRcWJ7A5Obw9jGKrnVYsA QdMkyW+zNNGc8dvoA4GtVbcsmjs4dnhA5ek5cpCqKPxI+zoSDGdkEfK7cknQXjW9m1+L 4PDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SM9Nu7HLLW6dJBK9ribZWDb0dIyTg06uQVKByYinOPw=; b=CJIPgQ7KBjimn4n4s1hyEyyvycWbXQVBGpD8IX2sFTVKoXGU+fVmJI+P+8OJfWABtB +o0SF3XzumGF3uuHKiYinuFYLZlpDmxwBz/Gk+Jg04QgzHzXgvgw6FdGXKV0GiFB+b+M O1/ksQoHHjkczXUTbfLEXazTUswpZEubEuDQtwOzz40kTAdMMX8Kk9TX7b8y97WssXED CcY9P3hv3aiZC/8KDTvMXG6gaJ0+Kp04cZFZUI+Fl1Vk99Vas/A5uO5xtP2LIU4a7rPf nnAShQ25Bkxj1pS6MGR1FfyTvN7pNzCy64fmlsCGT4Sfk6sd/wD3fv6CWDEoFeEy8RP4 AI7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I268DJvK; 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 p8si10549691edq.55.2019.11.27.13.13.25; Wed, 27 Nov 2019 13:13:49 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=I268DJvK; 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 S1733155AbfK0VLU (ORCPT + 99 others); Wed, 27 Nov 2019 16:11:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:39524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733135AbfK0VLO (ORCPT ); Wed, 27 Nov 2019 16:11:14 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D82272086A; Wed, 27 Nov 2019 21:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574889073; bh=XewPO8fLf1dj292J0MSmdr6EgWIOaBabmwa/gqziDyk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I268DJvKlmCQ1QK0yGgYJ7Tg965WnWura3nJWGNTQc/tm0BxdKWWYghiOah49DG0B FEUP1fEKrNMsfvZd/OC36qgm1ps+6EVTmHEcZS4dEgfhk7EGcorAAnAB3jxt/8jhpM Kt9H4V/s4wjNKCld+FjxVnzRUKg/3t9mqe8E79Mo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Hans Verkuil , Mauro Carvalho Chehab , syzbot+7fa38a608b1075dfd634@syzkaller.appspotmail.com Subject: [PATCH 5.3 72/95] media: usbvision: Fix invalid accesses after device disconnect Date: Wed, 27 Nov 2019 21:32:29 +0100 Message-Id: <20191127202938.704789013@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127202845.651587549@linuxfoundation.org> References: <20191127202845.651587549@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alan Stern commit c7a191464078262bf799136317c95824e26a222b upstream. The syzbot fuzzer found two invalid-access bugs in the usbvision driver. These bugs occur when userspace keeps the device file open after the device has been disconnected and usbvision_disconnect() has set usbvision->dev to NULL: When the device file is closed, usbvision_radio_close() tries to issue a usb_set_interface() call, passing the NULL pointer as its first argument. If userspace performs a querycap ioctl call, vidioc_querycap() calls usb_make_path() with the same NULL pointer. This patch fixes the problems by making the appropriate tests beforehand. Note that vidioc_querycap() is protected by usbvision->v4l2_lock, acquired in a higher layer of the V4L2 subsystem. Reported-and-tested-by: syzbot+7fa38a608b1075dfd634@syzkaller.appspotmail.com Signed-off-by: Alan Stern CC: Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/usbvision/usbvision-video.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/media/usb/usbvision/usbvision-video.c +++ b/drivers/media/usb/usbvision/usbvision-video.c @@ -453,6 +453,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, @@ -1111,8 +1114,9 @@ static int usbvision_radio_close(struct mutex_lock(&usbvision->v4l2_lock); /* Set packet size to 0 */ usbvision->iface_alt = 0; - usb_set_interface(usbvision->dev, usbvision->iface, - usbvision->iface_alt); + if (usbvision->dev) + usb_set_interface(usbvision->dev, usbvision->iface, + usbvision->iface_alt); usbvision_audio_off(usbvision); usbvision->radio = 0;