lkml.org 
[lkml]   [2018]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 52/66] gso: validate gso_type in GSO handlers
    Date
    4.9-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Willem de Bruijn <willemb@google.com>


    [ Upstream commit 121d57af308d0cf943f08f4738d24d3966c38cd9 ]

    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>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    net/ipv4/tcp_offload.c | 3 +++
    net/ipv4/udp_offload.c | 3 +++
    net/ipv6/tcpv6_offload.c | 3 +++
    net/ipv6/udp_offload.c | 3 +++
    net/sctp/offload.c | 3 +++
    5 files changed, 15 insertions(+)

    --- a/net/ipv4/tcp_offload.c
    +++ b/net/ipv4/tcp_offload.c
    @@ -32,6 +32,9 @@ static void tcp_gso_tstamp(struct sk_buf
    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);

    --- a/net/ipv4/udp_offload.c
    +++ b/net/ipv4/udp_offload.c
    @@ -205,6 +205,9 @@ static struct sk_buff *udp4_ufo_fragment
    goto out;
    }

    + if (!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP))
    + goto out;
    +
    if (!pskb_may_pull(skb, sizeof(struct udphdr)))
    goto out;

    --- a/net/ipv6/tcpv6_offload.c
    +++ b/net/ipv6/tcpv6_offload.c
    @@ -46,6 +46,9 @@ static struct sk_buff *tcp6_gso_segment(
    {
    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);

    --- a/net/ipv6/udp_offload.c
    +++ b/net/ipv6/udp_offload.c
    @@ -55,6 +55,9 @@ static struct sk_buff *udp6_ufo_fragment
    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;

    --- a/net/sctp/offload.c
    +++ b/net/sctp/offload.c
    @@ -44,6 +44,9 @@ static struct sk_buff *sctp_gso_segment(
    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;

    \
     
     \ /
      Last update: 2018-01-29 21:35    [W:4.051 / U:0.240 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site