]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: add more sanity checks to qdisc_pkt_len_init()
authorEric Dumazet <edumazet@google.com>
Tue, 24 Sep 2024 15:02:57 +0000 (15:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:11:21 +0000 (15:11 +0200)
commit2415f465730e48b6e38da1c7c097317bf5dd2d20
tree871bf254f3d7ef393c711642032b2f4f121500a2
parent939c88cbdc668dadd8cfa7a35d9066331239041c
net: add more sanity checks to qdisc_pkt_len_init()

[ Upstream commit ab9a9a9e9647392a19e7a885b08000e89c86b535 ]

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: 1def9238d4aa ("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>
net/core/dev.c