Skip to content

Commit 23e19f2

Browse files
author
Paolo Abeni
committed
Merge branch 'net-two-fixes-for-qdisc_pkt_len_init'
Eric Dumazet says: ==================== net: two fixes for qdisc_pkt_len_init() Inspired by one syzbot report. At least one qdisc (fq_codel) depends on qdisc_skb_cb(skb)->pkt_len having a sane value (not zero) With the help of af_packet, syzbot was able to fool qdisc_pkt_len_init() to precisely set qdisc_skb_cb(skb)->pkt_len to zero. First patch fixes this issue. Second one (a separate one to help future bisections) adds more sanity check to SKB_GSO_DODGY users. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents e9d591b + ab9a9a9 commit 23e19f2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

net/core/dev.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -3758,18 +3758,22 @@ static void qdisc_pkt_len_init(struct sk_buff *skb)
37583758
sizeof(_tcphdr), &_tcphdr);
37593759
if (likely(th))
37603760
hdr_len += __tcp_hdrlen(th);
3761-
} else {
3761+
} else if (shinfo->gso_type & SKB_GSO_UDP_L4) {
37623762
struct udphdr _udphdr;
37633763

37643764
if (skb_header_pointer(skb, hdr_len,
37653765
sizeof(_udphdr), &_udphdr))
37663766
hdr_len += sizeof(struct udphdr);
37673767
}
37683768

3769-
if (shinfo->gso_type & SKB_GSO_DODGY)
3770-
gso_segs = DIV_ROUND_UP(skb->len - hdr_len,
3771-
shinfo->gso_size);
3769+
if (unlikely(shinfo->gso_type & SKB_GSO_DODGY)) {
3770+
int payload = skb->len - hdr_len;
37723771

3772+
/* Malicious packet. */
3773+
if (payload <= 0)
3774+
return;
3775+
gso_segs = DIV_ROUND_UP(payload, shinfo->gso_size);
3776+
}
37733777
qdisc_skb_cb(skb)->pkt_len += (gso_segs - 1) * hdr_len;
37743778
}
37753779
}

0 commit comments

Comments
 (0)