[03/12] crypto/ipsec_mb: fix build with GCC 12

Message ID 20220518101657.1230416-4-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series Fix compilation with gcc 12 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand May 18, 2022, 10:16 a.m. UTC
  GCC 12 raises the following warning:

In function ‘__rte_ring_enqueue_elems_64’,
    inlined from ‘__rte_ring_enqueue_elems’ at
        ../lib/ring/rte_ring_elem_pvt.h:130:3,
    inlined from ‘__rte_ring_do_hts_enqueue_elem’ at
        ../lib/ring/rte_ring_hts_elem_pvt.h:196:3,
    inlined from ‘rte_ring_mp_hts_enqueue_burst_elem’ at
        ../lib/ring/rte_ring_hts.h:110:9,
    inlined from ‘rte_ring_enqueue_burst_elem’ at
        ../lib/ring/rte_ring_elem.h:577:10,
    inlined from ‘rte_ring_enqueue_burst’ at
        ../lib/ring/rte_ring.h:738:9,
    inlined from ‘process_op_bit’ at
        ../drivers/crypto/ipsec_mb/pmd_snow3g.c:425:16,
    inlined from ‘snow3g_pmd_dequeue_burst’ at
        ../drivers/crypto/ipsec_mb/pmd_snow3g.c:484:20:
../lib/ring/rte_ring_elem_pvt.h:68:44: error: array subscript 1 is
        outside array bounds of ‘struct rte_crypto_op[0]’
        [-Werror=array-bounds]
   68 |                         ring[idx + 1] = obj[i + 1];
      |                                         ~~~^~~~~~~
../drivers/crypto/ipsec_mb/pmd_snow3g.c: In function
        ‘snow3g_pmd_dequeue_burst’:
