Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2025558pxa; Mon, 3 Aug 2020 05:42:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD2oeD8ax58TP8B/2FoGdHvQ4FZFToKE6WAYnEEnN2+FBfpTpV70CcHxbowsG7K6KiFEDg X-Received: by 2002:a17:906:68e:: with SMTP id u14mr17412558ejb.166.1596458565461; Mon, 03 Aug 2020 05:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596458565; cv=none; d=google.com; s=arc-20160816; b=FYkivLvHrs5q/rfhdIxED493Z3tbT2Zj05BskepLyUXTKBtVBI64qsfyxXGJjMh6Ye gIgkxDkWX3VEAqbioP6K9YjDXjQugg3UNNUTwrm/+rGn6bJfu/Kr+BS3ft8xtbudhW83 6EzzME8QEhwtLl9pVnDXdvAi5AamOWbI358+quYv8Ge0WsdGWlhmI2J8q9QHlyfY8ZNt VQglAPyBwaj2ZMoqxUlybTxuremgdpHkB+ULFEGY9aAKVluFKFMm1beOxJYfLzbzE6VN ShRoY5i/P4WgYsN9LdWVIEQEjclz3J4dHDmBb8d88FnHOCRZOHrvFSip5zr1Ll1qCzJC 2FLg== 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=DT+9W+MhO3FDPvgroJJe971JVvLDDzMlHbzrIre1v80=; b=o0RQpmXyjfCyFjLH0IW9aI+J+iL84m+eSDxOVitsD9m1jBJUy5tQlhJsSRcPd0U2/h R54WXM1LPiF8aUjxy5f+jO0WoOcSBYdU3KlPUk4E/IKX56nbcaVYMGIN8IcjlHSeYmJv K+jJFJO2AiDvoRwpxDdB5LM+eXi8QoiXvMskuvYEPRWo1tWBGxuk4bcWTmVmJDHZyr81 a5HdMT5Xs4CugBu+cF0jk8nD16R9XlG6yy64mlCgSzGVjEjVFzhIte1cCUWUf1b9MGKs fRPb2Jjiv8S78oWgKCib5EZe+g0g7NGxxott/pOjF6DRYXbJFoVjl8YNp/4baoS6RyK8 wZlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pHHfXhcG; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rl26si3017054ejb.568.2020.08.03.05.42.23; Mon, 03 Aug 2020 05:42:45 -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=pHHfXhcG; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728408AbgHCMlw (ORCPT + 99 others); Mon, 3 Aug 2020 08:41:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:59970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729261AbgHCMcH (ORCPT ); Mon, 3 Aug 2020 08:32: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 011FB204EC; Mon, 3 Aug 2020 12:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596457925; bh=8OoNLzM9mef1N3xrgx4IKRdDJjPBJpJae6hwQNZo8l0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pHHfXhcGB8ogAL0N2mICFSh7K5FGkd7mjSVYLEn3LR0YKbcFJsiFfLdAiE4bhscpN x2aecNrcEDmIEHt4fwXWvzAA7M62NBaaHIrL1CBFyOJqLZPdhsnzxaBIp75QeLujDO /BHR+0I2jnakj/3qOEbiDtfvMXiqXaOLANBPluDk= 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.19 32/56] net: lan78xx: add missing endpoint sanity check Date: Mon, 3 Aug 2020 14:19:47 +0200 Message-Id: <20200803121851.898829519@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200803121850.306734207@linuxfoundation.org> References: <20200803121850.306734207@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 92548887df2fe..2dff233814ea5 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3786,6 +3786,11 @@ static int lan78xx_probe(struct usb_interface *intf, netdev->max_mtu = MAX_SINGLE_PACKET_SIZE; 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