Netdev List
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Jacob Keller <jacob.e.keller@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 12/12] i40e: fix i40e_add_queue_stats data pointer update
Date: Tue,  7 Aug 2018 12:27:57 -0700	[thread overview]
Message-ID: <20180807192757.21592-13-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20180807192757.21592-1-jeffrey.t.kirsher@intel.com>

From: Jacob Keller <jacob.e.keller@intel.com>

This function accidentally failed to update the data pointer, which
caused the reported stats to be incorrect. Additionally, statistics
which follow queue stats in the output would potentially read non-zeroed
garbage data from the ethtool buffer.

This occurred because the data double pointer was not dereferenced
before incrementing the size.

Additionally, make sure this issue is more visible by adding a WARN_ONCE
to the i40e_get_ethtool_stats function. This warning will trigger
whenever the data pointer is not at the expected address, similar to the
check that we make in the i40e_get_stat_strings() function.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index cd23d1e169c2..abcd096ede14 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -1860,6 +1860,7 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
 	unsigned int i;
 	unsigned int start;
 	bool veb_stats;
+	u64 *p = data;
 
 	i40e_update_stats(vsi);
 
@@ -1902,7 +1903,7 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
 	}
 	rcu_read_unlock();
 	if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1)
-		return;
+		goto check_data_pointer;
 
 	veb_stats = ((pf->lan_veb != I40E_NO_VEB) &&
 		     (pf->flags & I40E_FLAG_VEB_STATS_ENABLED));
@@ -1925,6 +1926,10 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
 
 		i40e_add_ethtool_stats(&data, &pfc, i40e_gstrings_pfc_stats);
 	}
+
+check_data_pointer:
+	WARN_ONCE(data - p != i40e_get_stats_count(netdev),
+		  "ethtool stats count mismatch!");
 }
 
 /**
-- 
2.17.1

  parent reply	other threads:[~2018-08-07 21:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-07 19:27 [net-next 00/12][pull request] 40GbE Intel Wired LAN Driver Updates 2018-08-07 Jeff Kirsher
2018-08-07 19:27 ` [net-next 01/12] i40e: Remove duplicated prepare call in i40e_shutdown Jeff Kirsher
2018-08-07 19:27 ` [net-next 02/12] i40e/i40evf: remove redundant functions i40evf_aq_{set/get}_phy_register Jeff Kirsher
2018-08-07 19:27 ` [net-next 03/12] i40e: add helper function for copying strings from stat arrays Jeff Kirsher
2018-08-07 19:27 ` [net-next 04/12] i40e: add helper to copy statistic values into ethtool buffer Jeff Kirsher
2018-08-07 19:27 ` [net-next 05/12] i40e: Set fec_config when forcing link state Jeff Kirsher
2018-08-07 19:27 ` [net-next 06/12] i40e: convert VEB TC stats to use an i40e_stats array Jeff Kirsher
2018-08-07 19:27 ` [net-next 07/12] i40e: convert priority flow control stats to use helpers Jeff Kirsher
2018-08-07 19:27 ` [net-next 08/12] i40e: remove unnecessary i variable causing -Wshadow warning Jeff Kirsher
2018-08-07 19:27 ` [net-next 09/12] i40e: fix warning about shadowed ring parameter Jeff Kirsher
2018-08-07 19:27 ` [net-next 10/12] i40e: Add additional return code to i40e_asq_send_command Jeff Kirsher
2018-08-07 19:27 ` [net-next 11/12] i40e: Add AQ command for rearrange NVM structure Jeff Kirsher
2018-08-07 19:27 ` Jeff Kirsher [this message]
2018-08-07 22:43 ` [net-next 00/12][pull request] 40GbE Intel Wired LAN Driver Updates 2018-08-07 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=20180807192757.21592-13-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=jacob.e.keller@intel.com \
    --cc=jogreene@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.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