From: "Chen Jing D(Mark)" <jing.d.chen@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/6] i40e: Add sanity check in pf host driver
Date: Fri, 20 Jun 2014 18:24:41 +0800 [thread overview]
Message-ID: <1403259884-6498-4-git-send-email-jing.d.chen@intel.com> (raw)
In-Reply-To: <1403259884-6498-1-git-send-email-jing.d.chen@intel.com>
From: "Chen Jing D(Mark)" <jing.d.chen@intel.com>
Add sanity check in message handling functions on the request
buffer pointer from VF.
Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>
Acked-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
---
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
next prev parent reply other threads:[~2014-06-20 10:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 10:24 [dpdk-dev] [PATCH 0/6] Support i40e VF vlan offload and pvid config Chen Jing D(Mark)
2014-06-20 10:24 ` [dpdk-dev] [PATCH 1/6] i40e: destroy MSIX pool when device is closed Chen Jing D(Mark)
2014-06-20 10:24 ` [dpdk-dev] [PATCH 2/6] i40e: Add permenant mac address into mac list Chen Jing D(Mark)
2014-06-20 10:24 ` Chen Jing D(Mark) [this message]
2014-06-20 10:24 ` [dpdk-dev] [PATCH 4/6] i40e: make change to vlan_strip and vlan_set_pvid function Chen Jing D(Mark)
2014-06-20 10:24 ` [dpdk-dev] [PATCH 5/6] i40e: PF host driver to support VF vlan offload and set pvid Chen Jing D(Mark)
2014-06-20 10:24 ` [dpdk-dev] [PATCH 6/6] i40e: VF to support VLAN strip and pvid set/clear Chen Jing D(Mark)
2014-06-20 13:51 ` [dpdk-dev] [PATCH 0/6] Support i40e VF vlan offload and pvid config Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403259884-6498-4-git-send-email-jing.d.chen@intel.com \
--to=jing.d.chen@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).