Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp445535iog; Mon, 13 Jun 2022 06:08:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSla5qXHMFrddRlN5kENdwrZA5+VbS9qgkR7bVFkwM0ffxoFckl+rx4WayW3Tl6PECDIKp X-Received: by 2002:a17:907:7e90:b0:704:b67d:623e with SMTP id qb16-20020a1709077e9000b00704b67d623emr52243098ejc.634.1655125697429; Mon, 13 Jun 2022 06:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125697; cv=none; d=google.com; s=arc-20160816; b=UV8BIipwSuqysCD2NwLgng+jWCKKLYy0I+W04g8ac7efOhamT6J1uczwFCh3PI3e0T FQ56/CpiMC9/N4YzMmNX7Upo7VHpmUaRaqfEmneklKvOZIjJQ05BIp1dxVZIvcFxgnU4 OlDEkL7FNCkz+09sTVgxhg4AgA1JEHXSOrXLS0KWCj1DpPOS9mVP4mT4Os9zGPL4VQQ8 G1FreuZoK0/5z9eyf+V9ld2iCatzOdCLqtHHf67+yTMX861lhN/ZK1s7iPY36EG3YyB1 cYC4YVIxv0PiMAHXkSsYXWeEC4fhAst3bNUrnaNwShxtTyF5gSAn9x6WC6K1BhrlgUQj eH/A== 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=HLKB5T7Lj7TVL4kc60dCDPT9PWiK8ToeJMZMEMGdEiY=; b=wjt6w/7auitxDcXJSVgWmBzyp3FOjRi0yTVnghXs02iJ6oG21WxnIMMDxhEH+iZUrS NKJvn3V+FgvxKiQqTMwWQAU5noOVQarx1BnF7s/77elWfFYbD430Eh4kUO5HtSEhySRR 9/VvF/NDymC9ol8xBpoeQg8He8yNJwMbSTXJaTeR3iegljaPJ6dzK8Ja3l+A3xyRIy2Q e01fOAmUz03T0oGFdHSreay+V1iV5+pf5kYxVkTVH9SN5krhbpDRhZ6UjJbICKfi/FlV 8IcbHP2zvngFLhBYTNkKQzdxTBLmDcviBdZ/L0ZWmExVL9goSsrnfXyMuJzLJYg98hgI LhbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rP705kCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h20-20020a05640250d400b0042dcb4de318si8813714edb.428.2022.06.13.06.07.47; Mon, 13 Jun 2022 06:08:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rP705kCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1351179AbiFMLDc (ORCPT + 99 others); Mon, 13 Jun 2022 07:03:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350594AbiFMKzA (ORCPT ); Mon, 13 Jun 2022 06:55:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3155621E21; Mon, 13 Jun 2022 03:31:46 -0700 (PDT) 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 C4653B80E5E; Mon, 13 Jun 2022 10:31:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40C15C3411C; Mon, 13 Jun 2022 10:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116303; bh=jbhtL23dw1SOfwSe9CIJ573qi3P1HYRs60jkyA5yyuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rP705kCAYFd7auY/LH61pLpWBO6aqF3zavpHdW8L5bCUrw6a8E7yJGTa2BQcaTnMJ SH6EQ9PxaVTt3Kaium80+4Ndi4CqbVl2onnOd+YtgDOTb4dCxttsREUv3DzspnlT3v PnDwzl4CYXQI9lTMrrCUd7VGQ/7ckePNKQlM75G0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 158/218] net: ethernet: mtk_eth_soc: out of bounds read in mtk_hwlro_get_fdir_entry() Date: Mon, 13 Jun 2022 12:10:16 +0200 Message-Id: <20220613094925.386465718@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit e7e7104e2d5ddf3806a28695670f21bef471f1e1 ] The "fsp->location" variable comes from user via ethtool_get_rxnfc(). Check that it is valid to prevent an out of bounds read. Fixes: 7aab747e5563 ("net: ethernet: mediatek: add ethtool functions to configure RX flows of HW LRO") Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index dbd16dd5aa04..ade72b46e93c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1579,6 +1579,9 @@ static int mtk_hwlro_get_fdir_entry(struct net_device *dev, struct ethtool_rx_flow_spec *fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; + if (fsp->location >= ARRAY_SIZE(mac->hwlro_ip)) + return -EINVAL; + /* only tcp dst ipv4 is meaningful, others are meaningless */ fsp->flow_type = TCP_V4_FLOW; fsp->h_u.tcp_ip4_spec.ip4dst = ntohl(mac->hwlro_ip[fsp->location]); -- 2.35.1