netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] bnx2x: ethtool dump fixes
@ 2013-07-01 15:23 Michal Schmidt
  2013-07-01 15:23 ` [PATCH net 1/2] bnx2x: remove zeroing of dump data buffer Michal Schmidt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michal Schmidt @ 2013-07-01 15:23 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Miriam Shitrit, Yuval Mintz, Ariel Elior

This fixes a couple of crashers in bnx2x's ethtool dump implementation.

Michal Schmidt (2):
  bnx2x: remove zeroing of dump data buffer
  bnx2x: fix dump flag handling

 drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 5 +++--
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c    | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

-- 
1.8.1.4

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

* [PATCH net 1/2] bnx2x: remove zeroing of dump data buffer
  2013-07-01 15:23 [PATCH net 0/2] bnx2x: ethtool dump fixes Michal Schmidt
@ 2013-07-01 15:23 ` Michal Schmidt
  2013-07-01 15:23 ` [PATCH net 2/2] bnx2x: fix dump flag handling Michal Schmidt
  2013-07-02  7:16 ` [PATCH net 0/2] bnx2x: ethtool dump fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Schmidt @ 2013-07-01 15:23 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Miriam Shitrit, Yuval Mintz, Ariel Elior

There is no need to initialize the dump data with zeros.
data is allocated with vzalloc, so it's already zero-filled.

More importantly, the memset is harmful, because dump->len (the length
requested by userspace) can be bigger than the allocated buffer (whose
size is determined by asking the driver's .get_dump_flag method).

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index ce1a916..61ccae5 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -986,8 +986,6 @@ static int bnx2x_get_dump_data(struct net_device *dev,
 	struct bnx2x *bp = netdev_priv(dev);
 	struct dump_header dump_hdr = {0};
 
-	memset(p, 0, dump->len);
-
 	/* Disable parity attentions as long as following dump may
 	 * cause false alarms by reading never written registers. We
 	 * will re-enable parity attentions right after the dump.
-- 
1.8.1.4

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

* [PATCH net 2/2] bnx2x: fix dump flag handling
  2013-07-01 15:23 [PATCH net 0/2] bnx2x: ethtool dump fixes Michal Schmidt
  2013-07-01 15:23 ` [PATCH net 1/2] bnx2x: remove zeroing of dump data buffer Michal Schmidt
@ 2013-07-01 15:23 ` Michal Schmidt
  2013-07-02  7:16 ` [PATCH net 0/2] bnx2x: ethtool dump fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Schmidt @ 2013-07-01 15:23 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Miriam Shitrit, Yuval Mintz, Ariel Elior

bnx2x interprets the dump flag as an index of a register preset.
It is important to validate the index to avoid out of bounds
memory accesses.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 3 +++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c    | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index 61ccae5..10b52b0 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -960,6 +960,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
 	struct bnx2x *bp = netdev_priv(dev);
 
 	/* Use the ethtool_dump "flag" field as the dump preset index */
+	if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
+		return -EINVAL;
+
 	bp->dump_preset_idx = val->flag;
 	return 0;
 }
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index b4c9dea..2a9927f 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -11497,6 +11497,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
 		bp->min_msix_vec_cnt = 2;
 	BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
 
+	bp->dump_preset_idx = 1;
+
 	return rc;
 }
 
-- 
1.8.1.4

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

* Re: [PATCH net 0/2] bnx2x: ethtool dump fixes
  2013-07-01 15:23 [PATCH net 0/2] bnx2x: ethtool dump fixes Michal Schmidt
  2013-07-01 15:23 ` [PATCH net 1/2] bnx2x: remove zeroing of dump data buffer Michal Schmidt
  2013-07-01 15:23 ` [PATCH net 2/2] bnx2x: fix dump flag handling Michal Schmidt
@ 2013-07-02  7:16 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-07-02  7:16 UTC (permalink / raw)
  To: mschmidt; +Cc: netdev, miris, yuvalmin, ariele

From: Michal Schmidt <mschmidt@redhat.com>
Date: Mon,  1 Jul 2013 17:23:04 +0200

> This fixes a couple of crashers in bnx2x's ethtool dump implementation.

Both applied.

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

end of thread, other threads:[~2013-07-02  7:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-01 15:23 [PATCH net 0/2] bnx2x: ethtool dump fixes Michal Schmidt
2013-07-01 15:23 ` [PATCH net 1/2] bnx2x: remove zeroing of dump data buffer Michal Schmidt
2013-07-01 15:23 ` [PATCH net 2/2] bnx2x: fix dump flag handling Michal Schmidt
2013-07-02  7:16 ` [PATCH net 0/2] bnx2x: ethtool dump fixes David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).