From: Travis Brown <travisb@aristanetworks.com>
To: netdev@vger.kernel.org, travisb@aristanetworks.com
Cc: davem@davemloft.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org,
yoshfuji@linux-ipv6.org, kaber@trash.net
Subject: [PATCH] ipv6: mld: Prevent skb_over_panic with large MTUs
Date: Fri, 20 Dec 2013 17:00:10 -0800 [thread overview]
Message-ID: <1387587610-31723-1-git-send-email-travisb@aristanetworks.com> (raw)
MLD limits the maximum skb size to fit within a single page. Later
code uses the device MTU, if available, to determine whether the skb
has sufficient room for another field. On interfaces with MTUs larger
than the page size, less the skb overhead, this can result in the skb
being overrun and a skb_over_panic being generated.
Fix MLD in the same way IGMPv3 was fixed in the commit 57e1ab6e
("igmp: refine skb allocations"), by storing the requested packet size
into skb->cb[0] and using that instead of the device MTU.
Signed-off-by: Travis Brown <travisb@aristanetworks.com>
---
net/ipv6/mcast.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index d18f9f9..3c6cbc3 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1522,6 +1522,7 @@ static void ip6_mc_hdr(struct sock *sk, struct sk_buff *skb,
hdr->daddr = *daddr;
}
+#define mld_skb_size(skb) (*(unsigned int *)((skb)->cb))
static struct sk_buff *mld_newpack(struct inet6_dev *idev, int size)
{
struct net_device *dev = idev->dev;
@@ -1531,6 +1532,7 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, int size)
struct mld2_report *pmr;
struct in6_addr addr_buf;
const struct in6_addr *saddr;
+ int skb_size;
int hlen = LL_RESERVED_SPACE(dev);
int tlen = dev->needed_tailroom;
int err;
@@ -1539,14 +1541,16 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, int size)
IPV6_TLV_PADN, 0 };
/* we assume size > sizeof(ra) here */
- size += hlen + tlen;
+ skb_size = size + hlen + tlen;
/* limit our allocations to order-0 page */
- size = min_t(int, size, SKB_MAX_ORDER(0, 0));
- skb = sock_alloc_send_skb(sk, size, 1, &err);
+ skb_size = min_t(int, skb_size, SKB_MAX_ORDER(0, 0));
+ skb = sock_alloc_send_skb(sk, skb_size, 1, &err);
if (!skb)
return NULL;
+ mld_skb_size(skb) = size;
+
skb->priority = TC_PRIO_CONTROL;
skb_reserve(skb, hlen);
@@ -1661,7 +1665,7 @@ static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc,
return skb;
}
-#define AVAILABLE(skb) ((skb) ? ((skb)->dev ? (skb)->dev->mtu - (skb)->len : \
+#define AVAILABLE(skb) ((skb) ? ((skb)->dev ? mld_skb_size(skb) - (skb)->len : \
skb_tailroom(skb)) : 0)
static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
--
1.7.4.4
next reply other threads:[~2013-12-21 1:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-21 1:00 Travis Brown [this message]
2013-12-21 1:24 ` [PATCH] ipv6: mld: Prevent skb_over_panic with large MTUs Eric Dumazet
2013-12-22 3:21 ` 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=1387587610-31723-1-git-send-email-travisb@aristanetworks.com \
--to=travisb@aristanetworks.com \
--cc=davem@davemloft.net \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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