In the Linux kernel, the following vulnerability has been resolved: net: always dissect GSO packets in __virtio_net_hdr_to_skb() Commit 9e8db5913264 ("net: avoid false positives in untrusted gso validation") added a '&& skb->network_header' check before flow-dissecting GSO packets without VIRTIO_NET_HDR_F_NEEDS_CSUM in __virtio_net_hdr_to_skb(), because some callers (such as tun_get_user(), tun_xdp_one(), virtnet_receive_done(), and raw_verify_header()) called virtio_net_hdr_*_to_skb() before initializing skb->network_header and skb->dev. Поскольку __alloc_skb() и __build_skb_around() инициализируют skb->network_header до 0 (в отличие от mac_header и transport_header, которые инициализируются до 0U), эти четыре абонента всегда имели skb->network_header 0 и обходили рассечение потока в __virtio_net_hdr_to_skb(). В целом, skb->network_header является смещением от skb->head (где 0 также является действительным смещением, когда skb_headroom(skb) равен 0), а не булевым флагом.
Всякий раз, когда ветка 'if (gso_type skb->network_header)' пропускалась, резервная версия 'else if (gso_type)' вытягивала только nh_min_len + thlen (40 байт для TCPv4) без вскрытия пакета, без проверки ip_proto или n_proto и без установки skb->transport_header. Если пакет имеет деформированный сетевой заголовок, он не отклоняется, и последующий skb_probe_transport_header () также терпит неудачу, оставляя skb->transport_header на уровне 0U (0xffff). Аналогичным образом, если пакет IPv4 содержит опции IP (ihl > 5) или пакет IPv6 содержит заголовки расширений, только nh_min_len + thlen может оставить заголовок TCP за пределами skb->head.
В обоих случаях, tcp_hdrlen(skb) в skb_gso_transport_seglen() читает out-of-bounds: BUG: KASAN: slab-out-of-bounds в skb_gso_transport_seglen Read размера 2 по задаче poc/133 skb_gso_transport_seglen (net/core/gso.c:155) skb_gso_validate_mac_len (net/core/gso.c:270) tbf_enqueue (net/sched/sch_tbf.c:260) dev_qdisc_enqueue (net/core/dev.c:4227) __dev_queue_xmit (net/core/dev.c:4884) In добавления, проверяя virtio_net_hdr_match_proto() только внутри 'если (!skb->protocol)' перед рассечением потока оба пропускали проверку, когда skb->protocol был предварительно установлен абонентом и отклонил VLAN-меченые кадры, чей внешний L2 протокол ETH_P_8021Q или ETH_P_8021AD. Исправьте это: 1. Инициализация skb->dev и skb->network_header (плюс skb->protocol for IFF_TUN) перед virtio_net_hdr_*_to_skb() в tun_get_user(), tun_xdp_one(), virtnet_receive_done(), и raw_verify_header().
В tun_get_user() уберите избыточный skb_reset_mac_header(skb) в случае IFF_TUN, так как __virtio_net_hdr_to_skb() безоговорочно сбрасывает mac_header. 2. Удаление ' skb->network_header' и неподтвержденного запасного варианта 'else if if (gso_type)' в __virtio_net_hdr_to_skb(), так что все пакеты GSO без VIRTIO_NET_HDR_F_NEEDS_CSUM разделены на потоки, их транспортный заголовок втянут в линейные данные и установлен skb->transport_header. 3. Перемещение проверки virtio_net_hdr_match_proto () после skb_flow_dissect_flow_keys_basic (), проверка keys.basic.n_proto против hdr_gso_type.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: net: always dissect GSO packets in __virtio_net_hdr_to_skb() Commit 9e8db5913264 ("net: avoid false positives in untrusted gso validation") added a '&& skb->network_header' check before flow-dissecting GSO packets without VIRTIO_NET_HDR_F_NEEDS_CSUM in __virtio_net_hdr_to_skb(), because some callers (such as tun_get_user(), tun_xdp_one(), virtnet_receive_done(), and raw_verify_header()) called virtio_net_hdr_*_to_skb() before initializing skb->network_header and skb->dev. Because __alloc_skb() and __build_skb_around() zero-initialize skb->network_header to 0 (unlike mac_header and transport_header which are initialized to ~0U), those four callers always had skb->network_header == 0 and bypassed flow dissection in __virtio_net_hdr_to_skb(). More generally, skb->network_header is an offset from skb->head (where 0 is also a valid offset whenever skb_headroom(skb) is 0), not a boolean flag. Whenever the 'if (gso_type && skb->network_header)' branch was skipped, the fallback 'else if (gso_type)' only pulled nh_min_len + thlen (40 bytes for TCPv4) without dissecting the packet, without validating ip_proto or n_proto, and without setting skb->transport_header. If the packet has a malformed network header, it is not rejected and a subsequent skb_probe_transport_header() also fails, leaving skb->transport_header at ~0U (0xffff). Similarly, if an IPv4 packet carries IP options (ihl > 5) or an IPv6 packet carries extension headers, pulling only nh_min_len + thlen can leave the TCP header outside skb->head. In both cases, tcp_hdrlen(skb) in skb_gso_transport_seglen() reads out-of-bounds: BUG: KASAN: slab-out-of-bounds in skb_gso_transport_seglen Read of size 2 by task poc/133 skb_gso_transport_seglen (net/core/gso.c:155) skb_gso_validate_mac_len (net/core/gso.c:270) tbf_enqueue (net/sched/sch_tbf.c:260) dev_qdisc_enqueue (net/core/dev.c:4227) __dev_queue_xmit (net/core/dev.c:4884) In addition, checking virtio_net_hdr_match_proto() only inside 'if (!skb->protocol)' before flow dissection both skipped validation when skb->protocol was pre-set by the caller and rejected VLAN-tagged frames whose outer L2 protocol is ETH_P_8021Q or ETH_P_8021AD. Fix this by: 1. Initializing skb->dev and skb->network_header (plus skb->protocol for IFF_TUN) before virtio_net_hdr_*_to_skb() in tun_get_user(), tun_xdp_one(), virtnet_receive_done(), and raw_verify_header(). In tun_get_user(), drop the redundant skb_reset_mac_header(skb) in the IFF_TUN case since __virtio_net_hdr_to_skb() unconditionally resets mac_header. 2. Removing '&& skb->network_header' and the unvalidated 'else if (gso_type)' fallback in __virtio_net_hdr_to_skb() so all GSO packets without VIRTIO_NET_HDR_F_NEEDS_CSUM are flow-dissected, have their transport header pulled into linear data, and have skb->transport_header set. 3. Moving the virtio_net_hdr_match_proto() check to after skb_flow_dissect_flow_keys_basic(), validating keys.basic.n_proto against hdr_gso_type.
Уязвимые продукты 10
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.0
|
7.2.11
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.0
|
7.3
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.14.104
|
— |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.19.26
|
— |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.20.13
|
— |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.14.104
|
— |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.19.26
|
— |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.20.13
|
— |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.14.226
|
— |
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
4.19.181
|
— |