lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAF=yD-KJ7htYqLz-HDKiW_p0W2xQww4oe6W9iE+J4nd0dAiPpw@mail.gmail.com>
Date:   Thu, 18 Jan 2018 16:17:02 -0500
From:   Willem de Bruijn <willemdebruijn.kernel@...il.com>
To:     Jason Wang <jasowang@...hat.com>
Cc:     Network Development <netdev@...r.kernel.org>,
        David Miller <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Willem de Bruijn <willemb@...gle.com>,
        Vlad Yasevic <vyasevic@...hat.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        Tom Herbert <tom@...bertland.com>
Subject: Re: [PATCH net] gso: validate gso_type if SKB_GSO_DODGY

On Thu, Jan 18, 2018 at 4:14 AM, Jason Wang <jasowang@...hat.com> wrote:
>
>
> On 2018年01月18日 14:04, Willem de Bruijn wrote:
>>
>> On Thu, Jan 18, 2018 at 12:20 AM, Willem de Bruijn
>> <willemdebruijn.kernel@...il.com> wrote:
>>>
>>> On Wed, Jan 17, 2018 at 10:48 PM, Jason Wang <jasowang@...hat.com> wrote:
>>>>
>>>>
>>>> On 2018年01月18日 07:11, Willem de Bruijn wrote:
>>>>>
>>>>> From: Willem de Bruijn<willemb@...gle.com>
>>>>>
>>>>> Validate gso_type of untrusted SKB_GSO_DODGY packets during
>>>>> segmentation.
>>>>>
>>>>> Untrusted user packets are limited to a small set of gso types in
>>>>> virtio_net_hdr_to_skb. But segmentation occurs on packet contents.
>>>>> Syzkaller was able to enter gso callbacks that are not hardened
>>>>> against untrusted user input.
>>>>>
>>>>> Fixes: f43798c27684 ("tun: Allow GSO using virtio_net_hdr")
>>>>
>>>>
>>>> This commit is suspicious, I guess it should be 5c7cdf339af5 ("gso:
>>>> Remove
>>>> arbitrary checks for unsupported GSO")
>>>
>>> The specific SCTP path was introduced with commit 90017accff61 ("sctp:
>>> add GSO support"). But the main issue that packets can be delivered to
>>> gso handlers different from their gso_type goes back further.
>>>
>>> The commit you reference is actually older than the sctp gso patch, so
>>> it makes sense that it did not have a check in the sctp_gso_segment.
>>>
>>> I still think that we should check in inet_gso_segment when we have
>>> the proto, instead of in each {tcp, sctp, udp, esp, ...} handler having
>>> a check of the form.
>>>
>>>        !(type & (SKB_GSO_TCPV4 |
>>>          SKB_GSO_TCPV6))))
>>
>> Unless we can create packets that legitimate combine
>> SKB_GSO_DODGY with tunnel headers.
>
>
> As you mentioned below, looks like we can e.g bridge between tunnels (vxlan,
> gre or others) and tap, or even bpf can produce this (e.g
> bpf_skb_adjust_room).
>
>>
>> virtio_net_hdr_to_skb does not accept tunneled gso types.
>
>
> Yes, Vlad is trying to extend virtio to support more kinds of gso types, so
> it will be supported for sure.
>
>>
>> But a tun device can be bridged with a gre tunnel in the
>> host, creating a path that will call gre_gso_segment.
>>
>> If that is possible, then this patch is indeed too strict and
>> we do need checks in the individual handlers.

Okay, I'm working on a patch that adds explicit checks

  @@ -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;
  +

to all transport layer gso offloads: {sctp, tcpv[46], ufov[46], espv[46]}. This
will block packets with gso_type X but protocol type Y from being parsed.
But does allow entering a tunnel protocol handler if that is different from Y,
unlike the above patch.

tunnels segmentation itself is protected by skb->encapsulation. Only tunnel
devices in the stack can set this field, not virtio_net_hdr_to_skb. Packets that
enter {gre, udp tunnel, ipxip4, ipxip6} without this bit are already dropped, so
no new checks are needed to these based on gso_type.

That leaves eth_proto callbacks. mpls had this check before commit 5c7cdf339af5
("gso: Remove arbitrary checks for unsupported GSO"):

         if (unlikely(skb_shinfo(skb)->gso_type &
                                 ~(SKB_GSO_TCPV4 |
                                   SKB_GSO_TCPV6 |
                                   SKB_GSO_UDP |
                                   SKB_GSO_DODGY |
                                   SKB_GSO_TCP_FIXEDID |
                                   SKB_GSO_TCP_ECN)))
                 goto out;

which appears to exclude only other tunnel types at the time, no
transport layers. I don't think we need any new check here, then: it
was robust against handling dodgy sources.

Aside from inet_gso_segment and ipv6_gso_segment, this only leaves the
new nsh_gso_segment. Unlke mpls, it has its own gso_type, so

        if (!skb_shinfo(skb)->gso_type & SKB_GSO_NSH)
                goto out;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