All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe
@ 2015-10-26 15:15 clsoto
  2015-10-26 17:02 ` Or Gerlitz
  0 siblings, 1 reply; 3+ messages in thread
From: clsoto @ 2015-10-26 15:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, ogerlitz, brking, jackm, 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. Also correct a memset of cmd_eqe to use the sizeof
mlx4_eqe instead of eqe_size. 

Fixes: 08ff32352d6f ('mlx4: 64-byte CQE/EQE support')
Signed-off-by: Carol L Soto <clsoto@linux.vnet.ibm.com>

---
 drivers/net/ethernet/mellanox/mlx4/cmd.c | 2 +-
 drivers/net/ethernet/mellanox/mlx4/eq.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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);
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 v2] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe
  2015-10-26 15:15 [PATCH v2] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe clsoto
@ 2015-10-26 17:02 ` Or Gerlitz
  2015-10-26 18:27   ` Carol Soto
  0 siblings, 1 reply; 3+ messages in thread
From: Or Gerlitz @ 2015-10-26 17:02 UTC (permalink / raw)
  To: Carol L Soto
  Cc: David Miller, Linux Netdev List, Or Gerlitz, brking,
	Jack Morgenstein

On Mon, Oct 26, 2015 at 5:15 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. Also correct a memset of cmd_eqe to use the sizeof
> mlx4_eqe instead of eqe_size.
>
> Fixes: 08ff32352d6f ('mlx4: 64-byte CQE/EQE support')
> Signed-off-by: Carol L Soto <clsoto@linux.vnet.ibm.com>

Thanks Carol, I'd like to review this a bit more tomorrow and will
send it with another fix/es to net

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

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



On 10/26/2015 12:02 PM, Or Gerlitz wrote:
> On Mon, Oct 26, 2015 at 5:15 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. Also correct a memset of cmd_eqe to use the sizeof
>> mlx4_eqe instead of eqe_size.
>>
>> Fixes: 08ff32352d6f ('mlx4: 64-byte CQE/EQE support')
>> Signed-off-by: Carol L Soto <clsoto@linux.vnet.ibm.com>
> Thanks Carol, I'd like to review this a bit more tomorrow and will
> send it with another fix/es to net
Sure thanks.

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

end of thread, other threads:[~2015-10-26 18:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-26 15:15 [PATCH v2] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe clsoto
2015-10-26 17:02 ` Or Gerlitz
2015-10-26 18:27   ` Carol Soto

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.