Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp116813ybg; Mon, 8 Jun 2020 18:04:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYv1NGxLUd4EV4qz50kiLor/YiYdChEsXXlyGkgbQ2YiPic2oqgFIRHI9p62BcYA6acNRc X-Received: by 2002:a17:906:7855:: with SMTP id p21mr23917288ejm.257.1591664682331; Mon, 08 Jun 2020 18:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664682; cv=none; d=google.com; s=arc-20160816; b=QqNq9sK9lYLSu4GROqmZ0+ZETrPGVHC0GheoIVvNs2MacL2pFwaXIy3L6pSwddfqsY /9cjuvScnIn98Awnc3O0bKYLm05WjWvCPmGEUjpGld0GET245lmLsTtPrpvpha4y1ufV 4xXN6EpOE1RMjZVvKAv7EUJJbGhzZj4nWwMRnpkTuFeY6RiPa0xYYjRjZmagu2we/Dos WptXu7aWO4tOqqsqS2Ez8HIEG1eL45DX9ka1gw0/lW2GRJ2dYKC4OTBnTeBjpaqT62mu zZNJhX9AeEE2akwuEuVg0LNPuaclmzgu3b28iSsBgbEpsU7mkWiWY+cpJA8UPkC/1XON tTFw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h7qJVT6DsFC1Xs9Ht8YZtPNztjTEM0J1pPsYXczv5kk=; b=v0olEqWVUtBuJOG4AxXK8xzbO4CqOPGfMSs7IruBrl9gcNSBnJiqMMmug4Lit1VQ5N I562GUmhtVpeBKooXc7vTQn+wBL23b9kJ/+Lvu/lf9j3S0nqCX8rNcD2CLtJOjg3pWgZ VYLfZZdGDhq6iKm3fDAq4WnY4R9+ZQD+Nw8K4Rq+AmSz4WbUXJxOisW5vW9/GE7mbKu8 tsNkfxq3eLnlazCelq1GDYqBRpTsKLasuPMTuoYtUrC7JfjVL9WIRI01VcHeH5IUXqfS PxbNg6nQYPCKJntLwLx/7XxlPFXfV730PlmLVYQXEFAvA0tmx2NrCfLc6q2WwsF3Iwn+ RRaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lUgohl81; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si10021742edv.590.2020.06.08.18.04.19; Mon, 08 Jun 2020 18:04:42 -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=lUgohl81; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729107AbgFIBCb (ORCPT + 99 others); Mon, 8 Jun 2020 21:02:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:52730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728049AbgFHXHz (ORCPT ); Mon, 8 Jun 2020 19:07:55 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A33462086A; Mon, 8 Jun 2020 23:07:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657675; bh=q1B3KQSxSxg9ydVzTPnGVgzi89sxg0AINlENfzb4HD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lUgohl814ilyn9UHqDppjqJI0bQyreoKPebLRnZB82R6TzPyDUfoax398LFTr2+Dr ps/XFLff3V7e0lGj14wldA+Pn+Xg9adqpfR5CC2l/Oro/AxetR8a+9PEUMHQKjm15r MzcarSYryu0g4Gz4l7Lh77aR/jQgl750o5q3obNU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jia-Ju Bai , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 083/274] net: vmxnet3: fix possible buffer overflow caused by bad DMA value in vmxnet3_get_rss() Date: Mon, 8 Jun 2020 19:02:56 -0400 Message-Id: <20200608230607.3361041-83-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 3e1c6846b9e108740ef8a37be80314053f5dd52a ] The value adapter->rss_conf is stored in DMA memory, and it is assigned to rssConf, so rssConf->indTableSize can be modified at anytime by malicious hardware. Because rssConf->indTableSize is assigned to n, buffer overflow may occur when the code "rssConf->indTable[n]" is executed. To fix this possible bug, n is checked after being used. Signed-off-by: Jia-Ju Bai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/vmxnet3/vmxnet3_ethtool.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c index 6528940ce5f3..b53bb8bcd47f 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c @@ -700,6 +700,8 @@ vmxnet3_get_rss(struct net_device *netdev, u32 *p, u8 *key, u8 *hfunc) *hfunc = ETH_RSS_HASH_TOP; if (!p) return 0; + if (n > UPT1_RSS_MAX_IND_TABLE_SIZE) + return 0; while (n--) p[n] = rssConf->indTable[n]; return 0; -- 2.25.1