🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26777

[PATCH net v2 1/2] gve: do not verify the XDP configuration on program or pool removal

#26777
From: Amaan Cheval
Date: Fri, 04 Dec 2026 06:28
119 lines
16484 bytes
gve_xdp() runs gve_verify_xdp_configuration() before it looks at the
command, so the check also applies when a program is removed or an
AF_XDP zero-copy pool is disabled. gve has no ndo_change_mtu, so the
MTU can be raised past the XDP limit while a program is attached. From
then on every removal fails with -EOPNOTSUPP.

The core does not expect a removal to fail. With a netlink attach the
program cannot be removed until the MTU is lowered again:

  # ethtool -L eth0 rx 1 tx 1
  # ip link set dev eth0 mtu 1460
  # ip link set dev eth0 xdp obj xdp_pass.o sec xdp
  # ip link set dev eth0 mtu 4000
  # ip link set dev eth0 xdp off
  Error: gve: XDP is not supported for mtu 4000.

With a bpf_link the release path ignores the error. The core warns and
drops its reference while the driver keeps running the program:

  WARNING: net/core/dev.c:10824 at bpf_xdp_link_release+0x194/0x1a0, CPU#0: xdp-hold/1293

After that no program is listed on the device, but the driver still
runs it on received packets and it stays loaded.

Only run the check when a program is installed or a pool is enabled.
Installing at an unsupported MTU is still refused.

