Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1193431pxa; Thu, 20 Aug 2020 05:16:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqQ/tCadGCC0gj9GkqLLh50+DjZleBzb3zFdax4rnedjNy6N29F69s6E+n8QEqfK2WTDXz X-Received: by 2002:aa7:d411:: with SMTP id z17mr2595203edq.85.1597925807040; Thu, 20 Aug 2020 05:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597925807; cv=none; d=google.com; s=arc-20160816; b=yFpC/YkwOXkiJEgwCW/wrnlY8sTrR7FTQNMo7++Lxqv8IdmRdQ/JnGJEle3uRmsLn9 VTDin0mqP9vMpWQGbLt+vv+JPbbngKYQykEzIyb7dF50KzwE7dNCRABaD0NpFWAYUD7m jvsmHqehB6zQIJrhJ41nuTUa93e38w4pp3BniWjybt5wXfW3GOS5UrHCIMQvg7vFJwcd Qdo6KFWhnwHH3cvbv9z1Lpi8B/WrdQq49SZxB7CL4pgKYRbLyBkbYyBuBRNIeAKYFFdP rBbacbHODrj1L4XJivd8FfAvOXR1neMUNHBAHJ2qb3Pr8r9wvKy16UJ1Jvc1X/4K4lnf 6trA== 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=9pYRNRmpa+7eYrRQCo0KVPU5W2hwDLI3r/FbTDX2BCg=; b=gEs4vc3ERvGzvVwlGJNFXaghlWabGyGfsdjRpOAuxjHRZjG61mguBer+oMPU1pSRRY hpV/oT8/3OYgcLj3RzgZMNpS0F/y5MQfIbGWiHHlcXL7Ico7dgzZ/WNTpPOdvhl56UN1 qZ55GpKEQwus06s4lJKhKRMDBeeFHwRczDaHPzeJncMFbxLU4aWqq1M46CzCuPi0XDHw ZMFSlzwOb5GzZOuq6LzIhQwdCxD38jJnGxtTPWhwqsf7hctLXgxrQYRHFzh1+Qz4rVuU AxHSEk9hTHDoySlK2WEMl9pXgFOBJiETppdaq2QlJScSF4uX0H/PZQhihl9DL7PdOPff dwaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="S/iCbZxj"; 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=fail (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 h11si1040240ejy.197.2020.08.20.05.16.23; Thu, 20 Aug 2020 05:16:47 -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=@kernel.org header.s=default header.b="S/iCbZxj"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729079AbgHTMPx (ORCPT + 99 others); Thu, 20 Aug 2020 08:15:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:40800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730277AbgHTJ5H (ORCPT ); Thu, 20 Aug 2020 05:57:07 -0400 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 B68682067C; Thu, 20 Aug 2020 09:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597917427; bh=MKw2zkMoNR52NXZ05/K5N9/DFpLHpLYLSmvRfyKtOcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S/iCbZxjVyJfkrkoOehky7EPzM810w/fpb5yV2WZURX+Y1IGi2NjN+h5kJu4jPUKf h3U5xIY+MbZjBPSrMSR1mR7hhMIls8r208Aoo2SrjsA5njpNa6DGuZcm7MrnhflVfZ CyW2KBW8HevhQg3UB1iq4qCwXdQOlWtAMikgXSPc= 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" , Sasha Levin Subject: [PATCH 4.9 027/212] net: lan78xx: add missing endpoint sanity check Date: Thu, 20 Aug 2020 11:20:00 +0200 Message-Id: <20200820091603.715508712@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091602.251285210@linuxfoundation.org> References: <20200820091602.251285210@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: Johan Hovold [ Upstream commit 8d8e95fd6d69d774013f51e5f2ee10c6e6d1fc14 ] Add the missing endpoint sanity check to prevent a NULL-pointer dereference should a malicious device lack the expected endpoints. Note that the driver has a broken endpoint-lookup helper, lan78xx_get_endpoints(), which can end up accepting interfaces in an altsetting without endpoints as long as *some* altsetting has a bulk-in and a bulk-out endpoint. Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Cc: Woojung.Huh@microchip.com Signed-off-by: Johan Hovold Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/lan78xx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 65e94dffaabc9..fd144a513e1fe 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3392,6 +3392,11 @@ static int lan78xx_probe(struct usb_interface *intf, netdev->mtu = dev->hard_mtu - netdev->hard_header_len; netif_set_gso_max_size(netdev, MAX_SINGLE_PACKET_SIZE - MAX_HEADER); + if (intf->cur_altsetting->desc.bNumEndpoints < 3) { + ret = -ENODEV; + goto out3; + } + dev->ep_blkin = (intf->cur_altsetting)->endpoint + 0; dev->ep_blkout = (intf->cur_altsetting)->endpoint + 1; dev->ep_intr = (intf->cur_altsetting)->endpoint + 2; -- 2.25.1