Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp593154iog; Mon, 13 Jun 2022 08:46:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJww9zj/WoTzmx65RrZn1M9Fuc1YsObikb9G6Mfg8M5T5zz8QYizniHM4EAC8gKiVhBnhWTp X-Received: by 2002:a63:5c26:0:b0:405:2650:d202 with SMTP id q38-20020a635c26000000b004052650d202mr237345pgb.276.1655135206562; Mon, 13 Jun 2022 08:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655135206; cv=none; d=google.com; s=arc-20160816; b=H0OKOHs/CY2OKhmSQxJuhzqFYuF3hzw2Oy/1v4ks2cAEq0Y3PCwX9jMoWjxFA7W3pv uB6wTZnVETPm8ZKw1CM0fughyMGcC3x+C8r+j8UUTYQoSnOAky5u7dYjkSvvhisayncp sjgvd4jtmAPG//R9Ewv5QXZ+IHop4+9bfCF0lx6etqiXwF8TlKrk0gbysRVzg22uINfS VmxL4gJChtAXn7gZuOfCASdDpkAHkoFhMInTyk1z2cNtJl/uUMkBUyOIWcRXEL0tnoE5 IUX837LlW+awka4pCjeUSw3eEdApRkyddGRfDyDOD0S5M2vxRwbTSwt1ZEbz1nfaINCV sAhQ== 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=KcKv14/+S5FGFM1rptlFSqC0bCyyD6Dz7HQW54rLCns=; b=Ze1Li4DAv3DbNPDHPv2KXdu7kmqjJHEUmbS0dLtzxU5BwiCNBILFKd9/EcwuK8T6zV UiEL4NwfzUzfOT0/SL8JrrNkkYsxMreEXUgXJuFqgeTNpiDuj0v6UCPD5lv6Sk+3r9mx 1i70cfu1t+4XHhmoRGCf3HSq95jS5BxNL2dOcoGUf3ECLjgAP93kaArv19FfwFqDo6An I2soDt9yX7y5xg5WuFf0+F/UBrZxVRf8RetuY3vuv2UYPzypEu1sfEe7SP4VKNahWqxr XdK6uGuH79At51dNUO1t9iMvy88squxoVJ2bIRzr86Z5EE6askq6aEdGZc+U5qalj3vg lUYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VhWzAxlh; 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 q76-20020a632a4f000000b003aa7f30fcaasi10284293pgq.516.2022.06.13.08.46.34; Mon, 13 Jun 2022 08:46:46 -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=VhWzAxlh; 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 S1355684AbiFMLj3 (ORCPT + 99 others); Mon, 13 Jun 2022 07:39:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355014AbiFMLaY (ORCPT ); Mon, 13 Jun 2022 07:30:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0040240A28; Mon, 13 Jun 2022 03:46:18 -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 A312AB80D3C; Mon, 13 Jun 2022 10:46:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00F17C34114; Mon, 13 Jun 2022 10:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117176; bh=6U78QIlckGBSaUPxamqdHWvKqZoyaE/nHXH6NUubhOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VhWzAxlhS1HGg9+KQtZkrvJeeEiKlAq4SXk4BJYzqcR2nyD5VYZoXEIf4om9MOHAk viknSP4YNe8IGVLnSfEFnDNlRUC0fFzHdGVwljMHAVoDREY1hDOJG7qVM2yGr7iE4H V8wd2+G14UfRkfopmz+FRXalZdM1+eJs+CUaEiXY= 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 5.4 324/411] net: ethernet: mtk_eth_soc: out of bounds read in mtk_hwlro_get_fdir_entry() Date: Mon, 13 Jun 2022 12:09:57 +0200 Message-Id: <20220613094938.447413129@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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=unavailable 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 3351d4f9363a..5dce4cd60f58 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1962,6 +1962,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