Skip to content

Commit a44d911

Browse files
edumazetgregkh
authored andcommitted
net: qdisc_pkt_len_init() should be more robust
[ Upstream commit 7c68d1a ] 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 d0c081b ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0ae1696 commit a44d911

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

net/core/dev.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3083,10 +3083,21 @@ static void qdisc_pkt_len_init(struct sk_buff *skb)
30833083
hdr_len = skb_transport_header(skb) - skb_mac_header(skb);
30843084

30853085
/* + transport layer */
3086-
if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
3087-
hdr_len += tcp_hdrlen(skb);
3088-
else
3089-
hdr_len += sizeof(struct udphdr);
3086+
if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) {
3087+
const struct tcphdr *th;
3088+
struct tcphdr _tcphdr;
3089+
3090+
th = skb_header_pointer(skb, skb_transport_offset(skb),
3091+
sizeof(_tcphdr), &_tcphdr);
3092+
if (likely(th))
3093+
hdr_len += __tcp_hdrlen(th);
3094+
} else {
3095+
struct udphdr _udphdr;
3096+
3097+
if (skb_header_pointer(skb, skb_transport_offset(skb),
3098+
sizeof(_udphdr), &_udphdr))
3099+
hdr_len += sizeof(struct udphdr);
3100+
}
30903101

30913102
if (shinfo->gso_type & SKB_GSO_DODGY)
30923103
gso_segs = DIV_ROUND_UP(skb->len - hdr_len,

0 commit comments

Comments
 (0)