Linux virtualization list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paulos Yibelo" <habte.yibelo@gmail.com>
Cc: "Eugenio Perez" <eperezma@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	virtualization@lists.linux.dev
Subject: Re: [PATCH net v4 1/2] net: validate virtio checksum start after network header
Date: Mon, 21 Sep 2026 00:47:54 +0000	[thread overview]
Message-ID: <20260921004754.DDA031F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260920004733.6473-2-habte.yibelo@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: virtio_net_hdr_to_skb security check bypassed for TUN devices
--

commit 1c7e0adac42db0550277cf456f6845d512993ef1
Author: Paulos Yibelo <habte.yibelo@gmail.com>

net: validate virtio checksum start after network header

__virtio_net_hdr_to_skb() rejects a CHECKSUM_PARTIAL start smaller than an
estimated minimum network-header length. The comparison currently uses the
offset from skb->data rather than the offset from skb_network_header().

> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> index c381b916c1b54..a95ad465b9887 100644
> --- a/include/linux/virtio_net.h
> +++ b/include/linux/virtio_net.h
[ ... ]
> @@ -104,7 +104,8 @@ static inline int __virtio_net_hdr_to_skb(struct sk_buff *skb,
>  
>  		if (!skb_partial_csum_set(skb, start, off))
>  			return -EINVAL;
> -		if (skb_transport_offset(skb) < nh_min_len)
> +		if (skb_transport_offset(skb) < nh_min_len ||
> +		    skb_transport_offset(skb) - skb_network_offset(skb) < nh_min_len)

[Severity: High]
Does this check get bypassed for TUN/TAP devices?

Looking at drivers/net/tun.c:tun_get_user(), the virtio_net_hdr parsing is
invoked before the network header is reset:

drivers/net/tun.c:tun_get_user() {
	...
	if (tun_vnet_hdr_tnl_to_skb(tun->flags, features, skb, &hdr)) {
		atomic_long_inc(&tun->rx_frame_errors);
		err = -EINVAL;
		goto free_skb;
	}
	...
	skb_reset_network_header(skb);
	...
}

Because skb->network_header is uninitialized when __virtio_net_hdr_to_skb()
is called, it retains its 0 value from allocation. This causes
skb_network_offset(skb) to evaluate to a negative value, such as -64 for
prepad bytes.

The new check then simplifies to start + prepad < nh_min_len. Since prepad
is typically >= 32 and nh_min_len is usually around 20, this comparison is
always false. This completely bypasses the security check and leaves TUN/TAP
devices vulnerable to the memory corruption this patch intends to fix.

While a subsequent patch in the series mitigates the consequence for IPv4 in
ip_do_fragment(), are other paths like IPv6 fragmentation via ip6_fragment()
still fully exposed to this bypass?

>  			return -EINVAL;
>  
>  		nh_min_len = skb_transport_offset(skb);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260920004733.6473-1-habte.yibelo@gmail.com?part=1

  parent reply	other threads:[~2026-09-21  0:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20  0:47 [PATCH net v4 0/2] net: prevent partial checksums from modifying IPv4 headers Paulos Yibelo
2026-09-20  0:47 ` [PATCH net v4 1/2] net: validate virtio checksum start after network header Paulos Yibelo
2026-09-20  1:11   ` David Ahern
2026-09-21  0:47   ` sashiko-bot [this message]
2026-09-20  0:47 ` [PATCH net v4 2/2] ipv4: reject partial checksums covering the IP header Paulos Yibelo
2026-09-20  1:12   ` David Ahern
2026-09-21  0:47   ` sashiko-bot
2026-09-21  2:53 ` [PATCH net v5 0/2] net: prevent partial checksums from modifying network headers Paulos Yibelo
2026-09-21  2:53   ` [PATCH net v5 1/2] net: validate virtio checksum start after network header Paulos Yibelo
2026-09-21  3:01     ` sashiko-bot
2026-09-21 22:11     ` Michael S. Tsirkin
2026-09-21 22:18     ` Michael S. Tsirkin
2026-09-21 22:44     ` Michael S. Tsirkin
2026-09-22  0:55       ` Paulos Yibelo
2026-09-24  8:54     ` netdev-bot+sashiko
2026-09-21  2:53   ` [PATCH net v5 2/2] ip: reject partial checksums covering network headers Paulos Yibelo
2026-09-21  3:01     ` sashiko-bot
2026-09-24  8:54     ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260921004754.DDA031F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=habte.yibelo@gmail.com \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox