Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3558118pxb; Mon, 24 Jan 2022 12:10:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXQX/3VhgeJ8lr5WDAGxNVpJGGiznk7ik6F9ZaEqbW+8vOyJUYZyMDTnLoJh7BCJeP0mbk X-Received: by 2002:a65:6149:: with SMTP id o9mr12763881pgv.144.1643055057111; Mon, 24 Jan 2022 12:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055057; cv=none; d=google.com; s=arc-20160816; b=QTO1yoaQXdh0uxtMnhBV3TDpAki0ZF3RBKYMEX1hD9Kobvl3G2XA+9fDFT7BGWO4dk XoLf7TDW2mGc2zWtANKMP5xYG94znPi2xwwy+znAUvIV40tiSl4/BzzTKc+zF2nkygAL ataiH1dWSOHEVIFN51Wl+V28rwTSEE0ANxCjKCmQBSBrLy0t+0desprB9Isj4Jd2S3sz F9aWkYTYh70IsBPY/pcRvzB8EsjPdV2smUKwAW/gLWF/IuYOgMS1/+0KO5M2zhyy2E8w rrncZgF8vp0lbPptnSAitbuOn4coYczDGFQzP3iCLbquBM1I4r6JayUQAGcGQlLrNFZs Hg8A== 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=fzHyz3bVcqnjDYnlQTg/Hq49LPrT1Dg/UDQ0bkQzyok=; b=lElasu1wTQhYBJRNQL2JQbLRunx7XlfGzoG/kThXHHrSCxhF1y4P9KgrGvGQcIDN1A AsOEFlvRwou/QzWzYhugTpLOQwHDDoaB+JADUjOYvZUxj16xNvjOODWVWt97QBhmUi9e aISp8pv501Mz/uHMQ6i/a2Wh1uwpoAVMpqHN6SdB5rpJcUpGX/8ptrQcnGuHB7AyeWXT kJ+PTfcnPm2c8y2cDZ8fpWp64iGx9QlirZIPxc0D+Y1eWqbO/OGEaTxbLB6xhy/YhpyS RKMKygBvlm2E3srauzG4U/nG6V5OGpkDLrMstcigL0emgCr9rHGe5wEyvWYO38oJomiP ozDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DC115jhZ; 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 e7si13797358pgg.78.2022.01.24.12.10.44; Mon, 24 Jan 2022 12:10:57 -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=DC115jhZ; 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 S1346638AbiAXTJM (ORCPT + 99 others); Mon, 24 Jan 2022 14:09:12 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:59542 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345162AbiAXTCt (ORCPT ); Mon, 24 Jan 2022 14:02:49 -0500 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 DDCCEB8122F; Mon, 24 Jan 2022 19:02:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E8B0C340E5; Mon, 24 Jan 2022 19:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050966; bh=iQYLBwzLMi48bseQjprm7HaXg8owdAOoP16c2+NUHWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DC115jhZyzdXOYOacuYls6ZnGf+gfSLh/IlDgECaVEnkrRvfiLebjuFtjyWYoXx8X t90rvPYTyPC9jW9OklBtaEBGJMn2Yvez1cFeDRW+e6JTapGh/PLT039Sag6QNHzCi7 QtTwdv8rtfKbVfGzOcvkQk4bMv5YZ1ZHRpUJyw0U= 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.14 012/186] media: uvcvideo: fix division by zero at stream start Date: Mon, 24 Jan 2022 19:41:27 +0100 Message-Id: <20220124183937.507289946@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 @@ -1711,6 +1711,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); }