Article View: linux.kernel.netdev
Article #4044Re: [PATCH net-next v2 5/7] net: add a sysctl to opt out of virtio net hdr checksum validation
From: Willem de Bruijn
Date: Fri, 16 Oct 2026 15:30
Date: Fri, 16 Oct 2026 15:30
115 lines
13517 bytes
13517 bytes
Michael S. Tsirkin wrote: > On Thu, Oct 15, 2026 at 01:50:54PM -0400, Willem de Bruijn wrote: > > Michael S. Tsirkin wrote: > > > The ingress validation as implemented by the previous > > > patch is stricter than what it replaced: GSO > > > packets whose checksum metadata matches no transport header are > > > dropped, and non-GSO ones get their checksum completed in place. > > > Such packets used to pass with the metadata unvalidated, > > > and with no overhead. > > > > > > I judge that this should not affect any deployments, but there is still > > > some risk that it does. In case a deployment depends on them anyway, > > > provide a per-netns switch to get the old behavior back: > > > > > > echo 0 > /proc/sys/net/core/virtio_net_hdr_csum_check > > > > > > The default is validating. > > > > > > Assisted-by: LLM > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > > --- > > > Documentation/admin-guide/sysctl/net.rst | 15 +++++++ > > > include/linux/virtio_net.h | 23 ++++++++++ > > > include/net/netns/core.h | 1 + > > > net/core/dev.c | 6 +++ > > > net/core/net_namespace.c | 1 + > > > net/core/sysctl_net_core.c | 54 ++++++++++++++++++++++++ > > > 6 files changed, 100 insertions(+) > > > > > > diff --git a/Documentation/admin-guide/sysctl/net.rst b/Documentation/admin-guide/sysctl/net.rst > > > index e586e17fc7a5..7f230929c37e 100644 > > > --- a/Documentation/admin-guide/sysctl/net.rst > > > +++ b/Documentation/admin-guide/sysctl/net.rst > > > @@ -246,6 +246,21 @@ processes are dropped unless socket option SOF_TIMESTAMPING_OPT_TSONLY is set. > > > Default: 1 (on) > > > > > > > > > +virtio_net_hdr_csum_check > > > +------------------------- > > > > Make more generic, virtio_net_hdr_validate? > > > > In case we add more validation in the future (as we have in the past), > > without having to introduce multiple such knobs. > > But it's uapi, are you sure we'll be able to change the meaning > of an existing knob, even if we keep the name vague? > > > > + > > > +When processing packets with a virtio net header (through tun, tap, a > > > +packet socket or a virtio network device) that request checksum offload > > > +(VIRTIO_NET_HDR_F_NEEDS_CSUM), validate the packet: complete the checksum > > > +in software, or drop the packet where the header does not match it. > > > + > > > +When disabled, the header is trusted not to corrupt the packet, and the > > > +checksum is offloaded to hardware (or not verified if it never reaches > > > +hardware). This is only safe if no protocol is processing the packets. > > > + > > > +Default: 1 (on) > > > + > > > + > > > wmem_default > > > ------------ > > > > > > diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h > > > index 357115ff0ec2..aa2f8ac4657c 100644 > > > --- a/include/linux/virtio_net.h > > > +++ b/include/linux/virtio_net.h > > > @@ -5,6 +5,7 @@ > > > #include <linux/if_vlan.h> > > > #include <linux/ip.h> > > > #include <linux/ipv6.h> > > > +#include <linux/jump_label.h> > > > #include <linux/netdevice.h> > > > #include <linux/udp.h> > > > #include <net/gso.h> > > > @@ -78,6 +79,19 @@ static inline struct iphdr *virtio_net_ip4_parse(struct sk_buff *skb, > > > *thoff = nhoff + iph->ihl * sizeof(u32); > > > return iph; > > > } > > > +/* Defined in net/core/dev.c, enabled while any network namespace > > > + * has net.core.virtio_net_hdr_csum_check set to 0. > > > + */ > > > > Should this be a global sysctl, rather than per netns? > > > For customers I work with, it would be much less useful. Third option: make it an integer rather than a boolean. 0: no validation 1: current level of validation 2 and beyond: if we have to extend it later Not pretty, I'll admit. So fine to keep as is too if you prefer. But I do foresee more changes in this area, if history is a guide. > > > Even if per-netns, most likely do not want it writable by netns root > > with user namespaces. > > > > That is the equivalent of ns_capable(CAP_NET_RAW), which is the cause > > of many crashes due to bad packets ingested by, e.g., a packet socket. > > Hmm, yes i get that. Two knobs? a. verify b. the per netns value ro? Both > on by default? A single system wide field is simplest. Is there a benefit to making this configurable on a per netns basis? If so, that's fine too. As long as root-in-namespace cannot modify it, so readonly indeed.
Technical Details
Message-ID:
<willemdebruijn.kernel.1d7ce6b64753a@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347420-linux-kernel-netdev=dewy.ruReferences:
<cover.1792067836.git.mst@redhat.com> <ad05a40681719a579691a1da6413f0dd7064f2a0.1792067836.git.mst@redhat.com> <willemdebruijn.kernel.3a7d04e1c306e@gmail.com> <20261016051827-mutt-send-email-mst@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347420-linux-kernel-netdev=dewy.ru
From: willemdebruijn.kernel@gmail.com (Willem de Bruijn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 5/7] net: add a sysctl to opt out of virtio
net hdr checksum validation
Date: Fri, 16 Oct 2026 11:30:17 -0400
Organization: Usenet Network
Message-ID: <willemdebruijn.kernel.1d7ce6b64753a@gmail.com>
References: <cover.1792067836.git.mst@redhat.com>
<ad05a40681719a579691a1da6413f0dd7064f2a0.1792067836.git.mst@redhat.com>
<willemdebruijn.kernel.3a7d04e1c306e@gmail.com>
<20261016051827-mutt-send-email-mst@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="2806445"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xoPE4dNoyCwlX33hzgcZH6fAQr0= sha256:Mh7RlfNLh/lNOcDtSjaRg3fWoniLfWCA+3fY919I/OM=
sha1:Kpi2R70B6sZ7HYC/SMbsjCXhnrg= sha256:IvSvpsjPFnspjDlSvxJenKfDdrRs7iKx7dZfiEw62Xo=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 2031711052A; Fri, 16 Oct 2026 18:52:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.047
X-Spam-Status: No, score=-3.047 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, FSL_HELO_FAKE=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id RocKSDlE-JBF;
Fri, 16 Oct 2026 18:52:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-347420-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id 5105811056D; Fri, 16 Oct 2026 18:52:23 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sin.lore.kernel.org (Postfix) with ESMTP id 6078B36360; Fri, 16 Oct 2026 15:32:34 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id A18D24ED1AA;
Fri, 16 Oct 2026 15:30:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KHcDDe3T"
X-Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03BED4E2F17
for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 15:30:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.49
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1792164621; cv=none; b=ii2406do1viZplcG6lIpipm78USHHaqmrQm/inE6Qj+DfGogCU4zljb8tGnIQi6KQ5Ztig6TQVRw83TdnJMmrXD1xF5p0niYVRfsWmsU2h+t2wVJkEkZFvQjhBIcCnJpTmu5szU3Qdmz65X+GrUzLT3eRH0Wn3bWS3x61v0poQw=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1792164621; c=relaxed/simple;
bh=IMgRqh7P9bFjG3FfvNoeXAv6Y2588Kxr8DTOqxdoKgw=;
h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject:
MIME-Version:Content-Type; b=nlpIGCo0sndsCzLawH3ma61/NBIzxPW5MMOAXy13TEAmEVDekAjmU4teT3IBD/paPkYAnukPXTM/7iu9SJRRe4vNs8mz6YlaxYkWhJyJTcspDm0rrt4hVkm24zvtzvusp57W+SmDNpAd+uceV8qKXbsWX0uvmDe1CDH5d195Rh0=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KHcDDe3T; arc=none smtp.client-ip=209.85.217.49
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-vs1-f49.google.com with SMTP id ada2fe7eead31-7c3b75caad1so3963378137.0
for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 08:30:19 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792164619; x=1792769419; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=EzgDhar5zkz19hBJENwPklhUs01SGYbuNfu08NDtMCg=;
b=KHcDDe3TiZHqPdrRSG1PuehEC3fud6vLfAYiRm5TT3GDi3zkDvf6KoV5YT+OK5B20x
piaQ2+hRNyy7xWEF48DyfIv1AIpiMeGFMF0s8fbLNy8x5kc+FLiYyLOe3BAposIrH/Pg
GOPIYGO/y/lWgppiHaknIzgJOzLIQDecBgK8eW6Pmr2/DKeQk6P9YYWV0Coxuo3ykfY0
ycNph4bc11HWb2ddYSS803JPu7nIkMJMFQVCOWdXb6/4isbWfeU5SezjIlLjs+9foQvo
ePAFFkOAlPLScxddFDbVRWosIXe/vWKuxC8VsI6rU+Y3p8A2er+A+O77EyIs6X7bUOEP
GYsg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792164619; x=1792769419;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=EzgDhar5zkz19hBJENwPklhUs01SGYbuNfu08NDtMCg=;
b=pNBO0NsBLmMfPLZ2E5WVdnvj01cE+ATqLu/3Q0gQ89yJqW63LbgI0QuQlVpITfCwrs
NU5Zw8smyVspb1j6KLmrLN74PvALpiWQ8PbG56hUySBTeyOJICaachKkI+XPkEqbsxwi
eoqPWPbv97M+V3qhJBPpkSh7VIkEA9q8QEwBolL6RACe+80FQjhSwT4escMnU7GpqBlo
Zu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with SMTP id ada2fe7eead31-7cc1acf084bmr1323389137.33.1792164618748;
Fri, 16 Oct 2026 08:30:18 -0700 (PDT)
X-Received: from gmail.com (111.46.245.35.bc.googleusercontent.com. [35.245.46.111])
by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-990833c2c2dsm1836983241.2.2026.10.16.08.30.17
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 16 Oct 2026 08:30:17 -0700 (PDT)
X-Cc: linux-kernel@vger.kernel.org,
Jason Wang <jasowangio@gmail.com>,
Eugenio PΓ©rez <eperezma@redhat.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org,
virtualization@lists.linux.dev,
Rusty Russell <rusty@rustcorp.com.au>,
Max Krasnyansky <maxk@qualcomm.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Simon Horman <horms@kernel.org>,
linux-doc@vger.kernel.org
X-In-Reply-To: <20261016051827-mutt-send-email-mst@kernel.org>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>