Commit f709f7b2 authored by Willem de Bruijn's avatar Willem de Bruijn Committed by Greg Kroah-Hartman

net: validate untrusted gso packets without csum offload

commit d5be7f63 upstream.

Syzkaller again found a path to a kernel crash through bad gso input.
By building an excessively large packet to cause an skb field to wrap.

If VIRTIO_NET_HDR_F_NEEDS_CSUM was set this would have been dropped in

GSO packets that do not set checksum offload are suspicious and rare.
Most callers of virtio_net_hdr_to_skb already pass them to

Move that test forward, change it to detect parse failure and drop
packets on failure as those cleary are not one of the legitimate

Fixes: bfd5f4a3 ("packet: Add GSO/csum offload support.")
Fixes: f43798c2 ("tun: Allow GSO using virtio_net_hdr")
Reported-by: default avatarsyzbot <[email protected]>
Signed-off-by: default avatarWillem de Bruijn <[email protected]>
Reviewed-by: default avatarEric Dumazet <[email protected].com>
Signed-off-by: default avatarDavid S. Miller <[email protected]>
Signed-off-by: default avatarGreg Kroah-Hartman <[email protected]>
parent df33b662
......@@ -2418,7 +2418,7 @@ static inline void skb_probe_transport_header(struct sk_buff *skb,
if (skb_flow_dissect_flow_keys_basic(skb, &keys, NULL, 0, 0, 0, 0))
skb_set_transport_header(skb, keys.control.thoff);
else if (offset_hint >= 0)
skb_set_transport_header(skb, offset_hint);
......@@ -57,6 +57,15 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
if (!skb_partial_csum_set(skb, start, off))
return -EINVAL;
} else {
/* gso packets without NEEDS_CSUM do not set transport_offset.
* probe and drop if does not match one of the above types.
if (gso_type) {
skb_probe_transport_header(skb, -1);
if (!skb_transport_header_was_set(skb))
return -EINVAL;
if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment