All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] dpaa2-eth: Fix possible access beyond end of array
@ 2019-03-20 14:11 Ioana Ciocoi Radulescu
  2019-03-20 23:29 ` David Miller
  2019-03-24 18:28 ` Jesper Dangaard Brouer
  0 siblings, 2 replies; 6+ messages in thread
From: Ioana Ciocoi Radulescu @ 2019-03-20 14:11 UTC (permalink / raw)
  To: netdev, davem; +Cc: Ioana Ciornei, brouer

Make sure we don't try to enqueue XDP_REDIRECT frames to an
inexistent FQ.

While it is guaranteed not to have more than one queue per core,
having fewer queues than CPUs on an interface is a valid
configuration.

Fixes: d678be1dc1ec ("dpaa2-eth: add XDP_REDIRECT support")
Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 2ba49e9..1a68052 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -1817,7 +1817,7 @@ static int dpaa2_eth_xdp_xmit_frame(struct net_device *net_dev,
 	dpaa2_fd_set_format(&fd, dpaa2_fd_single);
 	dpaa2_fd_set_ctrl(&fd, FD_CTRL_PTA);
 
-	fq = &priv->fq[smp_processor_id()];
+	fq = &priv->fq[smp_processor_id() % dpaa2_eth_queue_count(priv)];
 	for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) {
 		err = priv->enqueue(priv, fq, &fd, 0);
 		if (err != -EBUSY)
-- 
2.7.4


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

* Re: [PATCH net] dpaa2-eth: Fix possible access beyond end of array
  2019-03-20 14:11 [PATCH net] dpaa2-eth: Fix possible access beyond end of array Ioana Ciocoi Radulescu
@ 2019-03-20 23:29 ` David Miller
  2019-03-21 15:26   ` Ioana Ciocoi Radulescu
  2019-03-24 18:28 ` Jesper Dangaard Brouer
  1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2019-03-20 23:29 UTC (permalink / raw)
  To: ruxandra.radulescu; +Cc: netdev, ioana.ciornei, brouer

From: Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com>
Date: Wed, 20 Mar 2019 14:11:04 +0000

> Make sure we don't try to enqueue XDP_REDIRECT frames to an
> inexistent FQ.
> 
> While it is guaranteed not to have more than one queue per core,
> having fewer queues than CPUs on an interface is a valid
> configuration.
> 
> Fixes: d678be1dc1ec ("dpaa2-eth: add XDP_REDIRECT support")
> Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>
> Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>

Applied, thanks.

I hope the modulus operation doesn't start showing up on profiles.

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

* RE: [PATCH net] dpaa2-eth: Fix possible access beyond end of array
  2019-03-20 23:29 ` David Miller
@ 2019-03-21 15:26   ` Ioana Ciocoi Radulescu
  0 siblings, 0 replies; 6+ messages in thread
From: Ioana Ciocoi Radulescu @ 2019-03-21 15:26 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Ioana Ciornei, brouer

> -----Original Message-----
> From: David Miller <davem@davemloft.net>
> Sent: Thursday, March 21, 2019 1:29 AM
> To: Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com>
> Cc: netdev@vger.kernel.org; Ioana Ciornei <ioana.ciornei@nxp.com>;
> brouer@redhat.com
> Subject: Re: [PATCH net] dpaa2-eth: Fix possible access beyond end of array
> 
> From: Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com>
> Date: Wed, 20 Mar 2019 14:11:04 +0000
> 
> > Make sure we don't try to enqueue XDP_REDIRECT frames to an
> > inexistent FQ.
> >
> > While it is guaranteed not to have more than one queue per core,
> > having fewer queues than CPUs on an interface is a valid
> > configuration.
> >
> > Fixes: d678be1dc1ec ("dpaa2-eth: add XDP_REDIRECT support")
> > Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>
> > Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
> 
> Applied, thanks.
> 
> I hope the modulus operation doesn't start showing up on profiles.

I haven't seen any performance impact on XDP_REDIRECT numbers.

Also, I think this patch should be added to stable as well, the bug it
fixes is quite ugly.

Thanks,
Ioana

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

* Re: [PATCH net] dpaa2-eth: Fix possible access beyond end of array
  2019-03-20 14:11 [PATCH net] dpaa2-eth: Fix possible access beyond end of array Ioana Ciocoi Radulescu
  2019-03-20 23:29 ` David Miller
@ 2019-03-24 18:28 ` Jesper Dangaard Brouer
  2019-03-25  9:42   ` Ioana Ciocoi Radulescu
  1 sibling, 1 reply; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2019-03-24 18:28 UTC (permalink / raw)
  To: Ioana Ciocoi Radulescu; +Cc: netdev, davem, Ioana Ciornei, brouer

On Wed, 20 Mar 2019 14:11:04 +0000
Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com> wrote:

> Make sure we don't try to enqueue XDP_REDIRECT frames to an
> inexistent FQ.
> 
> While it is guaranteed not to have more than one queue per core,
> having fewer queues than CPUs on an interface is a valid
> configuration.
> 
> Fixes: d678be1dc1ec ("dpaa2-eth: add XDP_REDIRECT support")
> Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>
> Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
> ---
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> index 2ba49e9..1a68052 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> @@ -1817,7 +1817,7 @@ static int dpaa2_eth_xdp_xmit_frame(struct net_device *net_dev,
>  	dpaa2_fd_set_format(&fd, dpaa2_fd_single);
>  	dpaa2_fd_set_ctrl(&fd, FD_CTRL_PTA);
>  
> -	fq = &priv->fq[smp_processor_id()];
> +	fq = &priv->fq[smp_processor_id() % dpaa2_eth_queue_count(priv)];
>  	for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) {
>  		err = priv->enqueue(priv, fq, &fd, 0);

Are you sure this is correct?
How do you guard/lock concurrent CPUs from accessing 'fq' ?

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

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

* RE: [PATCH net] dpaa2-eth: Fix possible access beyond end of array
  2019-03-24 18:28 ` Jesper Dangaard Brouer
@ 2019-03-25  9:42   ` Ioana Ciocoi Radulescu
  2019-03-25 11:25     ` Jesper Dangaard Brouer
  0 siblings, 1 reply; 6+ messages in thread
From: Ioana Ciocoi Radulescu @ 2019-03-25  9:42 UTC (permalink / raw)
  To: Jesper Dangaard Brouer; +Cc: netdev, davem, Ioana Ciornei

> -----Original Message-----
> From: Jesper Dangaard Brouer <brouer@redhat.com>
> Sent: Sunday, March 24, 2019 8:29 PM
> To: Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com>
> Cc: netdev@vger.kernel.org; davem@davemloft.net; Ioana Ciornei
> <ioana.ciornei@nxp.com>; brouer@redhat.com
> Subject: Re: [PATCH net] dpaa2-eth: Fix possible access beyond end of array
> 
> On Wed, 20 Mar 2019 14:11:04 +0000
> Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com> wrote:
> 
> > Make sure we don't try to enqueue XDP_REDIRECT frames to an
> > inexistent FQ.
> >
> > While it is guaranteed not to have more than one queue per core,
> > having fewer queues than CPUs on an interface is a valid
> > configuration.
> >
> > Fixes: d678be1dc1ec ("dpaa2-eth: add XDP_REDIRECT support")
> > Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>
> > Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
> > ---
> >  drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > index 2ba49e9..1a68052 100644
> > --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > @@ -1817,7 +1817,7 @@ static int dpaa2_eth_xdp_xmit_frame(struct
> net_device *net_dev,
> >  	dpaa2_fd_set_format(&fd, dpaa2_fd_single);
> >  	dpaa2_fd_set_ctrl(&fd, FD_CTRL_PTA);
> >
> > -	fq = &priv->fq[smp_processor_id()];
> > +	fq = &priv->fq[smp_processor_id() % dpaa2_eth_queue_count(priv)];
> >  	for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) {
> >  		err = priv->enqueue(priv, fq, &fd, 0);
> 
> Are you sure this is correct?
> How do you guard/lock concurrent CPUs from accessing 'fq' ?

We only use 'fq' in the enqueue command to hardware.
Our hardware can handle concurrent enqueue commands, we
might at most get a busy response from it.

Thanks,
Ioana

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

* Re: [PATCH net] dpaa2-eth: Fix possible access beyond end of array
  2019-03-25  9:42   ` Ioana Ciocoi Radulescu
@ 2019-03-25 11:25     ` Jesper Dangaard Brouer
  0 siblings, 0 replies; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2019-03-25 11:25 UTC (permalink / raw)
  To: Ioana Ciocoi Radulescu; +Cc: netdev, davem, Ioana Ciornei, brouer

On Mon, 25 Mar 2019 09:42:22 +0000
Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com> wrote:

> > -----Original Message-----
> > From: Jesper Dangaard Brouer <brouer@redhat.com>
> > Sent: Sunday, March 24, 2019 8:29 PM
> > To: Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com>
> > Cc: netdev@vger.kernel.org; davem@davemloft.net; Ioana Ciornei
> > <ioana.ciornei@nxp.com>; brouer@redhat.com
> > Subject: Re: [PATCH net] dpaa2-eth: Fix possible access beyond end of array
> > 
> > On Wed, 20 Mar 2019 14:11:04 +0000
> > Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com> wrote:
> >   
> > > Make sure we don't try to enqueue XDP_REDIRECT frames to an
> > > inexistent FQ.
> > >
> > > While it is guaranteed not to have more than one queue per core,
> > > having fewer queues than CPUs on an interface is a valid
> > > configuration.
> > >
> > > Fixes: d678be1dc1ec ("dpaa2-eth: add XDP_REDIRECT support")
> > > Reported-by: Jesper Dangaard Brouer <brouer@redhat.com>
> > > Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
> > > ---
> > >  drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c  
> > b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c  
> > > index 2ba49e9..1a68052 100644
> > > --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > > +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > > @@ -1817,7 +1817,7 @@ static int dpaa2_eth_xdp_xmit_frame(struct  
> > net_device *net_dev,  
> > >  	dpaa2_fd_set_format(&fd, dpaa2_fd_single);
> > >  	dpaa2_fd_set_ctrl(&fd, FD_CTRL_PTA);
> > >
> > > -	fq = &priv->fq[smp_processor_id()];
> > > +	fq = &priv->fq[smp_processor_id() % dpaa2_eth_queue_count(priv)];
> > >  	for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) {
> > >  		err = priv->enqueue(priv, fq, &fd, 0);  
> > 
> > Are you sure this is correct?
> > How do you guard/lock concurrent CPUs from accessing 'fq' ?  
> 
> We only use 'fq' in the enqueue command to hardware.
> Our hardware can handle concurrent enqueue commands, we
> might at most get a busy response from it.

Great, then this should be okay :-)

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

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

end of thread, other threads:[~2019-03-25 11:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 14:11 [PATCH net] dpaa2-eth: Fix possible access beyond end of array Ioana Ciocoi Radulescu
2019-03-20 23:29 ` David Miller
2019-03-21 15:26   ` Ioana Ciocoi Radulescu
2019-03-24 18:28 ` Jesper Dangaard Brouer
2019-03-25  9:42   ` Ioana Ciocoi Radulescu
2019-03-25 11:25     ` Jesper Dangaard Brouer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.