* [PATCH net v2 0/2] gve, xsk: fix XDP removal after a config change and an uninitialized extack
@ 2026-12-04 6:28 Amaan Cheval
2026-12-04 6:28 ` [PATCH net v2 1/2] gve: do not verify the XDP configuration on program or pool removal Amaan Cheval
2026-12-04 6:28 ` [PATCH net v2 2/2] xsk: initialize the struct netdev_bpf passed to ndo_bpf Amaan Cheval
0 siblings, 2 replies; 4+ messages in thread
From: Amaan Cheval @ 2026-12-04 6:28 UTC (permalink / raw)
To: netdev
Cc: joshwash, hramamurthy, andrew+netdev, davem, edumazet, kuba,
pabeni, ast, daniel, hawk, john.fastabend, sdf, bpf, willemb,
jeroendb, pkaligineedi, nktgrg, jordanrhee, przemyslaw.kitszel,
debarghyak, treapking, magnus.karlsson, maciej.fijalkowski, horms,
michal.kubiak, anthony.l.nguyen, aleksander.lobakin, Amaan Cheval
gve checks that the device configuration supports XDP on every ndo_bpf
call, including the ones that remove a program or disable an AF_XDP
zero-copy pool. Once the MTU has been raised past the XDP limit, removal
is refused, which the core does not expect: netlink removal fails, and a
bpf_link release leaves the program running in the driver.
Patch 1 runs the check only when a program is installed or a pool is
enabled. The bug was reproduced and the fix tested on gVNIC in GQI-QPL
mode (GCE n2-standard-4) on net and, as a backport, on Debian 13's
6.12.117, and in DQO-RDA mode (c3-standard-4) on net; reproduce.sh is at
https://github.com/AmaanC/sticky-xdp
The GQI-QPL reproduce.sh run on net was repeated with the two patches of
this version applied. The DQO-RDA and pool disable results are from v1's
kernel, which had patch 1 and v1's gve change to the pool path; that
change did not touch the removal paths. The 6.12.117 backport had patch
1 alone. In all of the above, net is at
commit ef3e21c61baa ("net/tcp-ao: fix reset key lookup for IPv4
segments on IPv6 listeners"), the base of this series.
Patch 2 fixes a separate problem that gve hits on the line patch 1
moves: the XSK core passes drivers a struct netdev_bpf whose extack is
not initialized, and gve and idpf read it. It is latent with
CONFIG_INIT_STACK_ALL_ZERO and was reproduced on gve on a kernel built
with CONFIG_INIT_STACK_ALL_PATTERN.
Other drivers avoid the first problem by running their checks only when
a program is installed (mlx5, ice, veth), and by refusing an MTU change
that an attached program cannot handle (those three, and i40e, ixgbe,
igc). gve already refuses HW-GRO, header split and RX buffer size
changes, and queue count changes that XDP cannot use, while a program is
attached, but not an MTU change, and those guards do not cover a
zero-copy pool that was enabled without a program: raising the queue
counts then makes the pool disable fail in the same way. This series
makes gve run its check only on install and pool enable, so that
removal no longer depends on the configuration passing the XDP check.
Not changed by this series: gve still lets the MTU be raised past the
XDP limit while a program is attached, and the GQI receive path runs
the program only on frames that fit one buffer, so larger frames would
reach the stack without it. That is a separate problem.
A removal can also still fail if gve cannot rebuild its queues in
gve_adjust_config(), reached from gve_set_xdp(); that takes an
allocation or device failure, not a configuration change, and is not
addressed here.
Also not changed, found by reading the code during review of this
series and not reproduced: gve_xsk_pool_disable() unmaps the pool
before it stops the queue, so a receive poll that is still running can
use a pool whose device pointer has been cleared. That needs a separate
fix.
That problem and the one patch 2 fixes were found with the help of an
AI coding assistant, used interactively to read the driver and the XDP
core, write the reproducers and run the tests; details are in each
patch.
v2:
- Patch 2 now initializes the struct in the XSK core, in xp_assign_dev()
and xp_disable_drv_zc(), and replaces v1's gve-only change (Maciej).
- Patch 1 is unchanged.
v1: https://lore.kernel.org/netdev/20261203061215.487858-1-amaan.cheval@gmail.com/
Amaan Cheval (2):
gve: do not verify the XDP configuration on program or pool removal
xsk: initialize the struct netdev_bpf passed to ndo_bpf
drivers/net/ethernet/google/gve/gve_main.c | 22 ++++++++++++++++------
net/xdp/xsk_buff_pool.c | 4 ++--
2 files changed, 18 insertions(+), 8 deletions(-)
base-commit: ef3e21c61baa74e39a49b75318bd4541562ec43f
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH net v2 1/2] gve: do not verify the XDP configuration on program or pool removal
2026-12-04 6:28 [PATCH net v2 0/2] gve, xsk: fix XDP removal after a config change and an uninitialized extack Amaan Cheval
@ 2026-12-04 6:28 ` Amaan Cheval
2026-12-04 6:28 ` [PATCH net v2 2/2] xsk: initialize the struct netdev_bpf passed to ndo_bpf Amaan Cheval
1 sibling, 0 replies; 4+ messages in thread
From: Amaan Cheval @ 2026-12-04 6:28 UTC (permalink / raw)
To: netdev
Cc: joshwash, hramamurthy, andrew+netdev, davem, edumazet, kuba,
pabeni, ast, daniel, hawk, john.fastabend, sdf, bpf, willemb,
jeroendb, pkaligineedi, nktgrg, jordanrhee, przemyslaw.kitszel,
debarghyak, treapking, magnus.karlsson, maciej.fijalkowski, horms,
michal.kubiak, anthony.l.nguyen, aleksander.lobakin, Amaan Cheval,
stable
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
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net v2 2/2] xsk: initialize the struct netdev_bpf passed to ndo_bpf
2026-12-04 6:28 [PATCH net v2 0/2] gve, xsk: fix XDP removal after a config change and an uninitialized extack Amaan Cheval
2026-12-04 6:28 ` [PATCH net v2 1/2] gve: do not verify the XDP configuration on program or pool removal Amaan Cheval
@ 2026-12-04 6:28 ` Amaan Cheval
2026-12-04 18:07 ` Maciej Fijalkowski
1 sibling, 1 reply; 4+ messages in thread
From: Amaan Cheval @ 2026-12-04 6:28 UTC (permalink / raw)
To: netdev
Cc: joshwash, hramamurthy, andrew+netdev, davem, edumazet, kuba,
pabeni, ast, daniel, hawk, john.fastabend, sdf, bpf, willemb,
jeroendb, pkaligineedi, nktgrg, jordanrhee, przemyslaw.kitszel,
debarghyak, treapking, magnus.karlsson, maciej.fijalkowski, horms,
michal.kubiak, anthony.l.nguyen, aleksander.lobakin, Amaan Cheval,
stable
xp_assign_dev() and xp_disable_drv_zc() declare a struct netdev_bpf on
the stack, set command, xsk.pool and xsk.queue_id, and pass it to the
driver's ndo_bpf. Nothing else in the struct is initialized. That
includes extack, which belongs to the XDP_SETUP_PROG member of the
union and lies past the end of the xsk member, so a driver that reads
xdp->extack on this path gets whatever was on the stack.
gve and idpf read it. Since commit 091a3b6ff2b9 ("gve: Use extack to
log xdp config verification errors") gve_xdp() passes xdp->extack to
gve_verify_xdp_configuration() on the pool path, and that function
stores an error message through it whenever the configuration is
refused, for example when a zero-copy socket is bound while the RX and
TX queue counts do not allow XDP. Since commit 3d57b2c00f09 ("idpf: add
XSk pool initialization") idpf_xsk_pool_setup() passes it to
NL_SET_ERR_MSG_FMT_MOD() on its error paths. With
CONFIG_INIT_STACK_ALL_ZERO the pointer is NULL and the message is
skipped; otherwise the driver writes to wherever the uninitialized
pointer points.
Initialize the struct in both functions, so that extack is NULL on this
path for every driver. dev_xdp_install() already clears the struct it
passes to ndo_bpf with memset(), and the BPF offload code uses an empty
initializer.
This was discovered by an AI code review agent reading gve_xdp() while
preparing "gve: do not verify the XDP configuration on program or pool
removal". It was reproduced on gve, with that fix applied, 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"), built with
CONFIG_INIT_STACK_ALL_PATTERN, by binding a zero-copy AF_XDP socket at
the default queue counts and MTU 1460 with repro/xsk/xsk_trigger.c from
the Link below:
# ./xsk_trigger eth0 0
Oops: general protection fault, probably for non-canonical address 0xfefefefefefefefe: 0000 [#1] SMP NOPTI
RIP: 0010:gve_verify_xdp_configuration.cold+0x1d/0x2e [gve]
Call Trace:
gve_xdp+0x47/0x4d0 [gve]
xp_assign_dev+0x2c8/0x350
xsk_bind+0x1ba/0x4e0
With this patch the same bind is refused with -EINVAL and no fault.
The idpf case was found by reading the code and was not run.
Link: https://github.com/AmaanC/sticky-xdp
Fixes: 3d57b2c00f09 ("idpf: add XSk pool initialization")
Fixes: 091a3b6ff2b9 ("gve: Use extack to log xdp config verification errors")
Cc: stable@vger.kernel.org
Signed-off-by: Amaan Cheval <amaan.cheval@gmail.com>
---
v2: new; replaces "gve: do not pass extack to the XDP check on XSK pool
setup" from v1, as Maciej asked.
net/xdp/xsk_buff_pool.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index 5ec092f7cb6f..ac2a188b2839 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -144,7 +144,7 @@ EXPORT_SYMBOL(xp_fill_cb);
static void xp_disable_drv_zc(struct xsk_buff_pool *pool)
{
- struct netdev_bpf bpf;
+ struct netdev_bpf bpf = {};
int err;
ASSERT_RTNL();
@@ -169,7 +169,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
u8 umem_flags = pool->umem->flags;
bool mbuf = flags & XDP_USE_SG;
bool force_zc, force_copy;
- struct netdev_bpf bpf;
+ struct netdev_bpf bpf = {};
u32 frame_size;
int err = 0;
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net v2 2/2] xsk: initialize the struct netdev_bpf passed to ndo_bpf
2026-12-04 6:28 ` [PATCH net v2 2/2] xsk: initialize the struct netdev_bpf passed to ndo_bpf Amaan Cheval
@ 2026-12-04 18:07 ` Maciej Fijalkowski
0 siblings, 0 replies; 4+ messages in thread
From: Maciej Fijalkowski @ 2026-12-04 18:07 UTC (permalink / raw)
To: Amaan Cheval
Cc: netdev, joshwash, hramamurthy, andrew+netdev, davem, edumazet,
kuba, pabeni, ast, daniel, hawk, john.fastabend, sdf, bpf,
willemb, jeroendb, pkaligineedi, nktgrg, jordanrhee,
przemyslaw.kitszel, debarghyak, treapking, magnus.karlsson, horms,
michal.kubiak, anthony.l.nguyen, aleksander.lobakin, stable
On Fri, Dec 04, 2026 at 11:58:57AM +0530, Amaan Cheval wrote:
> xp_assign_dev() and xp_disable_drv_zc() declare a struct netdev_bpf on
> the stack, set command, xsk.pool and xsk.queue_id, and pass it to the
> driver's ndo_bpf. Nothing else in the struct is initialized. That
> includes extack, which belongs to the XDP_SETUP_PROG member of the
> union and lies past the end of the xsk member, so a driver that reads
> xdp->extack on this path gets whatever was on the stack.
>
> gve and idpf read it. Since commit 091a3b6ff2b9 ("gve: Use extack to
> log xdp config verification errors") gve_xdp() passes xdp->extack to
> gve_verify_xdp_configuration() on the pool path, and that function
> stores an error message through it whenever the configuration is
> refused, for example when a zero-copy socket is bound while the RX and
> TX queue counts do not allow XDP. Since commit 3d57b2c00f09 ("idpf: add
> XSk pool initialization") idpf_xsk_pool_setup() passes it to
> NL_SET_ERR_MSG_FMT_MOD() on its error paths. With
> CONFIG_INIT_STACK_ALL_ZERO the pointer is NULL and the message is
> skipped; otherwise the driver writes to wherever the uninitialized
> pointer points.
>
> Initialize the struct in both functions, so that extack is NULL on this
> path for every driver. dev_xdp_install() already clears the struct it
> passes to ndo_bpf with memset(), and the BPF offload code uses an empty
> initializer.
>
> This was discovered by an AI code review agent reading gve_xdp() while
> preparing "gve: do not verify the XDP configuration on program or pool
> removal". It was reproduced on gve, with that fix applied, 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"), built with
> CONFIG_INIT_STACK_ALL_PATTERN, by binding a zero-copy AF_XDP socket at
> the default queue counts and MTU 1460 with repro/xsk/xsk_trigger.c from
> the Link below:
>
> # ./xsk_trigger eth0 0
>
> Oops: general protection fault, probably for non-canonical address 0xfefefefefefefefe: 0000 [#1] SMP NOPTI
> RIP: 0010:gve_verify_xdp_configuration.cold+0x1d/0x2e [gve]
> Call Trace:
> gve_xdp+0x47/0x4d0 [gve]
> xp_assign_dev+0x2c8/0x350
> xsk_bind+0x1ba/0x4e0
>
> With this patch the same bind is refused with -EINVAL and no fault.
> The idpf case was found by reading the code and was not run.
>
> Link: https://github.com/AmaanC/sticky-xdp
> Fixes: 3d57b2c00f09 ("idpf: add XSk pool initialization")
> Fixes: 091a3b6ff2b9 ("gve: Use extack to log xdp config verification errors")
> Cc: stable@vger.kernel.org
> Signed-off-by: Amaan Cheval <amaan.cheval@gmail.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> ---
> v2: new; replaces "gve: do not pass extack to the XDP check on XSK pool
> setup" from v1, as Maciej asked.
>
> net/xdp/xsk_buff_pool.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
> index 5ec092f7cb6f..ac2a188b2839 100644
> --- a/net/xdp/xsk_buff_pool.c
> +++ b/net/xdp/xsk_buff_pool.c
> @@ -144,7 +144,7 @@ EXPORT_SYMBOL(xp_fill_cb);
>
> static void xp_disable_drv_zc(struct xsk_buff_pool *pool)
> {
> - struct netdev_bpf bpf;
> + struct netdev_bpf bpf = {};
> int err;
>
> ASSERT_RTNL();
> @@ -169,7 +169,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
> u8 umem_flags = pool->umem->flags;
> bool mbuf = flags & XDP_USE_SG;
> bool force_zc, force_copy;
> - struct netdev_bpf bpf;
> + struct netdev_bpf bpf = {};
> u32 frame_size;
> int err = 0;
>
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-04 18:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 6:28 [PATCH net v2 0/2] gve, xsk: fix XDP removal after a config change and an uninitialized extack Amaan Cheval
2026-12-04 6:28 ` [PATCH net v2 1/2] gve: do not verify the XDP configuration on program or pool removal Amaan Cheval
2026-12-04 6:28 ` [PATCH net v2 2/2] xsk: initialize the struct netdev_bpf passed to ndo_bpf Amaan Cheval
2026-12-04 18:07 ` Maciej Fijalkowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox