From: sashiko-bot@kernel.org
To: "Showta Ishizaki" <zakinko@snowrabbit.org>
Cc: virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH RFC net v11 6/6] net: add a sysctl to opt out of virtio net hdr checksum validation
Date: Sat, 05 Dec 2026 04:01:53 +0000 [thread overview]
Message-ID: <sashiko-outbox-251043@kernel.org> (raw)
In-Reply-To: <20261204.rfcv11.99731.6.zakinko@snowrabbit.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] net: missing RCU in virtio_net_hdr_validate_disabled() causes
netns UAF
--
commit 0b89c5d558deb20303dfa4d099fe2c3a761554eb
Author: Michael S. Tsirkin <mst@redhat.com>
net: add a sysctl to opt out of virtio net hdr checksum validation
This commit adds a per-netns sysctl net.core.virtio_net_hdr_validate
(default 1) guarded by a global static key so deployments can opt out of
virtio_net header checksum validation.
> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> index 6fe0c59217175..9e4b4440d062a 100644
> --- a/include/linux/virtio_net.h
> +++ b/include/linux/virtio_net.h
[ ... ]
> @@ -88,6 +89,18 @@ static inline struct iphdr *virtio_net_ip4_parse(struct sk_buff *skb,
> return (struct iphdr *)(skb->data + nhoff);
> }
>
> +/* Defined in net/core/dev.c, enabled while any network namespace
> + * has net.core.virtio_net_hdr_validate set to 0.
> + */
> +DECLARE_STATIC_KEY_FALSE(virtio_net_hdr_validate_disabled_key);
> +
> +/* The caller must keep the netns of skb->dev alive. */
> +static inline bool virtio_net_hdr_validate_disabled(struct sk_buff *skb)
> +{
> + return static_branch_unlikely(&virtio_net_hdr_validate_disabled_key) &&
> + !READ_ONCE(dev_net(skb->dev)->core.sysctl_virtio_net_hdr_validate);
> +}
[Severity: High]
Can dereferencing dev_net(skb->dev) here cause a use-after-free of the
network namespace?
The comment assumes callers keep the netns alive, but sleepable callers
such as tun_get_user() hold only dev_hold(dev), with no rcu_read_lock()
or netdev_lock(). __dev_change_net_namespace() swaps dev->nd_net and
synchronizes only with RCU readers, not dev_hold() references.
Once any namespace sets net.core.virtio_net_hdr_validate to 0 and
enables virtio_net_hdr_validate_disabled_key:
CPU0 CPU1
tun_get_user() /* holds dev_hold() */
...
virtio_net_hdr_validate_disabled()
net = dev_net(skb->dev)
/* preempted */
__dev_change_net_namespace()
dev_net_set(dev, new_net)
synchronize_net()
cleanup_net(net)
net_complete_free(net)
READ_ONCE(net->core.sysctl_...) <-- use-after-free
This causes a use-after-free read of struct net, which can crash the
kernel or bypass validation if the slab memory is reused. Even callers
holding rcu_read_lock() race with dev_net_set() because dev_net() omits
RCU dereference semantics compared to dev_net_rcu().
Guarding a dev_net_rcu(skb->dev) lookup with rcu_read_lock() and
rcu_read_unlock() after the static_branch_unlikely() check would fix
both issues without adding overhead when validation is enabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204.rfcv11.99731.0.zakinko@snowrabbit.org?part=6
next prev parent reply other threads:[~2026-12-05 4:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 4:01 [PATCH RFC net v11 0/6] more virtio-net csum hardening Showta Ishizaki
2026-12-04 4:01 ` [PATCH RFC net v11 1/6] net: account for ingress-resolved virtio net hdr state Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot
2026-12-04 4:01 ` [PATCH RFC net v11 4/6] net: resolve uncommon partial checksums at ingress Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot
2026-12-04 4:01 ` [PATCH RFC net v11 3/6] virtio_net: parse tunnel csum_start little-endian Showta Ishizaki
2026-12-04 4:01 ` [PATCH RFC net v11 2/6] um: vector: trim skbs before verifying the header Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot
2026-12-04 4:01 ` [PATCH RFC net v11 5/6] net: virtio: compute the outer checksum of non-GSO tunnel packets Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot
2026-12-04 4:01 ` [PATCH RFC net v11 6/6] net: add a sysctl to opt out of virtio net hdr checksum validation Showta Ishizaki
2026-12-05 4:01 ` sashiko-bot [this message]
2026-12-04 4:06 ` [PATCH RFC net v11 0/6] more virtio-net csum hardening netdev-bot+sinfo
2026-12-05 4:01 ` sashiko-bot
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-251043@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 \
--cc=zakinko@snowrabbit.org \
/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.