From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B8378A054A; Tue, 6 Sep 2022 04:27:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6AD7C400D6; Tue, 6 Sep 2022 04:27:45 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id B6AED40041 for ; Tue, 6 Sep 2022 04:27:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662431263; x=1693967263; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=RSgNX+w7ru4OGwt1SbZZfdrYsW6T8L7WM3xfZJpf5Vk=; b=E13VpZOoPR/agMKpTTg95oh80zBA8aVYWv6kHLw7NVaXhOHi2Fxi7eFa H46wALvtRJX+XHpw2Wxw/RXL14Z5o3xyINIc2y6H36Fq4TaNpYGYfss/p YypYEWn3LvVNkif9DHFSxGA0XsYJrsnq9otOjMcAidZOVSSZMRXcmiZ1P Yq7OnX+oxOdIn8zxrLnibKZ6vilFp/fWXOULOPpNW031TVZNmmkth3PpC Dc+basfFufNGVcNqlu3eR85Pketo7ZxkwF2zR6JIh9B/JxV6HwFao5JQC 4txEIHtB5FAHOLCvZl2aZXJvrWxts019FELGQ24YuRbe4iGAF3ls60+L8 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10461"; a="276878704" X-IronPort-AV: E=Sophos;i="5.93,292,1654585200"; d="scan'208";a="276878704" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 19:27:42 -0700 X-IronPort-AV: E=Sophos;i="5.93,292,1654585200"; d="scan'208";a="591086809" Received: from unknown (HELO localhost.localdomain) ([10.239.252.103]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 19:27:40 -0700 From: Zhichao Zeng To: dev@dpdk.org Cc: qiming.yang@intel.com, yidingx.zhou@intel.com, Zhichao Zeng , Qi Zhang Subject: [PATCH] net/ice: avoid out-of-bound access Date: Tue, 6 Sep 2022 10:28:59 +0800 Message-Id: <20220906022859.159925-1-zhichaox.zeng@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add judgment on 'ethdev_port_id' to avoid out-of-bound accessing the 'rte_eth_devices'. Fixes: 6f8fba7e437e ("net/ice: support represented port flow action") Signed-off-by: Zhichao Zeng --- drivers/net/ice/ice_switch_filter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index 240fa10750..59fb31aa9d 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -1631,6 +1631,10 @@ ice_switch_parse_dcf_action(struct ice_dcf_adapter *ad, case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: rule_info->sw_act.fltr_act = ICE_FWD_TO_VSI; act_ethdev = action->conf; + + if (!rte_eth_dev_is_valid_port(act_ethdev->port_id)) + goto invalid; + repr_dev = &rte_eth_devices[act_ethdev->port_id]; if (!repr_dev->data) -- 2.25.1