From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 71D47AFD2 for ; Fri, 20 Jun 2014 12:25:07 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 20 Jun 2014 03:20:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,513,1400050800"; d="scan'208";a="531483326" Received: from shilc102.sh.intel.com ([10.239.39.44]) by orsmga001.jf.intel.com with ESMTP; 20 Jun 2014 03:25:08 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shilc102.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s5KAP39K029310; Fri, 20 Jun 2014 18:25:05 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s5KAP1pl006628; Fri, 20 Jun 2014 18:25:03 +0800 Received: (from jingche2@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id s5KAP1Q7006624; Fri, 20 Jun 2014 18:25:01 +0800 From: "Chen Jing D(Mark)" To: dev@dpdk.org Date: Fri, 20 Jun 2014 18:24:41 +0800 Message-Id: <1403259884-6498-4-git-send-email-jing.d.chen@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1403259884-6498-1-git-send-email-jing.d.chen@intel.com> References: <1403259884-6498-1-git-send-email-jing.d.chen@intel.com> Subject: [dpdk-dev] [PATCH 3/6] i40e: Add sanity check in pf host driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2014 10:25:07 -0000 From: "Chen Jing D(Mark)" Add sanity check in message handling functions on the request buffer pointer from VF. Signed-off-by: Chen Jing D(Mark) Acked-by: Helin Zhang Acked-by: Cunming Liang Acked-by: Jingjing Wu --- lib/librte_pmd_i40e/i40e_pf.c | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_pf.c b/lib/librte_pmd_i40e/i40e_pf.c index 76405d3..1fa65e9 100644 --- a/lib/librte_pmd_i40e/i40e_pf.c +++ b/lib/librte_pmd_i40e/i40e_pf.c @@ -419,7 +419,7 @@ i40e_pf_host_process_cmd_config_vsi_queues(struct i40e_pf_vf *vf, int i; struct i40e_virtchnl_queue_pair_info *qpair; - if (msglen <= sizeof(*qconfig) || + if (msg == NULL || msglen <= sizeof(*qconfig) || qconfig->num_queue_pairs > vsi->nb_qps) { PMD_DRV_LOG(ERR, "vsi_queue_config_info argument wrong\n"); ret = I40E_ERR_PARAM; @@ -465,7 +465,7 @@ i40e_pf_host_process_cmd_config_irq_map(struct i40e_pf_vf *vf, struct i40e_virtchnl_irq_map_info *irqmap = (struct i40e_virtchnl_irq_map_info *)msg; - if (msglen < sizeof(struct i40e_virtchnl_irq_map_info)) { + if (msg == NULL || msglen < sizeof(struct i40e_virtchnl_irq_map_info)) { PMD_DRV_LOG(ERR, "buffer too short\n"); ret = I40E_ERR_PARAM; goto send_msg; @@ -553,7 +553,7 @@ i40e_pf_host_process_cmd_enable_queues(struct i40e_pf_vf *vf, struct i40e_virtchnl_queue_select *q_sel = (struct i40e_virtchnl_queue_select *)msg; - if (msglen != sizeof(*q_sel)) { + if (msg == NULL || msglen != sizeof(*q_sel)) { ret = I40E_ERR_PARAM; goto send_msg; } @@ -575,7 +575,7 @@ i40e_pf_host_process_cmd_disable_queues(struct i40e_pf_vf *vf, struct i40e_virtchnl_queue_select *q_sel = (struct i40e_virtchnl_queue_select *)msg; - if (msglen != sizeof(*q_sel)) { + if (msg == NULL || msglen != sizeof(*q_sel)) { ret = I40E_ERR_PARAM; goto send_msg; } @@ -600,7 +600,7 @@ i40e_pf_host_process_cmd_add_ether_address(struct i40e_pf_vf *vf, int i; struct ether_addr *mac; - if (msglen <= sizeof(*addr_list)) { + if (msg == NULL || msglen <= sizeof(*addr_list)) { PMD_DRV_LOG(ERR, "add_ether_address argument too short\n"); ret = I40E_ERR_PARAM; goto send_msg; @@ -633,7 +633,7 @@ i40e_pf_host_process_cmd_del_ether_address(struct i40e_pf_vf *vf, int i; struct ether_addr *mac; - if (msglen <= sizeof(*addr_list)) { + if (msg == NULL || msglen <= sizeof(*addr_list)) { PMD_DRV_LOG(ERR, "delete_ether_address argument too short\n"); ret = I40E_ERR_PARAM; goto send_msg; @@ -666,7 +666,7 @@ i40e_pf_host_process_cmd_add_vlan(struct i40e_pf_vf *vf, int i; uint16_t *vid; - if (msglen <= sizeof(*vlan_filter_list)) { + if (msg == NULL || msglen <= sizeof(*vlan_filter_list)) { PMD_DRV_LOG(ERR, "add_vlan argument too short\n"); ret = I40E_ERR_PARAM; goto send_msg; @@ -698,7 +698,7 @@ i40e_pf_host_process_cmd_del_vlan(struct i40e_pf_vf *vf, int i; uint16_t *vid; - if (msglen <= sizeof(*vlan_filter_list)) { + if (msg == NULL || msglen <= sizeof(*vlan_filter_list)) { PMD_DRV_LOG(ERR, "delete_vlan argument too short\n"); ret = I40E_ERR_PARAM; goto send_msg; @@ -722,7 +722,7 @@ static int i40e_pf_host_process_cmd_config_promisc_mode( struct i40e_pf_vf *vf, uint8_t *msg, - __rte_unused uint16_t msglen) + uint16_t msglen) { int ret = I40E_SUCCESS; struct i40e_virtchnl_promisc_info *promisc = @@ -730,6 +730,11 @@ i40e_pf_host_process_cmd_config_promisc_mode( struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf); bool unicast = FALSE, multicast = FALSE; + if (msg == NULL || msglen != sizeof(*promisc)) { + ret = I40E_ERR_PARAM; + goto send_msg; + } + if (promisc->flags & I40E_FLAG_VF_UNICAST_PROMISC) unicast = TRUE; ret = i40e_aq_set_vsi_unicast_promiscuous(hw, -- 1.7.7.6