Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3552099pxb; Mon, 24 Jan 2022 12:03:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHG3jbYTaQ/b8xgAJflVacfuO4JeJUEGOINlgC9PG3nZ9uq+jkTh7V94iKrVQslGfJITY9 X-Received: by 2002:a17:902:8ec7:b0:149:8d21:3e49 with SMTP id x7-20020a1709028ec700b001498d213e49mr15425221plo.111.1643054602221; Mon, 24 Jan 2022 12:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054602; cv=none; d=google.com; s=arc-20160816; b=sP/eus6YhSwCDshLMvFDgsaFrCiQtMTzf2KIAl5PBiaoyGLUF04wrIba73xZcvpzsN fNwR1OljI3VjUrarjWI3D/Jx7J+oV9fZiU3/34IYtm6rHtcuY4i6Ygurs7YjuAByfDlb s6kDNBNz+ieIzEzgw2PBX87Mik4G9JNxnkiVlIkBxcGmB5WPpBm4+45IJSCP/cy93nUF g8XSXohwWEnFVuZBb9ri4ELv62P2fT+fJqpRwo+Gh+NyT3/DFR4C1r3fcpNedftmgMLq XHfGVn5QzAmwOpGc7cnlzjTdciQ6uCZoHN/Y+7WQFOm2jxgNjkyJsiRKqJc4BKJgUusl LN4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aUUOhRu+zwUNq3RhhnmKi8Nogn8s/q0HRa9DvOXoNLQ=; b=JWOGHmJ+ZBF0jdrLtYt2KlPLWBVrXG/m9svrneN6C1odIHEDYC5B4/EkPAIlZV62FX mbog9viQ7jhuLC+AbgfKl4IuPbSpglO7IWX/VNMwo3A6CQegaSt5dmaxItSYksipih9P e/pZ7Ws8oVrHb1EQwSZtxGbjQwHg3vavWSrxa9uzjkEz5nD0jdCKvlc3ZLB1o4u8Yo5T fvQcUFylOzM/GGk6Q371dNztT6UicNMLyE/uQ3oQTwhYhFN9bojszCUshEc312pKGbwQ raKbBWicK/l7BtrmFKkn6nhdJZ8Jw/nSvlDJZU1zWO9ddOxMJ5OiDYh3haHQgWNql5gt 5dYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FNxuwaGZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a11si8290440pfx.24.2022.01.24.12.03.07; Mon, 24 Jan 2022 12:03:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FNxuwaGZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343631AbiAXTCx (ORCPT + 99 others); Mon, 24 Jan 2022 14:02:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344428AbiAXS6z (ORCPT ); Mon, 24 Jan 2022 13:58:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D11E2C061340; Mon, 24 Jan 2022 10:56:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8CD35B81235; Mon, 24 Jan 2022 18:56:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A75F5C340E5; Mon, 24 Jan 2022 18:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050568; bh=qJGO70c2a2ulGpa0+3IZx4+4uG78TZ2lXQht9kVfXc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FNxuwaGZwxI80bsVBV3WUgS82GeD6igNUo69pb20wAb2zgZw1dEOWN9bdS9qJ45FV S2EMF9Ab5xKJt5DKPN9bP30bHbDpoQ5iOANqaVFObdU//6bM0pfCzbrZcpUCQiPhwU kqKZxxd9V3sBA5UvmrhH0CYciHaJf129+PD5P1H0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Kieran Bingham , Laurent Pinchart , Mauro Carvalho Chehab Subject: [PATCH 4.9 011/157] media: uvcvideo: fix division by zero at stream start Date: Mon, 24 Jan 2022 19:41:41 +0100 Message-Id: <20220124183933.144507896@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183932.787526760@linuxfoundation.org> References: <20220124183932.787526760@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit 8aa637bf6d70d2fb2ad4d708d8b9dd02b1c095df upstream. Add the missing bulk-endpoint max-packet sanity check to uvc_video_start_transfer() to avoid division by zero in uvc_alloc_urb_buffers() in case a malicious device has broken descriptors (or when doing descriptor fuzz testing). Note that USB core will reject URBs submitted for endpoints with zero wMaxPacketSize but that drivers doing packet-size calculations still need to handle this (cf. commit 2548288b4fb0 ("USB: Fix: Don't skip endpoint descriptors with maxpacket=0")). Fixes: c0efd232929c ("V4L/DVB (8145a): USB Video Class driver") Cc: stable@vger.kernel.org # 2.6.26 Signed-off-by: Johan Hovold Reviewed-by: Kieran Bingham Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/uvc/uvc_video.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1716,6 +1716,10 @@ static int uvc_init_video(struct uvc_str if (ep == NULL) return -EIO; + /* Reject broken descriptors. */ + if (usb_endpoint_maxp(&ep->desc) == 0) + return -EIO; + ret = uvc_init_video_bulk(stream, ep, gfp_flags); }