From: Dan Carpenter <dan.carpenter@oracle.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: kernel-janitors@vger.kernel.org, netdev@vger.kernel.org,
Patrick McHardy <kaber@trash.net>,
e1000-devel@lists.sourceforge.net,
Bruce Allan <bruce.w.allan@intel.com>,
Jesse Brandeburg <jesse.brandeburg@intel.com>,
"David S. Miller" <davem@davemloft.net>,
John Ronciak <john.ronciak@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [patch -stable] igbvf: integer wrapping bug setting the mtu
Date: Fri, 13 Sep 2013 12:54:23 +0300 [thread overview]
Message-ID: <20130913095423.GH19256@mwanda> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B732F@saturn3.aculab.com>
On Fri, Sep 13, 2013 at 09:58:25AM +0100, David Laight wrote:
> > 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.
> >
> > This is a static checker fix and I'm not sure what the impact is.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
> > index 95d5430..24e3883 100644
> > --- a/drivers/net/ethernet/intel/igbvf/netdev.c
> > +++ b/drivers/net/ethernet/intel/igbvf/netdev.c
> > @@ -2342,7 +2342,7 @@ static struct net_device_stats *igbvf_get_stats(struct net_device *netdev)
> > 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;
> > + unsigned 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");
>
> It is safer to check:
> if ((new_mtu < 68) || (new_mtu > MAX_JUMBO_FRAME_SIZE - ETH_HLEN - ETH_FCS_LEN)) {
>
I believe my fix is already 100% safe... Where is the bug in my code?
Your fix harder to read because of the additional math and because it's
checking "new_mtu" when we care about "max_frame".
regards,
dan carpenter
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
next prev parent reply other threads:[~2013-09-13 9:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-13 8:37 [patch -stable] igbvf: integer wrapping bug setting the mtu Dan Carpenter
2013-09-13 8:58 ` David Laight
2013-09-13 9:54 ` Dan Carpenter [this message]
2013-09-13 10:55 ` David Laight
2013-09-13 12:29 ` [patch v2 " Dan Carpenter
2013-09-13 12:39 ` Jeff Kirsher
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=20130913095423.GH19256@mwanda \
--to=dan.carpenter@oracle.com \
--cc=David.Laight@ACULAB.COM \
--cc=bruce.w.allan@intel.com \
--cc=davem@davemloft.net \
--cc=e1000-devel@lists.sourceforge.net \
--cc=gregkh@linuxfoundation.org \
--cc=jesse.brandeburg@intel.com \
--cc=john.ronciak@intel.com \
--cc=kaber@trash.net \
--cc=kernel-janitors@vger.kernel.org \
--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).