All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: virtualization@lists.linux.dev, "Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH net-next v2 4/7] net: resolve uncommon partial checksums at ingress
Date: Fri, 16 Oct 2026 12:42:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-174320@kernel.org> (raw)
In-Reply-To: <e66f7984fdeb8168e07fd7d0dad3deb8c30ead0a.1792067836.git.mst@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: OOB read in virtio_net_l3_start due to uninitialized mac_header
--

commit 7b948a860070205bb3211c20ccd737b2f0e9cfad
Author: Michael S. Tsirkin <mst@redhat.com>

net: resolve uncommon partial checksums at ingress

This commit updates virtio net header parsing to validate checksum offsets
and only retain CHECKSUM_PARTIAL when they match parsed TCP or UDP headers.
It also introduces early tunnel offset validation.

> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> index d6466f96cdd00..357115ff0ec2d 100644
> --- a/include/linux/virtio_net.h
> +++ b/include/linux/virtio_net.h

[ ... ]

> @@ -332,10 +550,13 @@ virtio_net_hdr_tnl_to_skb(struct sk_buff *skb,
>  	    inner_th < inner_nh + inner_l3min)
>  		return -EINVAL;
>  
> +	if (!virtio_net_tnl_offsets_ok(skb, outer_isv6, outer_th))
> +		return -EINVAL;
> +

[Severity: High]
Does this sequence result in accessing an uninitialized MAC header?

Tracing the call sequence starting here:
virtio_net_hdr_tnl_to_skb()
  -> virtio_net_tnl_offsets_ok()
    -> virtio_net_l3_start()

Inside virtio_net_l3_start(), if the device type is ARPHRD_ETHER (which is
true for IFF_TAP and virtio_net), the code evaluates eth_hdr(skb)->h_proto:

include/linux/virtio_net.h:virtio_net_l3_start() {
	if (skb->dev->type == ARPHRD_ETHER) {
		if (!pskb_may_pull(skb, ETH_HLEN))
			return false;
		*nhoff = ETH_HLEN;
		*proto = eth_hdr(skb)->h_proto;
...
}

However, eth_hdr(skb) strictly evaluates to skb->head + skb->mac_header.
Callers like tun_get_user() and virtnet_receive_done() do not appear to
initialize the MAC header before calling virtio_net_hdr_tnl_to_skb().

The MAC header is normally initialized via skb_reset_mac_header(skb), which
happens in __virtio_net_hdr_to_skb() located just below this check.

Because virtio_net_tnl_offsets_ok() is called before __virtio_net_hdr_to_skb(),
skb->mac_header retains its default allocation value of 0xFFFF. Could this
cause an out-of-bounds memory read (skb->head + 0xFFFF + offsetof(h_proto))
and a potential kernel panic?

>  	/* Let the basic parsing deal with plain GSO features. */
>  	ret = __virtio_net_hdr_to_skb(skb, hdr, true,
>  				      hdr->gso_type & ~gso_tunnel_type);
> -	if (ret)
> +	if (ret < 0)
>  		return ret;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792067836.git.mst@redhat.com?part=4

  parent reply	other threads:[~2026-10-16 12:42 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 12:41 [PATCH net-next v2 0/7] more virtio-net csum hardening Michael S. Tsirkin
2026-10-15 12:41 ` [PATCH net-next v2 1/7] net: account for ingress-resolved virtio net hdr state Michael S. Tsirkin
2026-10-16 12:42   ` sashiko-bot
2026-10-15 12:41 ` [PATCH net-next v2 2/7] um: vector: honor virtio net hdr conversion failures Michael S. Tsirkin
2026-10-15 12:47   ` Johannes Berg
2026-10-15 12:52     ` Michael S. Tsirkin
2026-10-15 12:55       ` Johannes Berg
2026-10-16  9:37         ` Michael S. Tsirkin
2026-10-16  9:43         ` Michael S. Tsirkin
2026-10-16  9:44           ` Johannes Berg
2026-10-16  9:47             ` Michael S. Tsirkin
2026-10-16  9:49               ` Johannes Berg
2026-10-16  9:53                 ` Michael S. Tsirkin
2026-10-15 17:19   ` Willem de Bruijn
2026-10-16  9:40     ` Michael S. Tsirkin
2026-10-16 12:42   ` sashiko-bot
2026-10-15 12:41 ` [PATCH net-next v2 3/7] um: vector: trim skbs before verifying the header Michael S. Tsirkin
2026-10-16 12:42   ` sashiko-bot
2026-10-15 12:41 ` [PATCH net-next v2 4/7] net: resolve uncommon partial checksums at ingress Michael S. Tsirkin
2026-10-15 17:43   ` Willem de Bruijn
2026-10-15 19:18     ` Chris Arges
2026-10-16  9:34       ` Michael S. Tsirkin
2026-10-16  9:36     ` Michael S. Tsirkin
2026-10-15 18:04   ` Willem de Bruijn
2026-10-15 18:07   ` Willem de Bruijn
2026-10-16 10:02   ` Michael S. Tsirkin
2026-10-16 12:42   ` sashiko-bot [this message]
2026-10-15 12:41 ` [PATCH net-next v2 5/7] net: add a sysctl to opt out of virtio net hdr checksum validation Michael S. Tsirkin
2026-10-15 17:50   ` Willem de Bruijn
2026-10-16  9:33     ` Michael S. Tsirkin
2026-10-16 15:30       ` Willem de Bruijn
2026-10-16 17:51         ` Michael S. Tsirkin
2026-10-16 18:19           ` Willem de Bruijn
2026-10-16 18:40             ` Michael S. Tsirkin
2026-10-17  1:09               ` Willem de Bruijn
2026-10-16 17:55         ` Michael S. Tsirkin
2026-10-16 18:17           ` Willem de Bruijn
2026-10-16 12:42   ` sashiko-bot
2026-10-15 12:41 ` [PATCH net-next v2 6/7] net: add ip4_parse() Michael S. Tsirkin
2026-10-15 18:51   ` Phil Sutter
2026-10-16 11:56   ` Björn Töpel
2026-10-16 12:42   ` sashiko-bot
2026-10-15 12:41 ` [PATCH net-next v2 7/7] virtio_net: cleanup protocol calculation Michael S. Tsirkin
2026-10-16 11:52   ` Björn Töpel
2026-10-16 12:42   ` sashiko-bot
2026-10-15 19:21 ` [PATCH net-next v2 0/7] more virtio-net csum hardening Chris Arges

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=sashiko-outbox-174320@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eperezma@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.