Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2748114pxj; Mon, 31 May 2021 09:44:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysm1lgoGW333Cw9k453xQlPIM8gaOJjBoEo9bq98tdHtEm/kyxABSXl/zlcYi6xYVTwKcj X-Received: by 2002:aa7:d4c2:: with SMTP id t2mr10016229edr.144.1622479464917; Mon, 31 May 2021 09:44:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622479464; cv=none; d=google.com; s=arc-20160816; b=t70Wz0JE/SCa1EfG1WNKLMkXB5bY02ea1aD20SrGvUwQVKBMTBGhgt9LyFEvf/wH3x fyDa+VVJLk/tBKDlaEkZuZAVJktTR2WFGIUOsTLy/3X7cxMptztyWhzbByMFpeo3dKHB 7FQ77CGFIJD10mTG4n3Zp+dt8OPOX2J/xQz+rBB/8rAB48VfJ+GiPJrR+xRMa3vruJ6s MJ+vJcL3bBaLSKxNzbeuEhJtwdLZ+fN0HRUZYyOPz2wd9dNWmfdUQyq/6u7eOfWDvAvs KJwlWK8ne+FL3t7lduUsZbRRKFPAOgnrYSG65k9NcRz0vD6Krf5z583wTFktgsJ3O6+W T9UA== 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=VTf5J4Q9YkbMXyDuOh4kUbiY9XsFHZRAvlpdbXMXzv0=; b=xa1cm2j6v0fSPSMqQoiwsFV3fbQc/ToAzuD+ASD2wfth5dMQE22J7KLO+CNUH7Nb3e UMo7bsHxpzfz7UyOgiMamQwM7F18qUgJsscb97b1E58ccxJdjMgC+Gf/5aaAeAcpq3rO /Vlj/ozY0qSxtba8eOYlxysK39c4Mu1M6zT/e6DmeWZDkvm/ItI/J+M6O0hFMOl6GUVZ FbQcJvpRTIGE0Pb4x68eH/yykBhEbNDwJC5yhrO6ChCRuui81grB7vyVEfqrPg6wHSGG 0Ed4itAa9mIYmU70mVw6ZfQHAvmTX+U5ZKL/fDt9L6kTwjI1qC+Sux8hjatLktOE2hmB KMRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wyhn2Uap; 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 ao10si13162534ejc.33.2021.05.31.09.44.02; Mon, 31 May 2021 09:44:24 -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=Wyhn2Uap; 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 S234165AbhEaQoV (ORCPT + 99 others); Mon, 31 May 2021 12:44:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:48194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232601AbhEaOxd (ORCPT ); Mon, 31 May 2021 10:53:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD1FD61440; Mon, 31 May 2021 13:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469535; bh=DfZKl/NzFi7lgZuQmVDSRGUm2tklNb+SYAcydYSVrD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wyhn2UapMRXRiXTHZr2L1X3oyr9p1LlWx8uX8COseAsT/eufqMEdCSttonry2hvMa jo3WVCk4QZ9avTpAR3LRB6/B4UC50jnK0bJgYilsBOHgWRlI2bj8a6WlYg74461V3N 9bkWrVWgwxGXFxhG/z3VH6D8mmhBU3SnMRYOz2Y8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Sunil Goutham , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 234/296] octeontx2-pf: fix a buffer overflow in otx2_set_rxfh_context() Date: Mon, 31 May 2021 15:14:49 +0200 Message-Id: <20210531130711.670263034@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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: Dan Carpenter [ Upstream commit e5cc361e21648b75f935f9571d4003aaee480214 ] This function is called from ethtool_set_rxfh() and "*rss_context" comes from the user. Add some bounds checking to prevent memory corruption. Fixes: 81a4362016e7 ("octeontx2-pf: Add RSS multi group support") Signed-off-by: Dan Carpenter Acked-by: Sunil Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index f4962a97a075..9d9a2e438acf 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -786,6 +786,10 @@ static int otx2_set_rxfh_context(struct net_device *dev, const u32 *indir, if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP) return -EOPNOTSUPP; + if (*rss_context != ETH_RXFH_CONTEXT_ALLOC && + *rss_context >= MAX_RSS_GROUPS) + return -EINVAL; + rss = &pfvf->hw.rss_info; if (!rss->enable) { -- 2.30.2