]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
gso: validate gso_type in GSO handlers
authorWillem de Bruijn <willemb@google.com>
Fri, 19 Jan 2018 14:29:18 +0000 (09:29 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Jan 2018 21:01:30 +0000 (16:01 -0500)
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>
net/ipv4/esp4_offload.c
net/ipv4/tcp_offload.c
net/ipv4/udp_offload.c
net/ipv6/esp6_offload.c
net/ipv6/tcpv6_offload.c
net/ipv6/udp_offload.c
net/sctp/offload.c

index b1338e576d00389db8b6ce2383550e9aa22a4399..29b333a62ab01d606301ae45a7ec5f198cf1a5a0 100644 (file)
@@ -122,6 +122,9 @@ static struct sk_buff *esp4_gso_segment(struct sk_buff *skb,
        if (!xo)
                goto out;
 
+       if (!(skb_shinfo(skb)->gso_type & SKB_GSO_ESP))
+               goto out;
+
        seq = xo->seq.low;
 
        x = skb->sp->xvec[skb->sp->len - 1];
index b6a2aa1dcf56cbaa029b0ec6c5e512e33c90fff9..4d58e2ce0b5b181b39aeb12f8761ba016606dd43 100644 (file)
@@ -32,6 +32,9 @@ static void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq,
 static struct sk_buff *tcp4_gso_segment(struct sk_buff *skb,
                                        netdev_features_t features)
 {
+       if (!(skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4))
+               return ERR_PTR(-EINVAL);
+
        if (!pskb_may_pull(skb, sizeof(struct tcphdr)))
                return ERR_PTR(-EINVAL);
 
index 01801b77bd0da45764fd0e9a80f22b0e46633934..ea6e6e7df0eec8e79f631851846cf6957014c162 100644 (file)
@@ -203,6 +203,9 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
                goto out;
        }
 
+       if (!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP))
+               goto out;
+
        if (!pskb_may_pull(skb, sizeof(struct udphdr)))
                goto out;
 
index dd9627490c7ca22bda9fe3cca13b72c60f6865de..f52c314d4c97086fba003709f506ec7e408baba8 100644 (file)
@@ -149,6 +149,9 @@ static struct sk_buff *esp6_gso_segment(struct sk_buff *skb,
        if (!xo)
                goto out;
 
+       if (!(skb_shinfo(skb)->gso_type & SKB_GSO_ESP))
+               goto out;
+
        seq = xo->seq.low;
 
        x = skb->sp->xvec[skb->sp->len - 1];
index d883c9204c01d525fcd51012c34afbf5f8af11ed..278e49cd67d4e2c7b0ab9138fabe84753d628b5a 100644 (file)
@@ -46,6 +46,9 @@ static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb,
 {
        struct tcphdr *th;
 
+       if (!(skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6))
+               return ERR_PTR(-EINVAL);
+
        if (!pskb_may_pull(skb, sizeof(*th)))
                return ERR_PTR(-EINVAL);
 
index a0f89ad76f9d2233b9e048418069aacd92ac6a25..2a04dc9c781b5f236fbe6dc3804f5eeed174ee44 100644 (file)
@@ -42,6 +42,9 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
                const struct ipv6hdr *ipv6h;
                struct udphdr *uh;
 
+               if (!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP))
+                       goto out;
+
                if (!pskb_may_pull(skb, sizeof(struct udphdr)))
                        goto out;
 
index 275925b93b2909a32e9a5ab83a16e9b0f5717e24..35bc7106d1827a80f1135fe4797bec36cb7c669a 100644 (file)
@@ -45,6 +45,9 @@ static struct sk_buff *sctp_gso_segment(struct sk_buff *skb,
        struct sk_buff *segs = ERR_PTR(-EINVAL);
        struct sctphdr *sh;
 
+       if (!(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP))
+               goto out;
+
        sh = sctp_hdr(skb);
        if (!pskb_may_pull(skb, sizeof(*sh)))
                goto out;