From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796443314; b=OZqud6FL2zR295ZokW09yQ/26aaCNo5hp/+7bQ/qzOIZ/ctAuE9/rzEvfuWqN6GORuZV IFEbiTJ3UsUHXfBHNFPjSPmxz2tsabZLioHiyDYpR0PgpED6MqopbZ254EtUXqUUzMA4i iVlMyr2qnhEu7BaJOoo2f1OS5ER2pHydK/QFr1LL/f93LhhcxjnVk6/614UnaCj/FaQyk 2UWOHpLopj9XRnfDKuamUNYPvbILPtglSb1gJ8B5OemtW7YYkPFlQcEL2hVUzbTvlVwRv VrM0S5X+UMyKkx0fJ/vj82TJVLBZX8qKXEjHXSYh+YyvkzPaYHt2KPak2qhZ34yN2WA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796443314; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=v50YBgizLzhm8rl7opD5tYilR8vnXagbcWxO8yyeifU=; b=ohX+0Gnr8k2NIocbAY/POC1nVrWWBZHOuD/ujpBAsbLK6aWjGno242QdKVTTHeuDvG9k zLT7pmQfPYzabu8QPc+XN2emBc7cR+844inkAyIehfeZaKJ/7G38YrXK0yjE0syTlu9Xd XLoGMM6QWXmDbrZMEgYegk6VAMIZVbRco4vHWP9SVs5QtnzyFEUaZruua4ZRsZCcQZh6j 7Zx/ybFjd18fRs+1yqj30rxciz/KIsAxPs3UtXUg4jB5quRHX2+L1ODjfx9QDf58eeszj sOFuyhMbeQUYM2BMXyRHjpoJTtA8IECNzO4rKiEwn1jRFfBHVDNs28hVHaZezUaELpw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JyOoO6Fl; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 882FC606A33B for ; Sat, 5 Dec 2026 04:01:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JyOoO6Fl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DE4E1F0092B; Sat, 5 Dec 2026 04:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796443314; bh=v50YBgizLzhm8rl7opD5tYilR8vnXagbcWxO8yyeifU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JyOoO6Fl/QtUMI/VEI39UBqPpPRaUVd/KFD/3Ub0dqZHHgiYUf6CgwonewLz3fLSM 5iBbhoqyg+B5oeY3EMS0iPQfch7f/pdWZyEM/WbVPnFG5b1LzPU/qFWRGDidsStpQy PAil5eGGUE3spHNX2xV10HY0i2exRnmzvgCvtHv69SpDyn4XqcWenLGLTHUgZ5YVeC xtmb8LBu3kNEZh/CsWRyiZF0UBQVa7ULyyv+wiRvkZZJn1ZTPmof4b2s9XmNEitB7G d5SwQ1bH68QKjSUvO4bGD8lC6BrIQiVOaOBSmrfVXB3NjQsBlyM0WvfZumsX/f6Uhe rm2xLmaIX8ZlQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RFC net v11 6/6] net: add a sysctl to opt out of virtio net hdr checksum validation Reply-To: sashiko-reviews@lists.linux.dev To: "Showta Ishizaki" Cc: virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <20261204.rfcv11.99731.6.zakinko@snowrabbit.org> References: <20261204.rfcv11.99731.0.zakinko@snowrabbit.org> <20261204.rfcv11.99731.6.zakinko@snowrabbit.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 04:01:53 +0000 X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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(struc= t sk_buff *skb, > return (struct iphdr *)(skb->data + nhoff); > } > =20 > +/* 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_validat= e); > +} [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 =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204.rfcv11.997= 31.0.zakinko@snowrabbit.org?part=3D6