Reproduced on gVNIC in GQI-QPL mode (GCE n2-standard-4) on net at
commit ef3e21c61baa ("net/tcp-ao: fix reset key lookup for IPv4
segments on IPv6 listeners") with reproduce.sh at the Link below, on an
unmodified kernel and without error injection; the output above is from
that kernel. The script runs the equivalent of the commands above with
its own XDP program, and the bpf_link case with a small loader. On the
patched kernel both removals succeed, there is no warning, the program
stops processing packets, and a new attach at MTU 4000 is still refused.
gve_xdp() and the check are shared by the two queue formats that support
XDP. On DQO-RDA (c3-standard-4, HW-GRO off, 2K RX buffers) the
unmodified kernel fails in the same way and the patched kernel does not.
Unloading gve there with the program attached at MTU 4000 hits the
WARN_ON() in dev_xdp_uninstall() on the unmodified kernel and gives no
warning on the patched kernel.

drivers/net/queues.py passes on the patched kernel; drivers/net/xdp.py
was not run, it needs a second host.

The AF_XDP pool disable path was tested on a second n2-standard-4 VM
(GQI-QPL, network MTU 3000), because gve only enables a zero-copy
pool when one UMEM frame holds the device's maximum MTU. A zero-copy
socket was bound at MTU 1460 with no program attached, the MTU raised
to 3000 and the socket closed. The unmodified kernel logs:

  Failed to disable zero-copy!
  WARNING: net/xdp/xsk_buff_pool.c:160 at xp_disable_drv_zc+0xa7/0xd0, CPU#3: kworker/3:1/64

After the warning the core frees the pool anyway, while gve still has
it DMA-mapped and, if a program is attached, its queues still point at
it. That last case was found by reading the code and not reproduced.

On the patched kernel the pool is disabled and there is no warning.
The same warning appears at an unchanged MTU when the queue counts are
raised while the pool is bound, which gve allows when no program is
attached; on the patched kernel it does not.

This bug was found and fixed with the help of an AI coding assistant
over an interactive session; it read the driver and the XDP core, and
ran the tests above.

Link: https://github.com/AmaanC/sticky-xdp
Fixes: 75eaae158b1b ("gve: Add XDP DROP and TX support for GQI-QPL format")
Fixes: fd8e40321a12 ("gve: Add AF_XDP zero-copy support for GQI-QPL format")
Cc: stable@vger.kernel.org
Signed-off-by: Amaan Cheval <amaan.cheval@gmail.com>
---
v2: no changes.

 drivers/net/ethernet/google/gve/gve_main.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index 35cf0f06a0f2..5156259232b2 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -1852,17 +1852,27 @@ static int gve_xdp(struct net_device *dev, struct netdev_bpf *xdp)
 	struct gve_priv *priv = netdev_priv(dev);
 	int err;
 
-	err = gve_verify_xdp_configuration(dev, xdp->extack);
-	if (err)
-		return err;
 	switch (xdp->command) {
 	case XDP_SETUP_PROG:
+		/* Removing a program must not depend on the configuration
+		 * still being valid for XDP: the core does not expect an
+		 * uninstall to fail.
+		 */
+		if (xdp->prog) {
+			err = gve_verify_xdp_configuration(dev, xdp->extack);
+			if (err)
+				return err;
+		}
 		return gve_set_xdp(priv, xdp->prog, xdp->extack);
 	case XDP_SETUP_XSK_POOL:
-		if (xdp->xsk.pool)
-			return gve_xsk_pool_enable(dev, xdp->xsk.pool, xdp->xsk.queue_id);
-		else
+		if (!xdp->xsk.pool)
 			return gve_xsk_pool_disable(dev, xdp->xsk.queue_id);
+
+		err = gve_verify_xdp_configuration(dev, xdp->extack);
+		if (err)
+			return err;
+		return gve_xsk_pool_enable(dev, xdp->xsk.pool,
+					   xdp->xsk.queue_id);
 	default:
 		return -EINVAL;
 	}
-- 
2.47.3
Technical Details
Message-ID: <20261204062857.730993-2-amaan.cheval@gmail.com>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377115-linux-kernel-netdev=dewy.ru
References: <20261204062857.730993-1-amaan.cheval@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377115-linux-kernel-netdev=dewy.ru
From: amaan.cheval@gmail.com (Amaan Cheval)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 1/2] gve: do not verify the XDP configuration on program or pool removal
Date: Fri,  4 Dec 2026 11:58:56 +0530
Organization: Usenet Network
Message-ID: <20261204062857.730993-2-amaan.cheval@gmail.com>
References: <20261204062857.730993-1-amaan.cheval@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2692573"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CtLhkk399mQ0dx1EfZTPnnSAOQA= sha256:T9qvNJTzYSZe4EDjhsHF3ZCHhhEkicvvL+iJzRWQs5k=
	sha1:oLFLzCVuNJMNcPfVFMcG8YXzj0E= sha256:Vra0ZTlPB2ym9WyVlzVLdoIW0bv0zeoVrl34ML3BXWw=
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 AED56117B2C; Fri,  4 Dec 2026 09:30:10 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.296
X-Spam-Status: No, score=-3.296 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, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=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 0f9-sIAUCYmc;
	Fri,  4 Dec 2026 09:30:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377115-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 42AA8117B2B; Fri,  4 Dec 2026 09:29:58 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 4754C27E1C; Fri,  4 Dec 2026 06:29:56 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796365796;
	b=22VAxJnYlg3deNdbnOkEQ63hHQbd83FS2ldI/7ADNEkng0nkpq+/0HaRrdxoah4bN8nZ
	 IvY0b5dDDwWv7Bz1M668anFk6LMcYiPFUQurzaTXRJj8pofWS9R/dCwmJMcoM5sVu/Jbd
	 A9UqYesa3E0IO5KoyIxAOsdjPldxrPfbW+5RfzhOXSxPynsrApPOJjqKvqy1jbVUsJkbq
	 +BXj1xTyngem/MEx497YmhJh4S+j3E0AIj/u8zB7YqRqy7nK2jdGMS6F8JRZlOkFojuPC
	 0nDKaEq1dpE66r0ieeeaGov0xY11EcUur2ssGbyun92x26F2SftOcIc8HWiysJMECxw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796365796;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=5FuxEdJSPY65rdG7/svQSZpnOKb90xXYqVtgxlok9I8=;
	b=qlOkWWcnClLukhhWowT6gk5Yd4KklfNCIzx60iU6jIl/CZKPFkFnSE2qIqG9p5mEmJyV
	 6uXa/cGf8DjzUApHxN4Lk8bE7UKnftuDdhLL+efe8hifW64PAo3rTeOvOXwvBU5QFdoDY
	 Fl4/sXyv1JV6wiItkRNUet/SoL6qGP7XZuqrOcesj5SFzb7PzKZqTWsqgexB/3RJ0396t
	 +70eaVIav85uOXOjhcQBY43SNsgBT86/7gbdl6GXegLCvIi6QETWqlWMNiS3QP4opBXZ0
	 hydCdeMiafD65YUjlMpw83LyQoOpPFF8Nh63yZ3PJtlWi5P1mptZEC/5Nfpgu+jIuDg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=U8tPFUAN;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AD89606A337;
	Fri,  4 Dec 2026 06:29:56 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=U8tPFUAN
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.50
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796365795;
	b=OL3NKNPU9PF0cJ9bT7oOcqGyWEd9eY7CK9a1b3+vFXR5VYDvAs+CUXa7+520FqJrfynf
	 au6ar0pTZSe++lu7Q9AQ/kqdrlYTQD1PjSnClSYz/ITAHgl4n9LWMBdX3vvjujlt1J6po
	 uKkZzpUj5dLSQ/NDDltW1bHc2A9NUR8Do0tyZ5F6NzVLRIeGRsAEep1+NES7KgiYIAuu4
	 QcJZXK/+jFTz42BAnTVYaxuwowuAZHQ121A1kX8vyhOntmvGUDkJjN1lWQ6NtnZR5bM60
	 wy0pEmh3PlFL1y090WWV/EuTAoN/Iz6mS+wwyN0cZVxjr+DIBUfqy6bq81i96Efd1iQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796365795;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=5FuxEdJSPY65rdG7/svQSZpnOKb90xXYqVtgxlok9I8=;
	b=0d71CbxxfuwCBgTy7s9abQZ28q+1QypUv9BrXpCQx29+tzRafENyXTWIJx/dIidXJbD3
	 Cpf4utLRXsxcFsJ0Tk4WfxxS6LKGNl/the8QJgev8OgSGAkTq5VNrI7Te7qOcNpDzxcaH
	 xizSuGvocVmxekyW5s90oWsz/xXC9TtbtYeN/mQFqoUCdH0Xqb0YuN1OvvOGWRW4Ii8il
	 KYk7QO/pub51b6uRFyzD/1k+A8pUWaED9zZAkSSwiD/m6+cGGqCimFnBzzvQiHrn9g0n2
	 qpn6nwfl7TcZs3Ii0ovI43eM0Aha61WW1tutfDG/0ntHNjUIPclIZzo94gK1x2yMNgw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=U8tPFUAN;
	arc=none smtp.remote-ip=74.125.82.50
