From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, gospo@redhat.com, bphilips@novell.com,
Don Skidmore <donald.c.skidmore@intel.com>,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next-2.6 PATCH 01/20] ixgbe: cleanup ixgbe_get_drvinfo to be extra careful with buffer boundaries
Date: Thu, 19 Aug 2010 16:33:16 -0700 [thread overview]
Message-ID: <20100819233052.10335.13176.stgit@localhost.localdomain> (raw)
From: Don Skidmore <donald.c.skidmore@intel.com>
Make the code in ixgbe_get_drvinfo more protected against buffer overflow
boundaries by using snprintf and sizeof with snprintf.
Signed-off-by: Don Skidmore <donald.c.skidmore@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ixgbe/ixgbe_ethtool.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index dcebc82..fb6d8e8 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -820,16 +820,19 @@ static void ixgbe_get_drvinfo(struct net_device *netdev,
struct ixgbe_adapter *adapter = netdev_priv(netdev);
char firmware_version[32];
- strncpy(drvinfo->driver, ixgbe_driver_name, 32);
- strncpy(drvinfo->version, ixgbe_driver_version, 32);
-
- sprintf(firmware_version, "%d.%d-%d",
- (adapter->eeprom_version & 0xF000) >> 12,
- (adapter->eeprom_version & 0x0FF0) >> 4,
- adapter->eeprom_version & 0x000F);
-
- strncpy(drvinfo->fw_version, firmware_version, 32);
- strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
+ strncpy(drvinfo->driver, ixgbe_driver_name, sizeof(drvinfo->driver));
+ strncpy(drvinfo->version, ixgbe_driver_version,
+ sizeof(drvinfo->version));
+
+ snprintf(firmware_version, sizeof(firmware_version), "%d.%d-%d",
+ (adapter->eeprom_version & 0xF000) >> 12,
+ (adapter->eeprom_version & 0x0FF0) >> 4,
+ adapter->eeprom_version & 0x000F);
+
+ strncpy(drvinfo->fw_version, firmware_version,
+ sizeof(drvinfo->fw_version));
+ strncpy(drvinfo->bus_info, pci_name(adapter->pdev),
+ sizeof(drvinfo->bus_info));
drvinfo->n_stats = IXGBE_STATS_LEN;
drvinfo->testinfo_len = IXGBE_TEST_LEN;
drvinfo->regdump_len = ixgbe_get_regs_len(netdev);
next reply other threads:[~2010-08-19 23:33 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-19 23:33 Jeff Kirsher [this message]
2010-08-19 23:33 ` [net-next-2.6 PATCH 02/20] ixgbe: remove redundant DMA alignment code Jeff Kirsher
2010-08-19 23:45 ` David Miller
2010-08-19 23:34 ` [net-next-2.6 PATCH 03/20] ixgbe: move setting of GSO size for 82598 into ixgbe_configure_dcb Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:34 ` [net-next-2.6 PATCH 04/20] ixgbe: combine two modifications of TXDCTL into one Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:34 ` [net-next-2.6 PATCH 05/20] ixgbe: move configuration of the MTQC register into it's own function Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:35 ` [net-next-2.6 PATCH 06/20] ixgbe: move Tx ring configuration into a separate function Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:35 ` [net-next-2.6 PATCH 07/20] ixgbe: consolidate all setting of MRQC into one function Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:36 ` [net-next-2.6 PATCH 08/20] ixgbe: pull ring configuration into it's own function Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:36 ` [net-next-2.6 PATCH 09/20] ixgbe: pull PSRTYPE configuration into a separate function Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:36 ` [net-next-2.6 PATCH 10/20] ixgbe: combine accesses to FCTRL register into ixgbe_set_rx_mode Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:37 ` [net-next-2.6 PATCH 11/20] ixgbe: bump PS header size to 512 bytes Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:37 ` [net-next-2.6 PATCH 12/20] ixgbe: remove redundant configuration of vmolr, rename generic variable Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:38 ` [net-next-2.6 PATCH 13/20] ixgbe: Move max frame size and Rx buffer length configuration into a function Jeff Kirsher
2010-08-19 23:46 ` David Miller
2010-08-19 23:38 ` [net-next-2.6 PATCH 14/20] ixgbe: move all Rx DMA control register writes to one central location Jeff Kirsher
2010-08-19 23:47 ` David Miller
2010-08-19 23:38 ` [net-next-2.6 PATCH 15/20] ixgbe: Move virtualization config into a separate function Jeff Kirsher
2010-08-19 23:47 ` David Miller
2010-08-19 23:39 ` [net-next-2.6 PATCH 16/20] ixgbe: move all GPIE register config into a single function Jeff Kirsher
2010-08-19 23:47 ` David Miller
2010-08-19 23:39 ` [net-next-2.6 PATCH 17/20] ixgbe: pull all Tx init into ixgbe_configure_tx Jeff Kirsher
2010-08-19 23:47 ` David Miller
2010-08-19 23:40 ` [net-next-2.6 PATCH 18/20] ixgbe: combine Rx into into ixgbe_configure_rx Jeff Kirsher
2010-08-19 23:47 ` David Miller
2010-08-19 23:40 ` [net-next-2.6 PATCH 19/20] ixgbe: update all DESC_ADV macros to accept a ring pointer Jeff Kirsher
2010-08-19 23:47 ` David Miller
2010-08-19 23:40 ` [net-next-2.6 PATCH 20/20] ixgbe: rewrite ethtool test to use standard config functions Jeff Kirsher
2010-08-19 23:47 ` David Miller
2010-08-19 23:45 ` [net-next-2.6 PATCH 01/20] ixgbe: cleanup ixgbe_get_drvinfo to be extra careful with buffer boundaries 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=20100819233052.10335.13176.stgit@localhost.localdomain \
--to=jeffrey.t.kirsher@intel.com \
--cc=bphilips@novell.com \
--cc=davem@davemloft.net \
--cc=donald.c.skidmore@intel.com \
--cc=gospo@redhat.com \
--cc=netdev@vger.kernel.org \
/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).