mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-06 17:35:20 +02:00
net: add more sanity checks to qdisc_pkt_len_init()
[ Upstream commitab9a9a9e96
] One path takes care of SKB_GSO_DODGY, assuming skb->len is bigger than hdr_len. virtio_net_hdr_to_skb() does not fully dissect TCP headers, it only make sure it is at least 20 bytes. It is possible for an user to provide a malicious 'GSO' packet, total length of 80 bytes. - 20 bytes of IPv4 header - 60 bytes TCP header - a small gso_size like 8 virtio_net_hdr_to_skb() would declare this packet as a normal GSO packet, because it would see 40 bytes of payload, bigger than gso_size. We need to make detect this case to not underflow qdisc_skb_cb(skb)->pkt_len. Fixes:1def9238d4
("net_sched: more precise pkt_len computation") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
25ab0b87db
commit
9b0ee571d2
|
@ -3754,10 +3754,14 @@ static void qdisc_pkt_len_init(struct sk_buff *skb)
|
||||||
hdr_len += sizeof(struct udphdr);
|
hdr_len += sizeof(struct udphdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shinfo->gso_type & SKB_GSO_DODGY)
|
if (unlikely(shinfo->gso_type & SKB_GSO_DODGY)) {
|
||||||
gso_segs = DIV_ROUND_UP(skb->len - hdr_len,
|
int payload = skb->len - hdr_len;
|
||||||
shinfo->gso_size);
|
|
||||||
|
|
||||||
|
/* Malicious packet. */
|
||||||
|
if (payload <= 0)
|
||||||
|
return;
|
||||||
|
gso_segs = DIV_ROUND_UP(payload, shinfo->gso_size);
|
||||||
|
}
|
||||||
qdisc_skb_cb(skb)->pkt_len += (gso_segs - 1) * hdr_len;
|
qdisc_skb_cb(skb)->pkt_len += (gso_segs - 1) * hdr_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user