public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe
@ 2015-10-23 14:19 clsoto
  2015-10-25  8:26 ` Or Gerlitz
  0 siblings, 1 reply; 3+ messages in thread
From: clsoto @ 2015-10-23 14:19 UTC (permalink / raw)
  To: davem; +Cc: netdev, ogerlitz, brking, yevgenyp, Carol L Soto

From: Carol L Soto <clsoto@linux.vnet.ibm.com>

If the caps.eqe_size is bigger than the struct mlx4_eqe then there
is a potential for corrupting data at the master context. We can see
the message "Master failed to generate an EQE for slave: X" when the 
event_eqe array wraps and we can see potential oops at the function
mlx4_GEN_EQE. 

Signed-off-by: Carol L Soto <clsoto@linux.vnet.ibm.com>
---
 drivers/net/ethernet/mellanox/mlx4/eq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index c344884..603d1c3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -196,7 +196,7 @@ static void slave_event(struct mlx4_dev *dev, u8 slave, struct mlx4_eqe *eqe)
 		return;
 	}
 
-	memcpy(s_eqe, eqe, dev->caps.eqe_size - 1);
+	memcpy(s_eqe, eqe, sizeof(struct mlx4_eqe) - 1);
 	s_eqe->slave_id = slave;
 	/* ensure all information is written before setting the ownersip bit */
 	dma_wmb();
-- 
1.8.3.1

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

* Re: [PATCH] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe
  2015-10-23 14:19 [PATCH] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe clsoto
@ 2015-10-25  8:26 ` Or Gerlitz
  2015-10-25 10:07   ` Jack Morgenstein
  0 siblings, 1 reply; 3+ messages in thread
From: Or Gerlitz @ 2015-10-25  8:26 UTC (permalink / raw)
  To: Carol L Soto
  Cc: David Miller, Linux Netdev List, Or Gerlitz, brking,
	Yevgeny Petrilin, Jack Morgenstein, Yishai Hadas

On Fri, Oct 23, 2015 at 4:19 PM,  <clsoto@linux.vnet.ibm.com> wrote:
> From: Carol L Soto <clsoto@linux.vnet.ibm.com>
>
> If the caps.eqe_size is bigger than the struct mlx4_eqe then there
> is a potential for corrupting data at the master context. We can see
> the message "Master failed to generate an EQE for slave: X" when the
> event_eqe array wraps and we can see potential oops at the function
> mlx4_GEN_EQE.
>
> Signed-off-by: Carol L Soto <clsoto@linux.vnet.ibm.com>

Hi Carol,

Does this fixes a specific commit? if yes, please add a Fixes: line
before your signature, maybe
one the changes to enable CQE/EQE striding introduced that?

43c816c67a53 net/mlx4_core: Cache line EQE size support
77507aa249ae net/mlx4_core: Enable CQE/EQE stride support

I also added Yishai and Jack who should review your fix

Or.



Or.

> ---
>  drivers/net/ethernet/mellanox/mlx4/eq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
> index c344884..603d1c3 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/eq.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
> @@ -196,7 +196,7 @@ static void slave_event(struct mlx4_dev *dev, u8 slave, struct mlx4_eqe *eqe)
>                 return;
>         }
>
> -       memcpy(s_eqe, eqe, dev->caps.eqe_size - 1);
> +       memcpy(s_eqe, eqe, sizeof(struct mlx4_eqe) - 1);
>         s_eqe->slave_id = slave;
>         /* ensure all information is written before setting the ownersip bit */
>         dma_wmb();
> --
> 1.8.3.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe
  2015-10-25  8:26 ` Or Gerlitz
@ 2015-10-25 10:07   ` Jack Morgenstein
  0 siblings, 0 replies; 3+ messages in thread
From: Jack Morgenstein @ 2015-10-25 10:07 UTC (permalink / raw)
  To: Or Gerlitz
  Cc: Carol L Soto, David Miller, Linux Netdev List, Or Gerlitz, brking,
	Yevgeny Petrilin, Yishai Hadas

Hi Carol,

Good catch!

Need to add an additional chunk to your fix -- see below.

On Sun, 25 Oct 2015 10:26:07 +0200
Or Gerlitz <gerlitz.or@gmail.com> wrote:


> 
> > ---
> >  drivers/net/ethernet/mellanox/mlx4/eq.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c
> > b/drivers/net/ethernet/mellanox/mlx4/eq.c index c344884..603d1c3
> > 100644 --- a/drivers/net/ethernet/mellanox/mlx4/eq.c
> > +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
> > @@ -196,7 +196,7 @@ static void slave_event(struct mlx4_dev *dev,
> > u8 slave, struct mlx4_eqe *eqe) return;
> >         }
> >
> > -       memcpy(s_eqe, eqe, dev->caps.eqe_size - 1);
> > +       memcpy(s_eqe, eqe, sizeof(struct mlx4_eqe) - 1);
> >         s_eqe->slave_id = slave;
> >         /* ensure all information is written before setting the
> > ownersip bit */ dma_wmb();

diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 0a32020..2177e56 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -2398,7 +2398,7 @@ int mlx4_multi_func_init(struct mlx4_dev *dev)
 			}
 		}
 
-		memset(&priv->mfunc.master.cmd_eqe, 0, dev->caps.eqe_size);
+		memset(&priv->mfunc.master.cmd_eqe, 0, sizeof(struct mlx4_eqe));
 		priv->mfunc.master.cmd_eqe.type = MLX4_EVENT_TYPE_CMD;
 		INIT_WORK(&priv->mfunc.master.comm_work,
 			  mlx4_master_comm_channel);


> > --
> > 1.8.3.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe netdev" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2015-10-25 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-23 14:19 [PATCH] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe clsoto
2015-10-25  8:26 ` Or Gerlitz
2015-10-25 10:07   ` Jack Morgenstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox