Skip to content

Commit 15aaf7e

Browse files
Jason Wanggregkh
authored andcommitted
net_sched: better precise estimation on packet length for untrusted packets
[ Upstream commit 15e5a03 ] gso_segs were reset to zero when kernel receive packets from untrusted source. But we use this zero value to estimate precise packet len which is wrong. So this patch tries to estimate the correct gso_segs value before using it in qdisc_pkt_len_init(). Signed-off-by: Jason Wang <jasowang@redhat.com> Cc: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent acc196c commit 15aaf7e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎net/core/dev.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2592,6 +2592,7 @@ static void qdisc_pkt_len_init(struct sk_buff *skb)
25922592
*/
25932593
if (shinfo->gso_size) {
25942594
unsigned int hdr_len;
2595+
u16 gso_segs = shinfo->gso_segs;
25952596

25962597
/* mac layer + network layer */
25972598
hdr_len = skb_transport_header(skb) - skb_mac_header(skb);
@@ -2601,7 +2602,12 @@ static void qdisc_pkt_len_init(struct sk_buff *skb)
26012602
hdr_len += tcp_hdrlen(skb);
26022603
else
26032604
hdr_len += sizeof(struct udphdr);
2604-
qdisc_skb_cb(skb)->pkt_len += (shinfo->gso_segs - 1) * hdr_len;
2605+
2606+
if (shinfo->gso_type & SKB_GSO_DODGY)
2607+
gso_segs = DIV_ROUND_UP(skb->len - hdr_len,
2608+
shinfo->gso_size);
2609+
2610+
qdisc_skb_cb(skb)->pkt_len += (gso_segs - 1) * hdr_len;
26052611
}
26062612
}
26072613

0 commit comments

Comments
 (0)