From: Dan Carpenter <dan.carpenter@oracle.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Tom Gundersen <teg@jklm.no>,
David Herrmann <dh.herrmann@gmail.com>,
netdev@vger.kernel.org, Eric Dumazet <eric.dumazet@gmail.com>,
David Laight <David.Laight@ACULAB.COM>,
kernel-janitors@vger.kernel.org
Subject: [patch v2] wan/x25_asy: integer overflow in x25_asy_change_mtu()
Date: Thu, 17 Jul 2014 13:50:45 +0300 [thread overview]
Message-ID: <20140717105044.GA28140@mwanda> (raw)
In-Reply-To: <1405588471.10255.70.camel@edumazet-glaptop2.roam.corp.google.com>
If "newmtu * 2 + 4" is too large then it can cause an integer overflow
leading to memory corruption. Eric Dumazet suggests that 65534 is a
reasonable upper limit.
Btw, "newmtu" is not allowed to be a negative number because of the
check in dev_set_mtu(), so that's ok.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Cap it at 65534 instead of just testing for integer overflows.
Thanks David and Eric!
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index df6c073..5c47b01 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -122,8 +122,12 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
{
struct x25_asy *sl = netdev_priv(dev);
unsigned char *xbuff, *rbuff;
- int len = 2 * newmtu;
+ int len;
+ if (newmtu > 65534)
+ return -EINVAL;
+
+ len = 2 * newmtu;
xbuff = kmalloc(len + 4, GFP_ATOMIC);
rbuff = kmalloc(len + 4, GFP_ATOMIC);
next prev parent reply other threads:[~2014-07-17 10:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 8:03 [patch] wan/x25_asy: integer overflow in x25_asy_change_mtu() Dan Carpenter
2014-07-17 8:45 ` David Laight
2014-07-17 8:58 ` Dan Carpenter
2014-07-17 9:14 ` Eric Dumazet
2014-07-17 10:50 ` Dan Carpenter [this message]
2014-07-17 23:48 ` [patch v2] " 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=20140717105044.GA28140@mwanda \
--to=dan.carpenter@oracle.com \
--cc=David.Laight@ACULAB.COM \
--cc=davem@davemloft.net \
--cc=dh.herrmann@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=teg@jklm.no \
/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).