../drivers/crypto/ipsec_mb/pmd_snow3g.c:434:1: note:
        at offset 8 into object ‘op’ of size 8
  434 | snow3g_pmd_dequeue_burst(void *queue_pair,
      | ^~~~~~~~~~~~~~~~~~~~~~~~

Validate that one (exactly) op has been processed or return early.

Fixes: b537abdbee74 ("crypto/snow3g: support bit-level operations")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/crypto/ipsec_mb/pmd_snow3g.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

Bruce Richardson June 2, 2022, 9:50 a.m. UTC | #1
On Wed, May 18, 2022 at 12:16:48PM +0200, David Marchand wrote:
> GCC 12 raises the following warning:
> 
> In function ‘__rte_ring_enqueue_elems_64’,
>     inlined from ‘__rte_ring_enqueue_elems’ at
>         ../lib/ring/rte_ring_elem_pvt.h:130:3,
>     inlined from ‘__rte_ring_do_hts_enqueue_elem’ at
>         ../lib/ring/rte_ring_hts_elem_pvt.h:196:3,
>     inlined from ‘rte_ring_mp_hts_enqueue_burst_elem’ at
>         ../lib/ring/rte_ring_hts.h:110:9,
>     inlined from ‘rte_ring_enqueue_burst_elem’ at
>         ../lib/ring/rte_ring_elem.h:577:10,
>     inlined from ‘rte_ring_enqueue_burst’ at
>         ../lib/ring/rte_ring.h:738:9,
>     inlined from ‘process_op_bit’ at
>         ../drivers/crypto/ipsec_mb/pmd_snow3g.c:425:16,
>     inlined from ‘snow3g_pmd_dequeue_burst’ at
>         ../drivers/crypto/ipsec_mb/pmd_snow3g.c:484:20:
> ../lib/ring/rte_ring_elem_pvt.h:68:44: error: array subscript 1 is
>         outside array bounds of ‘struct rte_crypto_op[0]’
>         [-Werror=array-bounds]
>    68 |                         ring[idx + 1] = obj[i + 1];
>       |                                         ~~~^~~~~~~
> ../drivers/crypto/ipsec_mb/pmd_snow3g.c: In function
>         ‘snow3g_pmd_dequeue_burst’:
> ../drivers/crypto/ipsec_mb/pmd_snow3g.c:434:1: note:
>         at offset 8 into object ‘op’ of size 8
>   434 | snow3g_pmd_dequeue_burst(void *queue_pair,
>       | ^~~~~~~~~~~~~~~~~~~~~~~~
> 
> Validate that one (exactly) op has been processed or return early.
> 
> Fixes: b537abdbee74 ("crypto/snow3g: support bit-level operations")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  drivers/crypto/ipsec_mb/pmd_snow3g.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
> index ebc9a0b562..9a85f46721 100644
> --- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
> +++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
> @@ -422,12 +422,13 @@ process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
>  		op->sym->session = NULL;
>  	}
>  
> -	enqueued_op = rte_ring_enqueue_burst(qp->ingress_queue,
> -			(void **)&op, processed_op, NULL);
> +	if (unlikely(processed_op != 1))
> +		return 0;
> +	enqueued_op = rte_ring_enqueue(qp->ingress_queue, op);

As a fix for the compiler warning this looks ok, but question for
maintainer would be - should this check for processed_op != 1 not go
earlier in the function, immediately after the switch statement?

Fan, Pablo, can you please comment?

/Bruce
  
David Marchand June 10, 2022, 1:07 p.m. UTC | #2
On Thu, Jun 2, 2022 at 11:50 AM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Wed, May 18, 2022 at 12:16:48PM +0200, David Marchand wrote:
> > GCC 12 raises the following warning:
> >
> > In function ‘__rte_ring_enqueue_elems_64’,
> >     inlined from ‘__rte_ring_enqueue_elems’ at
> >         ../lib/ring/rte_ring_elem_pvt.h:130:3,
> >     inlined from ‘__rte_ring_do_hts_enqueue_elem’ at
> >         ../lib/ring/rte_ring_hts_elem_pvt.h:196:3,
> >     inlined from ‘rte_ring_mp_hts_enqueue_burst_elem’ at
> >         ../lib/ring/rte_ring_hts.h:110:9,
> >     inlined from ‘rte_ring_enqueue_burst_elem’ at
> >         ../lib/ring/rte_ring_elem.h:577:10,
> >     inlined from ‘rte_ring_enqueue_burst’ at
> >         ../lib/ring/rte_ring.h:738:9,
> >     inlined from ‘process_op_bit’ at
> >         ../drivers/crypto/ipsec_mb/pmd_snow3g.c:425:16,
> >     inlined from ‘snow3g_pmd_dequeue_burst’ at
> >         ../drivers/crypto/ipsec_mb/pmd_snow3g.c:484:20:
> > ../lib/ring/rte_ring_elem_pvt.h:68:44: error: array subscript 1 is
> >         outside array bounds of ‘struct rte_crypto_op[0]’
> >         [-Werror=array-bounds]
> >    68 |                         ring[idx + 1] = obj[i + 1];
> >       |                                         ~~~^~~~~~~
> > ../drivers/crypto/ipsec_mb/pmd_snow3g.c: In function
> >         ‘snow3g_pmd_dequeue_burst’:
> > ../drivers/crypto/ipsec_mb/pmd_snow3g.c:434:1: note:
> >         at offset 8 into object ‘op’ of size 8
> >   434 | snow3g_pmd_dequeue_burst(void *queue_pair,
> >       | ^~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Validate that one (exactly) op has been processed or return early.
> >
> > Fixes: b537abdbee74 ("crypto/snow3g: support bit-level operations")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> >  drivers/crypto/ipsec_mb/pmd_snow3g.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
> > index ebc9a0b562..9a85f46721 100644
> > --- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
> > +++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
> > @@ -422,12 +422,13 @@ process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
> >               op->sym->session = NULL;
> >       }
> >
> > -     enqueued_op = rte_ring_enqueue_burst(qp->ingress_queue,
> > -                     (void **)&op, processed_op, NULL);
> > +     if (unlikely(processed_op != 1))
> > +             return 0;
> > +     enqueued_op = rte_ring_enqueue(qp->ingress_queue, op);
>
> As a fix for the compiler warning this looks ok, but question for
> maintainer would be - should this check for processed_op != 1 not go
> earlier in the function, immediately after the switch statement?
>
> Fan, Pablo, can you please comment?

Fan? Pablo?
  
Stephen Hemminger June 11, 2022, 3:34 p.m. UTC | #3
On Wed, 18 May 2022 12:16:48 +0200
David Marchand <david.marchand@redhat.com> wrote:

> GCC 12 raises the following warning:
> 
> In function ‘__rte_ring_enqueue_elems_64’,
>     inlined from ‘__rte_ring_enqueue_elems’ at
>         ../lib/ring/rte_ring_elem_pvt.h:130:3,
>     inlined from ‘__rte_ring_do_hts_enqueue_elem’ at
>         ../lib/ring/rte_ring_hts_elem_pvt.h:196:3,
>     inlined from ‘rte_ring_mp_hts_enqueue_burst_elem’ at
>         ../lib/ring/rte_ring_hts.h:110:9,
>     inlined from ‘rte_ring_enqueue_burst_elem’ at
>         ../lib/ring/rte_ring_elem.h:577:10,
>     inlined from ‘rte_ring_enqueue_burst’ at
>         ../lib/ring/rte_ring.h:738:9,
>     inlined from ‘process_op_bit’ at
>         ../drivers/crypto/ipsec_mb/pmd_snow3g.c:425:16,
>     inlined from ‘snow3g_pmd_dequeue_burst’ at
>         ../drivers/crypto/ipsec_mb/pmd_snow3g.c:484:20:
> ../lib/ring/rte_ring_elem_pvt.h:68:44: error: array subscript 1 is
>         outside array bounds of ‘struct rte_crypto_op[0]’
>         [-Werror=array-bounds]
>    68 |                         ring[idx + 1] = obj[i + 1];
>       |                                         ~~~^~~~~~~
> ../drivers/crypto/ipsec_mb/pmd_snow3g.c: In function
>         ‘snow3g_pmd_dequeue_burst’:
> ../drivers/crypto/ipsec_mb/pmd_snow3g.c:434:1: note:
>         at offset 8 into object ‘op’ of size 8
>   434 | snow3g_pmd_dequeue_burst(void *queue_pair,
>       | ^~~~~~~~~~~~~~~~~~~~~~~~
> 
> Validate that one (exactly) op has been processed or return early.
> 
> Fixes: b537abdbee74 ("crypto/snow3g: support bit-level operations")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  

Patch

diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c
index ebc9a0b562..9a85f46721 100644
--- a/drivers/crypto/ipsec_mb/pmd_snow3g.c
+++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c
@@ -422,12 +422,13 @@  process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session,
 		op->sym->session = NULL;
 	}
 
-	enqueued_op = rte_ring_enqueue_burst(qp->ingress_queue,
-			(void **)&op, processed_op, NULL);
+	if (unlikely(processed_op != 1))
+		return 0;
+	enqueued_op = rte_ring_enqueue(qp->ingress_queue, op);
 	qp->stats.enqueued_count += enqueued_op;
 	*accumulated_enqueued_ops += enqueued_op;
 
-	return enqueued_op;
+	return 1;
 }
 
 static uint16_t