diff options
author | Willem de Bruijn <willemb@google.com> | 2018-01-19 09:29:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-22 16:01:30 -0500 |
commit | 121d57af308d0cf943f08f4738d24d3966c38cd9 (patch) | |
tree | 6089dfcad08b4d02fe8e8082f2d278a5cbec05a3 | |
parent | 7c68d1a6b4db9012790af7ac0f0fdc0d2083422a (diff) |
gso: validate gso_type in GSO handlers
Validate gso_type during segmentation as SKB_GSO_DODGY sources
may pass packets where the gso_type does not match the contents.
Syzkaller was able to enter the SCTP gso handler with a packet of
gso_type SKB_GSO_TCPV4.
On entry of transport layer gso handlers, verify that the gso_type
matches the transport protocol.
Fixes: 90017accff61 ("sctp: Add GSO support")
Link: http://lkml.kernel.org/r/<001a1137452496ffc305617e5fe0@google.com>
Reported-by: syzbot+fee64147a25aecd48055@syzkaller.appspotmail.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/esp4_offload.c | 3 | ||||
-rw-r--r-- | net/ipv4/tcp_offload.c | 3 | ||||
-rw-r--r-- | net/ipv4/udp_offload.c | 3 | ||||
-rw-r--r-- | net/ipv6/esp6_offload.c | 3 | ||||
-rw-r--r-- | net/ipv6/tcpv6_offload.c | 3 | ||||
-rw-r--r-- | net/ipv6/udp_offload.c | 3 | ||||
-rw-r--r-- | net/sctp/offload.c | 3 |
7 files changed, 21 insertions, 0 deletions
diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c index b1338e576d00..29b333a62ab0 100644 --- a/net/ipv4/esp4_offload.c +++ b/net/ipv4/esp4_offload.c | |||
@@ -122,6 +122,9 @@ static struct sk_buff *esp4_gso_segment(struct sk_buff *skb, | |||
122 | if (!xo) | 122 | if (!xo) |
123 | goto out; | 123 | goto out; |
124 | 124 | ||
125 | if (!(skb_shinfo(skb)->gso_type & SKB_GSO_ESP)) | ||
126 | goto out; | ||
127 | |||
125 | seq = xo->seq.low; | 128 | seq = xo->seq.low; |
126 | 129 | ||
127 | x = skb->sp->xvec[skb->sp->len - 1]; | 130 | x = skb->sp->xvec[skb->sp->len - 1]; |
diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index b6a2aa1dcf56..4d58e2ce0b5b 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c | |||
@@ -32,6 +32,9 @@ static void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq, | |||
32 | static struct sk_buff *tcp4_gso_segment(struct sk_buff *skb, | 32 | static struct sk_buff *tcp4_gso_segment(struct sk_buff *skb, |
33 | netdev_features_t features) | 33 | netdev_features_t features) |
34 | { | 34 | { |
35 | if (!(skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)) | ||
36 | return ERR_PTR(-EINVAL); | ||
37 | |||
35 | if (!pskb_may_pull(skb, sizeof(struct tcphdr))) | 38 | if (!pskb_may_pull(skb, sizeof(struct tcphdr))) |
36 | return ERR_PTR(-EINVAL); | 39 | return ERR_PTR(-EINVAL); |
37 | 40 | ||
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index 01801b77bd0d..ea6e6e7df0ee 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c | |||
@@ -203,6 +203,9 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, | |||
203 | goto out; | 203 | goto out; |
204 | } | 204 | } |
205 | 205 | ||
206 | if (!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP)) | ||
207 | goto out; | ||
208 | |||
206 | if (!pskb_may_pull(skb, sizeof(struct udphdr))) | 209 | if (!pskb_may_pull(skb, sizeof(struct udphdr))) |
207 | goto out; | 210 | goto out; |
208 | 211 | ||
diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c index dd9627490c7c..f52c314d4c97 100644 --- a/net/ipv6/esp6_offload.c +++ b/net/ipv6/esp6_offload.c | |||
@@ -149,6 +149,9 @@ static struct sk_buff *esp6_gso_segment(struct sk_buff *skb, | |||
149 | if (!xo) | 149 | if (!xo) |
150 | goto out; | 150 | goto out; |
151 | 151 | ||
152 | if (!(skb_shinfo(skb)->gso_type & SKB_GSO_ESP)) | ||
153 | goto out; | ||
154 | |||
152 | seq = xo->seq.low; | 155 | seq = xo->seq.low; |
153 | 156 | ||
154 | x = skb->sp->xvec[skb->sp->len - 1]; | 157 | x = skb->sp->xvec[skb->sp->len - 1]; |
diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c index d883c9204c01..278e49cd67d4 100644 --- a/net/ipv6/tcpv6_offload.c +++ b/net/ipv6/tcpv6_offload.c | |||
@@ -46,6 +46,9 @@ static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb, | |||
46 | { | 46 | { |
47 | struct tcphdr *th; | 47 | struct tcphdr *th; |
48 | 48 | ||
49 | if (!(skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)) | ||
50 | return ERR_PTR(-EINVAL); | ||
51 | |||
49 | if (!pskb_may_pull(skb, sizeof(*th))) | 52 | if (!pskb_may_pull(skb, sizeof(*th))) |
50 | return ERR_PTR(-EINVAL); | 53 | return ERR_PTR(-EINVAL); |
51 | 54 | ||
diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c index a0f89ad76f9d..2a04dc9c781b 100644 --- a/net/ipv6/udp_offload.c +++ b/net/ipv6/udp_offload.c | |||
@@ -42,6 +42,9 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, | |||
42 | const struct ipv6hdr *ipv6h; | 42 | const struct ipv6hdr *ipv6h; |
43 | struct udphdr *uh; | 43 | struct udphdr *uh; |
44 | 44 | ||
45 | if (!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP)) | ||
46 | goto out; | ||
47 | |||
45 | if (!pskb_may_pull(skb, sizeof(struct udphdr))) | 48 | if (!pskb_may_pull(skb, sizeof(struct udphdr))) |
46 | goto out; | 49 | goto out; |
47 | 50 | ||
diff --git a/net/sctp/offload.c b/net/sctp/offload.c index 275925b93b29..35bc7106d182 100644 --- a/net/sctp/offload.c +++ b/net/sctp/offload.c | |||
@@ -45,6 +45,9 @@ static struct sk_buff *sctp_gso_segment(struct sk_buff *skb, | |||
45 | struct sk_buff *segs = ERR_PTR(-EINVAL); | 45 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
46 | struct sctphdr *sh; | 46 | struct sctphdr *sh; |
47 | 47 | ||
48 | if (!(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP)) | ||
49 | goto out; | ||
50 | |||
48 | sh = sctp_hdr(skb); | 51 | sh = sctp_hdr(skb); |
49 | if (!pskb_may_pull(skb, sizeof(*sh))) | 52 | if (!pskb_may_pull(skb, sizeof(*sh))) |
50 | goto out; | 53 | goto out; |