🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26165

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

#26165
From: Amaan Cheval
Date: Thu, 03 Dec 2026 06:12
117 lines
16120 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>
---
 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: <20261203061215.487858-2-amaan.cheval@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376315-linux-kernel-netdev=dewy.ru
References: <20261203061215.487858-1-amaan.cheval@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376315-linux-kernel-netdev=dewy.ru
From: amaan.cheval@gmail.com (Amaan Cheval)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 1/2] gve: do not verify the XDP configuration on program or pool removal
Date: Thu,  3 Dec 2026 11:42:14 +0530
Organization: Usenet Network
Message-ID: <20261203061215.487858-2-amaan.cheval@gmail.com>
References: <20261203061215.487858-1-amaan.cheval@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2192760"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0MYNGnWfqpJvZ5GAWlpvx5KW2iI= sha256:Cepotm3mcLRZPKbCEg4KJR30SdT3JnqKVepX3+um/Sc=
	sha1:vSZaz6euECf+JoHl5vzAugtX7Q8= sha256:Ga4C2aO1l2qEU8vdwNzOHopSkyBXznAtN2Y9MMIGSoA=
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 7E53E117832; Thu,  3 Dec 2026 09:13:10 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
	tests=[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.249, 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 LA9jW5sO5dIq;
	Thu,  3 Dec 2026 09:13:06 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376315-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 12E7011782E; Thu,  3 Dec 2026 09:12:57 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id DD035256E0; Thu,  3 Dec 2026 06:12:53 +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=1796278373;
	b=btU+gEM/GCIILHZ1w576f+8q2meWo6aLNKiougMBxoWg2/9x6PTubRQQAtkbdjzXlYcB
	 Ar/LvnV0e8bjxqYctNId3vPmuM6CQkfqvAPnOSpQizmK7rMmKvEqRCMWchI89HV6pLxnm
	 CRoDEG8zOIW6Qh6h+HQHvLcUaDjzY/7hcLtqbh/8y96kDg/27yWur6hEbaVsmWDBVxe8O
	 Todmqlzl0UITHkIVgfZdUkgLOPxMq3u8skgICLj6nUF8gfVK9xyoKxI5iTZmz3ZzRFXXq
	 IJSm3HRGhXoSuMRYrr3t0X3CD+QhGMucLaFqi1+jdGWeh80AQqAs85qwzZV8A2oMgwg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796278373;
	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=Kd2cNHplcgbkAvOIeDwt9SaUxa+AdzoDGnZ38psuJHE=;
	b=MH0mPo+oHxCxZI9sR2YUliR5+4hMbeelESQL80ddgsefPzvKlSZP9lgFxzAgMz7YHv3R
	 3CAPqunLO9OIaoS8RI62R08xMfY0tnVLSBVAmXxcshQFOTnUK43PUTgufzGslG4tkF0WN
	 B5izTj8JMSAwMQGIoLWI8Dcuvnkkokl7PYH8vxLDDiMBWbgaVxLW3oI4Bu1wbJdQKky89
	 f1eu6iOsO5GtMMihI2Gld8tVDdWbrEuTVkWZhUY/wFPIcX5RqlHD6ZHtWkcyr5tbdpbbH
	 SBP193FHK+k2GdgwxPFjTP5frLjwBD0W5uAEPVnyyun2/eXc4XrntHNgodtyF/DoalQ==
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=umx8osl5;
	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 3589B606A322;
	Thu,  3 Dec 2026 06:12:53 +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=umx8osl5
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.45
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796278372;
	b=bnILUQsooGgoF5w7waczcDKCFdausNZrQcFkjNWcDNLAxfN0G8L/VOMhUhj3cUEpgrGc
	 msbna5SMBIXpguaSFWWKN4GMXumJrIqdQBWB983r8DOetpuyTGEuGVXVvMR5hqds7999k
	 9UImv5PQioY+Vhw2CBQQyexTzRfMP/b5TLY8AZjixhrDlBqalJVv2zP6m/vYLUMqUPr8D
	 DHYq6EcwUNzPvrZm0nSXITP4KsLPWFBwbuQXyykEpvScOwb261W8y8WgSmPxoWd7cssKc
	 PvuM1uWVWbJYktKgZcEl4JUci8/WUAOc87pIlf3snD+Hsp4mplwCV1MMKQhK6jYE7Xw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796278372;
	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=Kd2cNHplcgbkAvOIeDwt9SaUxa+AdzoDGnZ38psuJHE=;
	b=DTa56yJw4I0hVB8ctnhiBmkNtacRg7c8cSASVD7oEHfGGxws3Yax+pKNT5IwOm2HzyTk
	 qus+ahcuelncDgcfLmhdkZHfF/a4JMJ/Dr8aByqky1m+qo/vQz6Gt/PmUVHE00xFm8v6J
	 WS2Tgdp9wlNZ0wProzVlDygl9FYav78YajXv5sk2JfPaBABVliVcTYFdwCNiJO1fhL2qI
	 4o+0KUaUr6SRK14yB1P/ACrXeetllsTpcnI6MoRPde+KatoKJqB0ZFiXPWtBbK7WMWNt1
	 uan2HVxKd+njtJOXr2N0YrEYjqfjKe3XbhbM1/wcQS68ci725fX98mkiwIxE2MbSw+w==
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=umx8osl5;
	arc=none smtp.remote-ip=74.125.82.45
X-Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45])
	(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 056F1606A32D
	for <netdev@vger.kernel.org>; Thu,  3 Dec 2026 06:12:51 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 056F1606A32D
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-f45.google.com with SMTP id a92af1059eb24-1b59dfe466bso7627944c88.1
        for <netdev@vger.kernel.org>; Wed, 02 Dec 2026 22:12:51 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796278371; x=1796883171; 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=Kd2cNHplcgbkAvOIeDwt9SaUxa+AdzoDGnZ38psuJHE=;
        b=umx8osl5qbzlgckdKtSi6mMd+nvMSi5+CdF5xUMNeiObpPJVREcqoCaemT50+2thw0
         7V27kRoutE6ZDGv+9wFKBuQ2MXEtx2+bIAReLYc8QP3CBvs1G56rl1TiyCHcjzd5h88l
         vYPlCiVr90gJnXg/nPXKdPQ5ni54+pOtLTy7Y7WE0Xrz0km3eLAFalrlsrrWg7cfH2St
         10liqter5dfKIBzQSgOw78XnOrE9ISmgrIWFCb1OLS1tCYWpbgF6++GP22QpcqeYYS6h
         E50T0E/Fv6s1Fw9X86vXo1jS1wkvFKFaAqj38YlK2MQB6yn9paOy7/f/LuB0AveG/k1E
         6Bxg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796278371; x=1796883171;
        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=Kd2cNHplcgbkAvOIeDwt9SaUxa+AdzoDGnZ38psuJHE=;
        b=VScXNUw0fkc8MbcJLEZQ/dX7ax8s0VvWkdndYEDYP/c8LpRcbiGbL/x8oIqtkCHb0s
         xEppMk+8QGzARyWMHXqqHMeb0gFkNwbXW5mB7ID44G9BBvraRQdrMjQ1+H17KJ9bRanM
         lZwqOjRxODRCUrFPBld7moBI0j1uDPq36dhzq3JSDjQ0LI5Cxx3RL6wEaPjh4oOQ9jXK
         5ifgyy9PR5aZDleyywVOi1Yt9Z+rUJ+NIPQpRidHguIKgOSRNQ0cJUKOywCfIbPYe10C
         hU3BZIB2REFMZ8HZ4HfCRDUxzkv86pVtv38Of8izelbxN/SSui6u7of9UCMsNLWk5hnx
         nkVA==
X-Gm-Message-State: APuU4Z+X9kG588ef4cF2Fl3IxIcP0f3229dZ5AId26xlfNYkb9Ob3KXg
	DYJK6Ff/TtgZCewlwNX8aOIcOlnADWJVWZ05y4kKSnHExvixFk4xVw3lbarBliO0
X-Gm-Gg: AZFdTZfpAcWHvQppUEnI3UixQjUIICKXKlIla1jvxoXKFmlfWbcKGjeyev1tdMacYJA
	zD8BuYaRVHxnFxK/AUYQJOrkyuckt+3UvfUM+XuFU9qZZxnx/HlMpJBqf73G43XfL+2OdhDLBSJ
	JCcgd9cfYpXBaz5gubE7+VCCJkwDP//cAT4uXS2W/G/vRB4f8QkzpCFSeJTzJ7TAP/CjcycOBoe
	dIJET60nDj2ys95dNSs8o+SdfnxWm0JUAWLS8D8db4QOcOhagKxjtdJvrYmGR/FvUnKQ3smMPMZ
	O/9mMUm6d4Zs3pjpYkWhKUlT1GegqO1AH98SkL+wUCmifYVm4e0B78eTj0fu9KwtNuJbA1B7E8E
	lSVw9p4ghrNEj5WX540uxkBBz3wBd54YiCQhFKzQfM8UfNlBmrrHBYXyZrGfsa8XjWxEpJAzJIy
	p7p/H0IDCy4DShPJBv+zjhpuHALl8W44wOLxp2PVxZ+BktTBrpNov/yNpk5DBGM0zTNfwzuj5ea
	6+jLBH8qEUVSeeLvQO8Vz7UlG3ES4lxSyzbxx9bSeklE9FoKhYi/7gNPiBgB5R4fcrplAg9S6Q9
	aAKcvlKJi35sIYj/1fprzM/Sg3CsntgUCr+I7qijoU3z
X-Received: by 2002:a05:7300:c7c4:b0:376:13e5:e8fe with SMTP id 5a478bee46e88-3856c4b839cmr39579718eec.3.1796278370974;
        Wed, 02 Dec 2026 22:12:50 -0800 (PST)
X-Received: from localhost.localdomain ([2406:7400:51:44ac:c2b6:f9ff:fe77:10a0])
        by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38730405b61sm12074437eec.24.2026.12.02.22.12.43
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 02 Dec 2026 22:12:50 -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,
	Amaan Cheval <amaan.cheval@gmail.com>,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.49.0
X-In-Reply-To: <20261203061215.487858-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