From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 01/11] igbvf: integer wrapping bug setting the mtu
Date: Thu, 24 Oct 2013 08:27:28 -0700 [thread overview]
Message-ID: <1382628458-26601-2-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1382628458-26601-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Dan Carpenter <dan.carpenter@oracle.com>
If new_mtu is very large then "new_mtu + ETH_HLEN + ETH_FCS_LEN" can
wrap and the check on the next line can underflow. This is one of those
bugs which can be triggered by the user if you have namespaces
configured.
Also since this is something the user can trigger then we don't want to
have dev_err() message.
This is a static checker fix and I'm not sure what the impact is.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Tested-by: Sibai Li Sibai.li@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/igbvf/netdev.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index 93eb7ee..f48ae71 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -2343,10 +2343,9 @@ static int igbvf_change_mtu(struct net_device *netdev, int new_mtu)
struct igbvf_adapter *adapter = netdev_priv(netdev);
int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
- if ((new_mtu < 68) || (max_frame > MAX_JUMBO_FRAME_SIZE)) {
- dev_err(&adapter->pdev->dev, "Invalid MTU setting\n");
+ if (new_mtu < 68 || new_mtu > INT_MAX - ETH_HLEN - ETH_FCS_LEN ||
+ max_frame > MAX_JUMBO_FRAME_SIZE)
return -EINVAL;
- }
#define MAX_STD_JUMBO_FRAME_SIZE 9234
if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
--
1.8.3.1
next prev parent reply other threads:[~2013-10-24 15:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 15:27 [net-next 00/11][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2013-10-24 15:27 ` Jeff Kirsher [this message]
2013-10-24 15:27 ` [net-next 02/11] igbvf: add missing iounmap() on error in igbvf_probe() Jeff Kirsher
2013-10-24 15:27 ` [net-next 03/11] i40e: remove unused including <linux/version.h> Jeff Kirsher
2013-10-24 15:27 ` [net-next 04/11] igb: Fix master/slave mode for all m88 i354 PHY's Jeff Kirsher
2013-10-24 15:27 ` [net-next 05/11] igb: fix driver reload with VF assigned to guest Jeff Kirsher
2013-10-24 15:27 ` [net-next 06/11] ixgbe: cleanup ixgbe_enumerate_functions Jeff Kirsher
2013-10-24 15:27 ` [net-next 07/11] ixgbe: use pcie_capability_read_word() to simplify code Jeff Kirsher
2013-10-24 15:27 ` [net-next 08/11] ixgbe: fix rx-usecs range checks for BQL Jeff Kirsher
2013-10-24 15:27 ` [net-next 09/11] ixgbevf: Adds function to set PSRTYPE register Jeff Kirsher
2013-10-24 15:27 ` [net-next 10/11] ixgbevf: implement ethtool get/set coalesce Jeff Kirsher
2013-10-24 15:27 ` [net-next 11/11] ixgbevf: bump driver version Jeff Kirsher
2013-10-26 4:30 ` [net-next 00/11][pull request] Intel Wired LAN Driver Updates 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=1382628458-26601-2-git-send-email-jeffrey.t.kirsher@intel.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=gospo@redhat.com \
--cc=netdev@vger.kernel.org \
--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).