diff options
author | Eric Dumazet <edumazet@google.com> | 2018-01-18 22:59:19 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-22 16:00:05 -0500 |
commit | 7c68d1a6b4db9012790af7ac0f0fdc0d2083422a (patch) | |
tree | 080fa20981e54ee032dc59e2e80a925f9d7c4dd7 | |
parent | 18b0affaf40cf5f320258d28f7069dfff76da184 (diff) |
net: qdisc_pkt_len_init() should be more robust
Without proper validation of DODGY packets, we might very well
feed qdisc_pkt_len_init() with invalid GSO packets.
tcp_hdrlen() might access out-of-bound data, so let's use
skb_header_pointer() and proper checks.
Whole story is described in commit d0c081b49137 ("flow_dissector:
properly cap thoff field")
We have the goal of validating DODGY packets earlier in the stack,
so we might very well revert this fix in the future.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Cc: Jason Wang <jasowang@redhat.com>
Reported-by: syzbot+9da69ebac7dddd804552@syzkaller.appspotmail.com
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/dev.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 0e0ba36eeac9..613fb4066be7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -3151,10 +3151,21 @@ static void qdisc_pkt_len_init(struct sk_buff *skb) | |||
3151 | hdr_len = skb_transport_header(skb) - skb_mac_header(skb); | 3151 | hdr_len = skb_transport_header(skb) - skb_mac_header(skb); |
3152 | 3152 | ||
3153 | /* + transport layer */ | 3153 | /* + transport layer */ |
3154 | if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) | 3154 | if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) { |
3155 | hdr_len += tcp_hdrlen(skb); | 3155 | const struct tcphdr *th; |
3156 | else | 3156 | struct tcphdr _tcphdr; |
3157 | hdr_len += sizeof(struct udphdr); | 3157 | |
3158 | th = skb_header_pointer(skb, skb_transport_offset(skb), | ||
3159 | sizeof(_tcphdr), &_tcphdr); | ||
3160 | if (likely(th)) | ||
3161 | hdr_len += __tcp_hdrlen(th); | ||
3162 | } else { | ||
3163 | struct udphdr _udphdr; | ||
3164 | |||
3165 | if (skb_header_pointer(skb, skb_transport_offset(skb), | ||
3166 | sizeof(_udphdr), &_udphdr)) | ||
3167 | hdr_len += sizeof(struct udphdr); | ||
3168 | } | ||
3158 | 3169 | ||
3159 | if (shinfo->gso_type & SKB_GSO_DODGY) | 3170 | if (shinfo->gso_type & SKB_GSO_DODGY) |
3160 | gso_segs = DIV_ROUND_UP(skb->len - hdr_len, | 3171 | gso_segs = DIV_ROUND_UP(skb->len - hdr_len, |