[dpdk-dev,v3] examples/l3fwd: fix validation for queue id of config tuple

Message ID 1458918824-15168-1-git-send-email-reshma.pattan@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Pattan, Reshma March 25, 2016, 3:13 p.m. UTC
Added validation for queue id of config parameter tuple.

This validation enforces user to enter queue ids of a port
from 0 and in sequence.

This additional validation on queue ids avoids ixgbe crash caused by null
rxq pointer access inside ixgbe_dev_rx_init.

Reason for null rxq is, L3fwd application allocates memory only for queues passed by user.
But rte_eth_dev_start  tries to initialize rx queues in sequence from 0 to nb_rx_queues,
which is not true and coredump while accessing the unallocated queue .

Fixes: af75078fece3 ("first public release")

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
 v3:
 added Fixes line
 added "\n" at the end of err message.
 
 v2:
 used nested if instead of if and elseif.

 examples/l3fwd/main.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
  

Comments

De Lara Guarch, Pablo March 25, 2016, 4:08 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Reshma Pattan
> Sent: Friday, March 25, 2016 3:14 PM
> To: dev@dpdk.org; Ananyev, Konstantin
> Cc: Pattan, Reshma
> Subject: [dpdk-dev] [PATCH v3] examples/l3fwd: fix validation for queue id of
> config tuple
> 
> Added validation for queue id of config parameter tuple.
> 
> This validation enforces user to enter queue ids of a port
> from 0 and in sequence.
> 
> This additional validation on queue ids avoids ixgbe crash caused by null
> rxq pointer access inside ixgbe_dev_rx_init.
> 
> Reason for null rxq is, L3fwd application allocates memory only for queues
> passed by user.
> But rte_eth_dev_start  tries to initialize rx queues in sequence from 0 to
> nb_rx_queues,
> which is not true and coredump while accessing the unallocated queue .
> 
> Fixes: af75078fece3 ("first public release")
> 
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>

Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
  
Thomas Monjalon March 25, 2016, 6:49 p.m. UTC | #2
> > Added validation for queue id of config parameter tuple.
> > 
> > This validation enforces user to enter queue ids of a port
> > from 0 and in sequence.
> > 
> > This additional validation on queue ids avoids ixgbe crash caused by null
> > rxq pointer access inside ixgbe_dev_rx_init.
> > 
> > Reason for null rxq is, L3fwd application allocates memory only for queues
> > passed by user.
> > But rte_eth_dev_start  tries to initialize rx queues in sequence from 0 to
> > nb_rx_queues,
> > which is not true and coredump while accessing the unallocated queue .
> > 
> > Fixes: af75078fece3 ("first public release")
> > 
> > Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> 
> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied, thanks
  

Patch

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 792894f..97a1423 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -263,9 +263,14 @@  get_port_n_rx_queues(const uint8_t port)
 	uint16_t i;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
-		if (lcore_params[i].port_id == port &&
-			lcore_params[i].queue_id > queue)
-			queue = lcore_params[i].queue_id;
+		if (lcore_params[i].port_id == port) {
+			if (lcore_params[i].queue_id == queue+1)
+				queue = lcore_params[i].queue_id;
+			else
+				rte_exit(EXIT_FAILURE, "queue ids of the port %d must be"
+						" in sequence and must start with 0\n",
+						lcore_params[i].port_id);
+		}
 	}
 	return (uint8_t)(++queue);
 }