DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound
@ 2017-08-23  7:05 Rongqiang XIE
  2017-09-04 13:37 ` Singh, Jasvinder
  2017-09-20 12:01 ` Dumitrescu, Cristian
  0 siblings, 2 replies; 3+ messages in thread
From: Rongqiang XIE @ 2017-08-23  7:05 UTC (permalink / raw)
  To: cristian.dumitrescu; +Cc: dev, Rongqiang XIE

In function rte_pipeline_compute_masks(), the value pos equal
p->entries[i]->action,type constraint p->entries[i]->action is
[0,4],but array action_mask1 size is 4,it possible attempt to
access element 4 of array action_mask1.And also in function
rte_pipeline_run(),it possible attempt to access element 4 of
array action_mask0.

Signed-off-by: Rongqiang XIE <xie.rongqiang@zte.com.cn>
---
 lib/librte_pipeline/rte_pipeline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pipeline/rte_pipeline.c b/lib/librte_pipeline/rte_pipeline.c
index 7f8fbac..2914445 100644
--- a/lib/librte_pipeline/rte_pipeline.c
+++ b/lib/librte_pipeline/rte_pipeline.c
@@ -155,8 +155,8 @@ struct rte_pipeline {
 	/* Pipeline run structures */
 	struct rte_mbuf *pkts[RTE_PORT_IN_BURST_SIZE_MAX];
 	struct rte_pipeline_table_entry *entries[RTE_PORT_IN_BURST_SIZE_MAX];
-	uint64_t action_mask0[RTE_PIPELINE_ACTIONS];
-	uint64_t action_mask1[RTE_PIPELINE_ACTIONS];
+	uint64_t action_mask0[RTE_PIPELINE_ACTIONS + 1];
+	uint64_t action_mask1[RTE_PIPELINE_ACTIONS + 1];
 	uint64_t pkts_mask;
 	uint64_t n_pkts_ah_drop;
 	uint64_t pkts_drop_mask;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound
  2017-08-23  7:05 [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound Rongqiang XIE
@ 2017-09-04 13:37 ` Singh, Jasvinder
  2017-09-20 12:01 ` Dumitrescu, Cristian
  1 sibling, 0 replies; 3+ messages in thread
From: Singh, Jasvinder @ 2017-09-04 13:37 UTC (permalink / raw)
  To: Rongqiang XIE, Dumitrescu, Cristian; +Cc: dev

Hi Xie,

-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Rongqiang XIE
Sent: Wednesday, August 23, 2017 8:06 AM
To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
Cc: dev@dpdk.org; Rongqiang XIE <xie.rongqiang@zte.com.cn>
Subject: [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound

In function rte_pipeline_compute_masks(), the value pos equal
p->entries[i]->action,type constraint p->entries[i]->action is
[0,4],but array action_mask1 size is 4,it possible attempt to access element 4 of array action_mask1.And also in function rte_pipeline_run(),it possible attempt to access element 4 of array action_mask0.

Signed-off-by: Rongqiang XIE <xie.rongqiang@zte.com.cn>
---
 lib/librte_pipeline/rte_pipeline.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pipeline/rte_pipeline.c b/lib/librte_pipeline/rte_pipeline.c
index 7f8fbac..2914445 100644
--- a/lib/librte_pipeline/rte_pipeline.c
+++ b/lib/librte_pipeline/rte_pipeline.c
@@ -155,8 +155,8 @@ struct rte_pipeline {
 	/* Pipeline run structures */
 	struct rte_mbuf *pkts[RTE_PORT_IN_BURST_SIZE_MAX];
 	struct rte_pipeline_table_entry *entries[RTE_PORT_IN_BURST_SIZE_MAX];
-	uint64_t action_mask0[RTE_PIPELINE_ACTIONS];
-	uint64_t action_mask1[RTE_PIPELINE_ACTIONS];
+	uint64_t action_mask0[RTE_PIPELINE_ACTIONS + 1];
+	uint64_t action_mask1[RTE_PIPELINE_ACTIONS + 1];
 	uint64_t pkts_mask;
 	uint64_t n_pkts_ah_drop;
 	uint64_t pkts_drop_mask;


How about making library more robust by introducing some checks to make sure that action field value doesn't overshoot?
The action field value can be checked in the following functions meant for adding table entries. 
rte_pipeline_table_default_entry_add(),
rte_pipeline_table_entry_add(),
rte_pipeline_table_entry_add_bulk() 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound
  2017-08-23  7:05 [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound Rongqiang XIE
  2017-09-04 13:37 ` Singh, Jasvinder
@ 2017-09-20 12:01 ` Dumitrescu, Cristian
  1 sibling, 0 replies; 3+ messages in thread
From: Dumitrescu, Cristian @ 2017-09-20 12:01 UTC (permalink / raw)
  To: Rongqiang XIE; +Cc: dev, Singh, Jasvinder



> -----Original Message-----
> From: Rongqiang XIE [mailto:xie.rongqiang@zte.com.cn]
> Sent: Wednesday, August 23, 2017 8:06 AM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org; Rongqiang XIE <xie.rongqiang@zte.com.cn>
> Subject: [PATCH] lib/librte_pipeline:fix the array index out of bound
> 
> In function rte_pipeline_compute_masks(), the value pos equal
> p->entries[i]->action,type constraint p->entries[i]->action is
> [0,4],but array action_mask1 size is 4,it possible attempt to
> access element 4 of array action_mask1.And also in function
> rte_pipeline_run(),it possible attempt to access element 4 of
> array action_mask0.
> 
> Signed-off-by: Rongqiang XIE <xie.rongqiang@zte.com.cn>
> ---
>  lib/librte_pipeline/rte_pipeline.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_pipeline/rte_pipeline.c
> b/lib/librte_pipeline/rte_pipeline.c
> index 7f8fbac..2914445 100644
> --- a/lib/librte_pipeline/rte_pipeline.c
> +++ b/lib/librte_pipeline/rte_pipeline.c
> @@ -155,8 +155,8 @@ struct rte_pipeline {
>  	/* Pipeline run structures */
>  	struct rte_mbuf *pkts[RTE_PORT_IN_BURST_SIZE_MAX];
>  	struct rte_pipeline_table_entry
> *entries[RTE_PORT_IN_BURST_SIZE_MAX];
> -	uint64_t action_mask0[RTE_PIPELINE_ACTIONS];
> -	uint64_t action_mask1[RTE_PIPELINE_ACTIONS];
> +	uint64_t action_mask0[RTE_PIPELINE_ACTIONS + 1];
> +	uint64_t action_mask1[RTE_PIPELINE_ACTIONS + 1];
>  	uint64_t pkts_mask;
>  	uint64_t n_pkts_ah_drop;
>  	uint64_t pkts_drop_mask;
> --
> 1.8.3.1
> 
> 

NAK

Hi Rongqiang,

Thanks for your patch, but I think there is a confusion on your side here:

	pos = p->entries[i]->action can only be 0 .. 3 (and not: 0 .. 4), as the last value in the enum rte_pipeline_action, namely RTE_PIPELINE_ACTIONS (equal to 4), is not a valid action, but the number of valid actions (which are specified by enu values 0 ..3).

Makes sense?

Regards,
Cristian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-20 12:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-23  7:05 [dpdk-dev] [PATCH] lib/librte_pipeline:fix the array index out of bound Rongqiang XIE
2017-09-04 13:37 ` Singh, Jasvinder
2017-09-20 12:01 ` Dumitrescu, Cristian

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).