bnx2x: ethtool dump fixes
cover bnx2x: ethtool dump fixes
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(-)
Signature · 1 line
1.8.1.4
PATCH 1/2 bnx2x: remove zeroing of dump data buffer
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).
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +0 -2
@@ -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.
Signature · 1 line
1.8.1.4
PATCH 2/2 bnx2x: fix dump flag handling
In reply to Michal Schmidtbnx2x 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.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 3 +++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 ++ 2 files changed, 5 insertions(+)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +3 -0
@@ -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 ; }
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +2 -0
@@ -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; }
Signature · 1 line
1.8.1.4
David Miller
maintainerFrom: Michal Schmidt <[email protected]>
Date: Mon, 1 Jul 2013 17:23:04 +0200
Quoted 1 line
This fixes a couple of crashers in bnx2x's ethtool dump implementation.
Both applied.