Files
twx-linux/include/linux
Jonathan Davies 960b360ca7 net: virtio_net_hdr_to_skb: count transport header in UFO
[ Upstream commit cf9acc90c8 ]

virtio_net_hdr_to_skb does not set the skb's gso_size and gso_type
correctly for UFO packets received via virtio-net that are a little over
the GSO size. This can lead to problems elsewhere in the networking
stack, e.g. ovs_vport_send dropping over-sized packets if gso_size is
not set.

This is due to the comparison

  if (skb->len - p_off > gso_size)

not properly accounting for the transport layer header.

p_off includes the size of the transport layer header (thlen), so
skb->len - p_off is the size of the TCP/UDP payload.

gso_size is read from the virtio-net header. For UFO, fragmentation
happens at the IP level so does not need to include the UDP header.

Hence the calculation could be comparing a TCP/UDP payload length with
an IP payload length, causing legitimate virtio-net packets to have
lack gso_type/gso_size information.

Example: a UDP packet with payload size 1473 has IP payload size 1481.
If the guest used UFO, it is not fragmented and the virtio-net header's
flags indicate that it is a GSO frame (VIRTIO_NET_HDR_GSO_UDP), with
gso_size = 1480 for an MTU of 1500.  skb->len will be 1515 and p_off
will be 42, so skb->len - p_off = 1473.  Hence the comparison fails, and
shinfo->gso_size and gso_type are not set as they should be.

Instead, add the UDP header length before comparing to gso_size when
using UFO. In this way, it is the size of the IP payload that is
compared to gso_size.

Fixes: 6dd912f826 ("net: check untrusted gso_size at kernel entry")
Signed-off-by: Jonathan Davies <jonathan.davies@nutanix.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-26 11:36:22 +01:00
..
…
…
…
…
…
…
…
…
…
…
…
2021-04-14 08:22:36 +02:00
…
…
…
…
…
…
…
…
…
2018-05-26 09:16:44 +02:00
…
…
2012-10-08 13:50:20 +10:30
…
2018-06-15 18:10:01 -03:00
…
…
…
2011-03-11 14:25:50 +00:00
…
2018-05-09 17:25:13 +02:00
…
2018-06-15 18:10:01 -03:00
2018-06-19 10:06:29 -07:00
…
…
…
2018-03-26 15:09:38 +02:00
2018-08-22 10:52:48 -07:00
2017-08-24 13:23:03 -07:00
2012-02-20 19:46:36 +11:00
…
…
…
…
…
2012-10-16 18:49:15 -07:00
2018-01-01 12:40:27 -07:00
…
…
…
2019-11-24 08:19:14 +01:00
2017-08-07 17:22:14 +02:00
2014-12-31 13:06:50 -05:00
2018-07-12 10:04:29 -04:00
…
2017-11-13 01:41:20 +01:00
…
2021-01-30 13:32:13 +01:00
2018-07-27 09:57:23 +10:00
…
2021-01-30 13:32:12 +01:00
2018-06-28 20:32:51 +09:00
…
…
…
2010-02-09 11:13:56 +01:00
…
…
…
…
…
…
…
…
2018-03-26 08:53:43 -06:00
…
…
2021-05-22 10:59:50 +02:00
…
…
…
…
2018-06-22 13:43:27 +09:00
…
…
2014-03-13 12:11:00 +10:30
…
…
…
…
…
2019-12-13 08:52:43 +01:00
2021-03-04 09:39:44 +01:00
2018-04-11 10:28:38 -07:00
2015-07-28 08:50:42 +01:00
…
…
2021-02-07 14:48:38 +01:00
2018-07-12 21:35:28 +02:00
2021-11-26 11:35:57 +01:00
2017-12-01 13:09:40 -08:00
2018-04-12 09:41:19 -07:00
…
2017-08-28 20:51:22 +02:00
2018-06-07 17:34:35 -07:00
2018-04-11 10:28:32 -07:00
…
2019-12-31 16:35:38 +01:00
…
2021-07-11 12:49:26 +02:00
2020-07-29 10:16:52 +02:00
2018-06-07 17:34:39 -07:00
…
2018-03-26 13:14:43 -04:00
…
…
…
2021-06-30 08:48:18 -04:00
…
…
2018-08-22 10:52:45 -07:00
2018-01-28 22:17:24 -05:00
…
…
2018-01-08 08:22:45 -06:00
…
…
…
…
…
2021-09-03 09:58:00 +02:00
2018-01-31 17:18:37 -08:00
…
2017-11-09 10:23:28 +01:00
…
…
…
…
…
2020-03-18 07:14:17 +01:00
2017-11-17 16:10:04 -08:00
2018-07-21 10:43:12 -05:00
…
…
…
2017-12-16 02:05:48 +01:00
…
2019-06-11 12:20:52 +02:00
2018-07-20 01:11:45 +02:00
…
…
…
…
…
…
…
…
…
2017-11-07 12:22:21 +01:00
2018-06-29 08:48:06 -06:00
…
…
…
2020-04-02 15:28:22 +02:00
…
2009-04-08 14:33:38 -07:00
…
…
…
…
2018-07-07 17:25:23 +02:00
…
…
…
2018-08-16 12:14:42 -07:00
…
2018-01-15 12:07:46 -08:00
…
2013-04-30 15:50:12 +05:30
…
…
2018-06-20 11:35:56 +02:00
…
2018-02-06 18:32:47 -08:00
…
2018-11-13 11:08:51 -08:00
…
…
2015-10-01 09:57:59 -07:00
…
…
…
2020-12-11 13:25:01 +01:00
…
…
…
2018-02-06 18:32:44 -08:00
2017-12-20 09:53:54 -07:00
…
…
…
…
2020-04-02 15:28:23 +02:00
…
…
…
…
2017-08-15 09:02:07 -07:00
…
2013-10-17 15:53:09 -04:00
…
…
2017-08-15 09:02:08 -07:00