Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2826429pxb; Mon, 1 Nov 2021 02:37:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwppJ7X+TmAm//Gu+YPT0vgcqh0dqFEO040x0s+oXTiLfAy8gIPown7nerKxxMedZBeiDzP X-Received: by 2002:a17:907:6e9e:: with SMTP id sh30mr35227100ejc.51.1635759463562; Mon, 01 Nov 2021 02:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635759463; cv=none; d=google.com; s=arc-20160816; b=oX6TmJUhlBWhk8Ahk+otbLz72/2up/zBs2jtKvOUUtJKygWpVG3yoADjLcH9oeZcxe V9F1Ij6w9RcD48eNmd9VdkFFb/MtvWr6Pv3pZ1jLVbw6akKycBg5eXA6dZwqIQkjkwXb CTmxRF2Ml1vAPTRlyhOs3hKsPCfPpqFRfVdBM2gw1lK8oVMmN0oGPu+ekCOzedGsPcyy mPVsVbyfiHrKHgaKShvbwPuztouJiMBLPG1DbxIX0gwzGMfGwFuw2KF8or5GmeAlrXef HqZmw2+T59Ay7ZFua3r5FCi34550JPXwh1A4h7OFwz3yE3GVseceZ61T2IAeuEYXWVEl nokQ== 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=MAfpM6vszClmd0RYkClWsBmeJ9oQPmCjMGFW89WQ4E4=; b=vLZeTYbWcpXPedVHClFOmvtUP3AOFs8JlsnUgTEjCH5EKgG6ZpFApk+yqqroJlQoKY XHX4mW0FEGhoVLLfiD/OSOcDyJ0aQKs7sUOV64nHSL8h1Ge15xeNI9NkZewBjR8qFFK/ 2dKwMBIpyrPlNTnrxhldMs63W/xnrmtR3NgHdUaeFwcyI/rvSQfcd3LkBIezHmQlFoUp AjjjFKs1sIkEW1oeOXAPkbbIPzbGuBHlnXUNhEMWxy1F9BO3q5vNn9DbtVmT0vl2bIzf oociwsqdHVMceUJ2IK1skdxhHMOxOKyBB3mzFSM7FHPlRHk3PmA/OQ8Bm/nwSZGdak74 4boQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oBkmAVpf; 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 i11si25295669edb.538.2021.11.01.02.37.12; Mon, 01 Nov 2021 02:37:43 -0700 (PDT) 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=oBkmAVpf; 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 S233223AbhKAJhy (ORCPT + 99 others); Mon, 1 Nov 2021 05:37:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:43646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233670AbhKAJdx (ORCPT ); Mon, 1 Nov 2021 05:33:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3EE0E61260; Mon, 1 Nov 2021 09:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758723; bh=0Mc7zX9jlYQRhs95FnVD17qXmj+1awjseC/rhz120s4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oBkmAVpfWl/ff53sL6QbuFXUnkEf4vJCiktSkw2mG7rUJt/90frmSvEEWOI615Nrm 3FBbKBBYh0Hf2My94mHa8iCBia3L949/ry7931rJ0uwvlkn9e77oS47geNA6Ahm88q AuMkcdgi6WPpnLz47Z0XImu6XvRFYi6skMlGpu3o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Woojung.Huh@microchip.com" , Johan Hovold , "David S. Miller" Subject: [PATCH 5.10 30/77] net: lan78xx: fix division by zero in send path Date: Mon, 1 Nov 2021 10:17:18 +0100 Message-Id: <20211101082518.247237161@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082511.254155853@linuxfoundation.org> References: <20211101082511.254155853@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 db6c3c064f5d55fa9969f33eafca3cdbefbb3541 upstream. Add the missing endpoint max-packet sanity check to probe() to avoid division by zero in lan78xx_tx_bh() 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: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Cc: stable@vger.kernel.org # 4.3 Cc: Woojung.Huh@microchip.com Signed-off-by: Johan Hovold Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/lan78xx.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3745,6 +3745,12 @@ static int lan78xx_probe(struct usb_inte dev->maxpacket = usb_maxpacket(dev->udev, dev->pipe_out, 1); + /* Reject broken descriptors. */ + if (dev->maxpacket == 0) { + ret = -ENODEV; + goto out4; + } + /* driver requires remote-wakeup capability during autosuspend. */ intf->needs_remote_wakeup = 1;