Netdev List
 help / color / mirror / Atom feed
* [PATCH] ipv6: mld: Prevent skb_over_panic with large MTUs
@ 2013-12-21  1:00 Travis Brown
  2013-12-21  1:24 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Travis Brown @ 2013-12-21  1:00 UTC (permalink / raw)
  To: netdev, travisb; +Cc: davem, kuznet, jmorris, yoshfuji, kaber

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-12-22  3:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-21  1:00 [PATCH] ipv6: mld: Prevent skb_over_panic with large MTUs Travis Brown
2013-12-21  1:24 ` Eric Dumazet
2013-12-22  3:21   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox