From patchwork Fri Jun 19 14:32:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 580A4C433DF for ; Fri, 19 Jun 2020 16:35:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B3F72067D for ; Fri, 19 Jun 2020 16:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592584523; bh=KZ7y1Ex25p0wM+XL4Imgv9FD0uTWknGiw0q6ffVnGQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1iPAGjfa4IVBK4zm5pDM9jBMDr7WWrJgRXMGOUBEPZ1Hqh0H+gQFyw4HzDFvEMcQ6 WTEVjmKPW3SdPx2ArkTAwz++e8MRz0yePTKs8oQnxq3oePzuZ5lr6hDiCCAOe+nmjh 5z1hoEfgKft/zlhoQNGo1AI24y52ghKhhuDxVEN0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389652AbgFSQfP (ORCPT ); Fri, 19 Jun 2020 12:35:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:42750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389269AbgFSOt7 (ORCPT ); Fri, 19 Jun 2020 10:49:59 -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 D1EE1217A0; Fri, 19 Jun 2020 14:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578199; bh=KZ7y1Ex25p0wM+XL4Imgv9FD0uTWknGiw0q6ffVnGQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QHtqK2KBoAd2VSzk1JbVNO49mqksSyiHKj/SoenkvvTIklvkq/MGUZ5gEZsIHLMPw zb6R2XqNfngpC8Im++rFTCXvuZqxz966M+6paIPq0UcNYlNKB68zw/Z/o1FHBMQuVj 51tehdhmZpLLiq7phWfLCJdBGZ7VTV2Fdx/0gqg4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 094/190] net: vmxnet3: fix possible buffer overflow caused by bad DMA value in vmxnet3_get_rss() Date: Fri, 19 Jun 2020 16:32:19 +0200 Message-Id: <20200619141638.294719692@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141633.446429600@linuxfoundation.org> References: <20200619141633.446429600@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 2ff27314e047..66c6c07c7a16 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c @@ -692,6 +692,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;