[dpdk-dev] examples/l2fwd-crypto: fix incorrect stats array length

Message ID 1467034665-30988-1-git-send-email-pablo.de.lara.guarch@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

De Lara Guarch, Pablo June 27, 2016, 1:37 p.m. UTC
  crypto_statistics array was not big enough for storing
all the possible crypto device statistics, as its size was
RTE_MAX_ETHPORTS, but should be RTE_CRYPTO_MAX_DEVS, leading
this to a potential out-of-bounds issue.

Coverity issue: 120145

Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 examples/l2fwd-crypto/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Doherty, Declan June 28, 2016, 8:28 a.m. UTC | #1
On 27/06/16 14:37, Pablo de Lara wrote:
> crypto_statistics array was not big enough for storing
> all the possible crypto device statistics, as its size was
> RTE_MAX_ETHPORTS, but should be RTE_CRYPTO_MAX_DEVS, leading
> this to a potential out-of-bounds issue.
>
> Coverity issue: 120145
>
> Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application")
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>  examples/l2fwd-crypto/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
> index 8dc616d..70fada5 100644
> --- a/examples/l2fwd-crypto/main.c
> +++ b/examples/l2fwd-crypto/main.c
> @@ -243,7 +243,7 @@ struct l2fwd_crypto_statistics {
>  } __rte_cache_aligned;
>
>  struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];
> -struct l2fwd_crypto_statistics crypto_statistics[RTE_MAX_ETHPORTS];
> +struct l2fwd_crypto_statistics crypto_statistics[RTE_CRYPTO_MAX_DEVS];
>
>  /* A tsc-based timer responsible for triggering statistics printout */
>  #define TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */
>
Acked-by: Declan Doherty <declan.doherty@intel.com>
  
Thomas Monjalon July 11, 2016, 3:05 p.m. UTC | #2
2016-06-28 09:28, Declan Doherty:
> On 27/06/16 14:37, Pablo de Lara wrote:
> > crypto_statistics array was not big enough for storing
> > all the possible crypto device statistics, as its size was
> > RTE_MAX_ETHPORTS, but should be RTE_CRYPTO_MAX_DEVS, leading
> > this to a potential out-of-bounds issue.
> >
> > Coverity issue: 120145
> >
> > Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application")
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
>
> Acked-by: Declan Doherty <declan.doherty@intel.com>

Slawomir sent the same fix, so kind of applied :)
  

Patch

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 8dc616d..70fada5 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -243,7 +243,7 @@  struct l2fwd_crypto_statistics {
 } __rte_cache_aligned;
 
 struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];
-struct l2fwd_crypto_statistics crypto_statistics[RTE_MAX_ETHPORTS];
+struct l2fwd_crypto_statistics crypto_statistics[RTE_CRYPTO_MAX_DEVS];
 
 /* A tsc-based timer responsible for triggering statistics printout */
 #define TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */