netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Mitch Williams <mitch.a.williams@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 05/16] i40evf: don't overflow buffer
Date: Tue, 28 Jun 2016 21:40:51 -0700	[thread overview]
Message-ID: <1467175262-54719-6-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1467175262-54719-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Mitch Williams <mitch.a.williams@intel.com>

If the user adds an obscene amount of MAC addresses, the driver will run
into the situation where it has too many address requests to fit into a
single PF message. The driver checks for this case, and calculates the
maximum number of messages that it can send. Then it completely ignores
this count and overflows the buffer.

Fix this by checking the address count and bailing out of the loop at
the appropriate time.

Change-ID: If8dcbb04602c75941dc0cd8309065e1de9ca791c
Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
index f134456..d76c221 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
@@ -434,6 +434,8 @@ void i40evf_add_ether_addrs(struct i40evf_adapter *adapter)
 			ether_addr_copy(veal->list[i].addr, f->macaddr);
 			i++;
 			f->add = false;
+			if (i == count)
+				break;
 		}
 	}
 	if (!more)
@@ -497,6 +499,8 @@ void i40evf_del_ether_addrs(struct i40evf_adapter *adapter)
 			i++;
 			list_del(&f->list);
 			kfree(f);
+			if (i == count)
+				break;
 		}
 	}
 	if (!more)
@@ -560,6 +564,8 @@ void i40evf_add_vlans(struct i40evf_adapter *adapter)
 			vvfl->vlan_id[i] = f->vlan;
 			i++;
 			f->add = false;
+			if (i == count)
+				break;
 		}
 	}
 	if (!more)
@@ -623,6 +629,8 @@ void i40evf_del_vlans(struct i40evf_adapter *adapter)
 			i++;
 			list_del(&f->list);
 			kfree(f);
+			if (i == count)
+				break;
 		}
 	}
 	if (!more)
-- 
2.5.5

  parent reply	other threads:[~2016-06-29  4:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29  4:40 [net-next 00/16][pull request] 40GbE Intel Wired LAN Driver Updates 2016-06-27 Jeff Kirsher
2016-06-29  4:40 ` [net-next 01/16] i40e: add functions to control default VSI Jeff Kirsher
2016-06-29  4:40 ` [net-next 02/16] i40e: add hw struct local variable Jeff Kirsher
2016-06-29 13:00   ` David Laight
2016-06-29  4:40 ` [net-next 03/16] i40e: write HENA for VFs Jeff Kirsher
2016-06-29  4:40 ` [net-next 04/16] i40e: Add a call to set the client interface down Jeff Kirsher
2016-06-29  4:40 ` Jeff Kirsher [this message]
2016-06-29  4:40 ` [net-next 06/16] i40e: Clean up MSIX IRQs before suspend Jeff Kirsher
2016-06-29  4:40 ` [net-next 07/16] i40e: Save PCI state " Jeff Kirsher
2016-06-29 14:49   ` Greg
2016-06-29  4:40 ` [net-next 08/16] i40e: fix missing DA cable check Jeff Kirsher
2016-06-29  4:40 ` [net-next 09/16] i40e: Removing unnecessary code which caused supported link mode bug Jeff Kirsher
2016-06-29  4:40 ` [net-next 10/16] i40e: Fix RSS to not be limited by the number of CPUs Jeff Kirsher
2016-06-29  4:40 ` [net-next 11/16] i40evf: always activate correct MAC address filter Jeff Kirsher
2016-06-29  4:40 ` [net-next 12/16] i40e: set default VSI without a reset Jeff Kirsher
2016-06-29  4:40 ` [net-next 13/16] i40e: add VSI info to macaddr messages Jeff Kirsher
2016-06-29  4:41 ` [net-next 14/16] i40e/i40evf: Bump version from 1.5.16 to 1.6.4 Jeff Kirsher
2016-06-29  4:41 ` [net-next 15/16] i40e: Fix errors resulted while turning off TSO Jeff Kirsher
2016-06-29  4:41 ` [net-next 16/16] i40e: Don't notify client(s) for DCB changes on all VSIs Jeff Kirsher
2016-06-29 12:23 ` [net-next 00/16][pull request] 40GbE Intel Wired LAN Driver Updates 2016-06-27 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=1467175262-54719-6-git-send-email-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=jogreene@redhat.com \
    --cc=mitch.a.williams@intel.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;
as well as URLs for NNTP newsgroup(s).