Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4026421ybl; Mon, 3 Feb 2020 11:06:29 -0800 (PST) X-Google-Smtp-Source: APXvYqz6GX5Od9Bn9LyuHWaaN1nS1OhTdctKZBAb8CVlU9ZQNR12Gu1PvcteeTIBpJyVQ3ndjn5j X-Received: by 2002:a9d:6b17:: with SMTP id g23mr19097749otp.139.1580756789123; Mon, 03 Feb 2020 11:06:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580756789; cv=none; d=google.com; s=arc-20160816; b=bzLIAUWHP9hj5oOWKtrqa0CJhQopNSWxz0jN2ODVWpDX+6P+l6gla6Phi9F3ihVksg L3ELhvfYNHjfFgLUiObbHPdOChVEZ+o3UI+b06tUY+Uj8zCSdTxl+0gsqjgjBY95oZe3 KPKMEyMtiULysr2bBp8YGlbtgWJ+pn+IEj2L/zDRHI2EYKvRqpAxbuzPGvmbdPFv/vaz NFZBTz+rqp16FO56CxwNtrvZ+73kK0Bbwqc2yRyaZi3Jox9WllPR6B06qYGFgWi0qvkO 8YkOnWXqUy3bSejAtKqBThjpez/IwDCoZGEVFVZRbLD4IyDTemhAfKAS8fuABYUz7dbZ Y42Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aLO0RMK7XBfxEcUxknHOGEDTwOw2S7rWj0wDMo7kgfU=; b=x/fNqWukf5/YqnvZzK4bGOCqguu5hqe97IsbPe/zxX16cKtQBwvzPwnlGY/8arjO3p zyb3fy/DZDUNDIUA7CWS5zBnYpAqTlYiUQyMuQE+7pnnBPhPjQGoacUdL8tUSJszoBjG W4849TAtVpX+AWY3+zjCN+NxypedBW10eTytwlpfRue512n4H1xraBvYGH4TJ8Ng0TOh nJ2cgM4Z3jpva9iJu7xLtYK8OPiuEJZM5I0wb2XJrnQyGOiZd6xam4Ge6mUElWQXTn1e dAxB3ml0eqx+W+Oh3+HI13+zobMHKu6avDBSFe75ZYhmmMuK9lAJ9rDBJBz5Sn9FJ/a6 VeFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ge7Vr+z4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e23si5738648oii.173.2020.02.03.11.06.17; Mon, 03 Feb 2020 11:06:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ge7Vr+z4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731505AbgBCQlT (ORCPT + 98 others); Mon, 3 Feb 2020 11:41:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:49916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730930AbgBCQfN (ORCPT ); Mon, 3 Feb 2020 11:35:13 -0500 Received: from localhost (unknown [104.132.45.99]) (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 7610E21582; Mon, 3 Feb 2020 16:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580747712; bh=gITOntd6JjepyRqHUzvVgH4Fg1uLC6E0WP0cBUWuEUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ge7Vr+z4dtjgLikgtphmnKQkFkgILyD6hMq29WTy8AvcZOMTGOVbrc3GaqTGYBblL D8eGBQgfj1u5uGAVmqrzGZGrw/dhzYCJ75/eSthBuaZ3RO1dyGk3Fiya8xADm1UPY9 fZmSpCVWuAvW0jL7Yrv/JA8wif4x+r1u6beL4vB8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arkady Gilinksky , Brett Creeley , Andrew Bowers , Jeff Kirsher , Sasha Levin Subject: [PATCH 5.4 38/90] i40e: Fix virtchnl_queue_select bitmap validation Date: Mon, 3 Feb 2020 16:19:41 +0000 Message-Id: <20200203161922.708588217@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200203161917.612554987@linuxfoundation.org> References: <20200203161917.612554987@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brett Creeley [ Upstream commit d9d6a9aed3f66f8ce5fa3ca6ca26007d75032296 ] Currently in i40e_vc_disable_queues_msg() we are incorrectly validating the virtchnl queue select bitmaps. The virtchnl_queue_select rx_queues and tx_queue bitmap is being compared against ICE_MAX_VF_QUEUES, but the problem is that these bitmaps can have a value greater than I40E_MAX_VF_QUEUES. Fix this by comparing the bitmaps against BIT(I40E_MAX_VF_QUEUES). Also, add the function i40e_vc_validate_vqs_bitmaps() that checks to see if both virtchnl_queue_select bitmaps are empty along with checking that the bitmaps only have valid bits set. This function can then be used in both the queue enable and disable flows. Suggested-by: Arkady Gilinksky Signed-off-by: Brett Creeley Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c index 3d24408388226..3515ace0f0201 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c @@ -2322,6 +2322,22 @@ static int i40e_ctrl_vf_rx_rings(struct i40e_vsi *vsi, unsigned long q_map, return ret; } +/** + * i40e_vc_validate_vqs_bitmaps - validate Rx/Tx queue bitmaps from VIRTHCHNL + * @vqs: virtchnl_queue_select structure containing bitmaps to validate + * + * Returns true if validation was successful, else false. + */ +static bool i40e_vc_validate_vqs_bitmaps(struct virtchnl_queue_select *vqs) +{ + if ((!vqs->rx_queues && !vqs->tx_queues) || + vqs->rx_queues >= BIT(I40E_MAX_VF_QUEUES) || + vqs->tx_queues >= BIT(I40E_MAX_VF_QUEUES)) + return false; + + return true; +} + /** * i40e_vc_enable_queues_msg * @vf: pointer to the VF info @@ -2347,7 +2363,7 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg) goto error_param; } - if ((0 == vqs->rx_queues) && (0 == vqs->tx_queues)) { + if (i40e_vc_validate_vqs_bitmaps(vqs)) { aq_ret = I40E_ERR_PARAM; goto error_param; } @@ -2409,9 +2425,7 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg) goto error_param; } - if ((vqs->rx_queues == 0 && vqs->tx_queues == 0) || - vqs->rx_queues > I40E_MAX_VF_QUEUES || - vqs->tx_queues > I40E_MAX_VF_QUEUES) { + if (i40e_vc_validate_vqs_bitmaps(vqs)) { aq_ret = I40E_ERR_PARAM; goto error_param; } -- 2.20.1