mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-30 01:46:30 -05:00
98 lines
3.2 KiB
Diff
98 lines
3.2 KiB
Diff
From f7c2d2d7ebf9a110cafbe53199457c318f61a192 Mon Sep 17 00:00:00 2001
|
|
From: "David S. Miller" <davem@davemloft.net>
|
|
Date: Wed, 17 May 2017 22:54:11 -0400
|
|
Subject: ipv6: Check ip6_find_1stfragopt() return value properly.
|
|
|
|
commit 7dd7eb9513bd02184d45f000ab69d78cb1fa1531 upstream.
|
|
|
|
Do not use unsigned variables to see if it returns a negative
|
|
error or not.
|
|
|
|
Fixes: 2423496af35d ("ipv6: Prevent overrun when parsing v6 header options")
|
|
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
[bwh: Backported to 3.2: adjust filenames, context]
|
|
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
|
|
---
|
|
net/ipv6/af_inet6.c | 9 ++++-----
|
|
net/ipv6/ip6_output.c | 7 +++----
|
|
net/ipv6/udp.c | 8 +++++---
|
|
3 files changed, 12 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
|
|
index 914c7d5..b0e4fb8 100644
|
|
--- a/net/ipv6/af_inet6.c
|
|
+++ b/net/ipv6/af_inet6.c
|
|
@@ -785,7 +785,6 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, u32 features)
|
|
const struct inet6_protocol *ops;
|
|
int proto;
|
|
struct frag_hdr *fptr;
|
|
- unsigned int unfrag_ip6hlen;
|
|
u8 *prevhdr;
|
|
int offset = 0;
|
|
|
|
@@ -824,11 +823,11 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, u32 features)
|
|
ipv6h->payload_len = htons(skb->len - skb->mac_len -
|
|
sizeof(*ipv6h));
|
|
if (proto == IPPROTO_UDP) {
|
|
- unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr);
|
|
- if (unfrag_ip6hlen < 0)
|
|
- return ERR_PTR(unfrag_ip6hlen);
|
|
+ int err = ip6_find_1stfragopt(skb, &prevhdr);
|
|
+ if (err < 0)
|
|
+ return ERR_PTR(err);
|
|
fptr = (struct frag_hdr *)(skb_network_header(skb) +
|
|
- unfrag_ip6hlen);
|
|
+ err);
|
|
fptr->frag_off = htons(offset);
|
|
if (skb->next != NULL)
|
|
fptr->frag_off |= htons(IP6_MF);
|
|
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
|
|
index dd31060..81a7803 100644
|
|
--- a/net/ipv6/ip6_output.c
|
|
+++ b/net/ipv6/ip6_output.c
|
|
@@ -631,11 +631,10 @@ int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
|
|
u8 *prevhdr, nexthdr = 0;
|
|
struct net *net = dev_net(skb_dst(skb)->dev);
|
|
|
|
- hlen = ip6_find_1stfragopt(skb, &prevhdr);
|
|
- if (hlen < 0) {
|
|
- err = hlen;
|
|
+ err = ip6_find_1stfragopt(skb, &prevhdr);
|
|
+ if (err < 0)
|
|
goto fail;
|
|
- }
|
|
+ hlen = err;
|
|
nexthdr = *prevhdr;
|
|
|
|
mtu = ip6_skb_dst_mtu(skb);
|
|
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
|
|
index 8157ae0..5f0d519 100644
|
|
--- a/net/ipv6/udp.c
|
|
+++ b/net/ipv6/udp.c
|
|
@@ -1316,6 +1316,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, u32 features)
|
|
u8 frag_hdr_sz = sizeof(struct frag_hdr);
|
|
int offset;
|
|
__wsum csum;
|
|
+ int err;
|
|
|
|
mss = skb_shinfo(skb)->gso_size;
|
|
if (unlikely(skb->len <= mss))
|
|
@@ -1352,9 +1353,10 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, u32 features)
|
|
/* Find the unfragmentable header and shift it left by frag_hdr_sz
|
|
* bytes to insert fragment header.
|
|
*/
|
|
- unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr);
|
|
- if (unfrag_ip6hlen < 0)
|
|
- return ERR_PTR(unfrag_ip6hlen);
|
|
+ err = ip6_find_1stfragopt(skb, &prevhdr);
|
|
+ if (err < 0)
|
|
+ return ERR_PTR(err);
|
|
+ unfrag_ip6hlen = err;
|
|
nexthdr = *prevhdr;
|
|
*prevhdr = NEXTHDR_FRAGMENT;
|
|
unfrag_len = skb_network_header(skb) - skb_mac_header(skb) +
|
|
--
|
|
cgit v1.1
|
|
|