X-Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5609606A330
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 06:29:54 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D5609606A330
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-dl1-f50.google.com with SMTP id a92af1059eb24-18818daa3e7so1013522c88.0
        for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 22:29:54 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796365794; x=1796970594; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=5FuxEdJSPY65rdG7/svQSZpnOKb90xXYqVtgxlok9I8=;
        b=U8tPFUANM3GfM3GhBWfHTy7hgOA++cYC9FLsjM/ivxNN9RgH2vEh+On/U4VBsK52jG
         ilYwR8hkRc0S4xR1v7FJCVXF58HT+4oXMw5ooSgoIZdHVFprwG+lpQ8HcnelzPo9s1Sc
         Z8WGCWJFXHezRReNp9f1cqrdxLZZEl5BDbH7r5UFhhemdLsbar23xi2AfGeAiQFrwR2T
         EIxOve0/yzqLUK1GdZ5ISsbE6nCaH7KpSUhCAUWKRJJcqcpNMrmV6GhocDmAZq7qyHiN
         cYe3ep2FUrVdGciBkK0mRIv7NJYbDXCu7eczxtyxlXxie0p6YwYtEhVXigHYGLKeNeok
         MQHA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796365794; x=1796970594;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=5FuxEdJSPY65rdG7/svQSZpnOKb90xXYqVtgxlok9I8=;
        b=mharMx/kNb9Wg+bZk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PqK18P7oPhFUHA7xEC
	LeUliVlOwkFwPE+k0FvtsBzMHDvF1k+wWIbiTVGKnu4D
X-Received: by 2002:a05:7022:b150:10b0:1b5:c305:2f72 with SMTP id a92af1059eb24-1b5d6fd2b96mr1080875c88.0.1796365793933;
        Thu, 03 Dec 2026 22:29:53 -0800 (PST)
X-Received: from localhost.localdomain ([2406:7400:51:44ac:c2b6:f9ff:fe77:10a0])
        by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d63d04e7sm4447866c88.1.2026.12.03.22.29.45
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 03 Dec 2026 22:29:53 -0800 (PST)
X-Cc: joshwash@google.com,
	hramamurthy@google.com,
	andrew+netdev@lunn.ch,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	ast@kernel.org,
	daniel@iogearbox.net,
	hawk@kernel.org,
	john.fastabend@gmail.com,
	sdf@fomichev.me,
	bpf@vger.kernel.org,
	willemb@google.com,
	jeroendb@google.com,
	pkaligineedi@google.com,
	nktgrg@google.com,
	jordanrhee@google.com,
	przemyslaw.kitszel@intel.com,
	debarghyak@google.com,
	treapking@google.com,
	magnus.karlsson@intel.com,
	maciej.fijalkowski@intel.com,
	horms@kernel.org,
	michal.kubiak@intel.com,
	anthony.l.nguyen@intel.com,
	aleksander.lobakin@intel.com,
	Amaan Cheval <amaan.cheval@gmail.com>,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.49.0
X-In-Reply-To: <20261204062857.730993-1-amaan.cheval@gmail.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 16262