From: Michal Schmidt <mschmidt@redhat.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Miriam Shitrit <miris@broadcom.com>,
Yuval Mintz <yuvalmin@broadcom.com>,
Ariel Elior <ariele@broadcom.com>
Subject: [PATCH net 2/2] bnx2x: fix dump flag handling
Date: Mon, 1 Jul 2013 17:23:06 +0200 [thread overview]
Message-ID: <1372692186-31032-3-git-send-email-mschmidt@redhat.com> (raw)
In-Reply-To: <1372692186-31032-1-git-send-email-mschmidt@redhat.com>
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
next prev parent reply other threads:[~2013-07-01 15:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2013-07-02 7:16 ` [PATCH net 0/2] bnx2x: ethtool dump fixes David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372692186-31032-3-git-send-email-mschmidt@redhat.com \
--to=mschmidt@redhat.com \
--cc=ariele@broadcom.com \
--cc=davem@davemloft.net \
--cc=miris@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=yuvalmin@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).