Article View: linux.kernel.netdev
Article #21793Re: [PATCH net v2 2/5] vmxnet3: keep the previous XDP program when attaching fails
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 13:26
Date: Tue, 24 Nov 2026 13:26
171 lines
14147 bytes
14147 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 (1) · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The new err_restore path in vmxnet3_xdp_set()
(drivers/net/vmxnet3/vmxnet3_xdp.c:100-109) puts old_bpf_prog back…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the
err_restore path added here only restores software state:…
--
vmxnet3: keep the previous XDP program when attaching fails
This patch changes vmxnet3_xdp_set() so the old program's reference is
released only after the device has been reactivated. If
vmxnet3_rq_create_all() or vmxnet3_activate_dev() fails, the new
err_restore path puts the old program back in adapter->xdp_bpf_prog and
restores the redirect-target feature.
> diff --git a/drivers/net/vmxnet3/vmxnet3_xdp.c b/drivers/net/vmxnet3/vmxnet3_xdp.c
> index 5f470499e6002..45259b236ebd7 100644
> --- a/drivers/net/vmxnet3/vmxnet3_xdp.c
> +++ b/drivers/net/vmxnet3/vmxnet3_xdp.c
[ ... ]
> @@ -84,17 +82,31 @@ vmxnet3_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf,
> if (err) {
> NL_SET_ERR_MSG_MOD(extack,
> "failed to re-create rx queues for XDP.");
> - return -EOPNOTSUPP;
> + goto err_restore;
> }
> err = vmxnet3_activate_dev(adapter);
> if (err) {
> NL_SET_ERR_MSG_MOD(extack,
> "failed to activate device for XDP.");
> - return -EOPNOTSUPP;
> + goto err_restore;
> }
> clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state);
>
> +out:
> + if (old_bpf_prog)
> + bpf_prog_put(old_bpf_prog);
> return 0;
> +
> +err_restore:
> + /* On error the core drops its reference to the new program and
> + * keeps the old one attached: the driver must keep the old one.
> + */
> + vmxnet3_xdp_exchange_program(adapter, old_bpf_prog);
[Severity: High]
The comment says the core keeps the old program attached on error. Does
that hold for every caller of ndo_bpf?
An XDP link detach goes through bpf_xdp_link_release() or
bpf_xdp_link_detach(), then dev_xdp_detach_link(). That function ignores
the driver's return value:
net/core/dev.c:dev_xdp_detach_link() {
...
bpf_op = dev_xdp_bpf_op(dev, mode);
WARN_ON(dev_xdp_install(dev, mode, bpf_op, NULL, 0, NULL));
dev_xdp_set_link(dev, mode, NULL);
return 0;
}
On that path, vmxnet3_xdp_set() is called with new_bpf_prog == NULL and
old_bpf_prog == P, so need_update is true on a running device.
Suppose vmxnet3_rq_create_all() or vmxnet3_activate_dev() fails. Then
err_restore puts P back into adapter->xdp_bpf_prog and keeps the
reference. The core, however, has already cleared its record of the
program.
What releases that reference afterwards? vmxnet3 has no other
bpf_prog_put(). At unregister, dev_xdp_uninstall() skips modes that have
no program in the core:
prog = dev_xdp_prog(dev, mode);
if (!prog)
continue;
So ndo_bpf is never called again, and P and its maps stay pinned until
another program is attached.
Can P also keep running on received traffic? QUIESCED stays set, so a
later vmxnet3_close() skips quiesce. On the next open,
vmxnet3_open()->vmxnet3_activate_dev()->vmxnet3_rq_init() would see
vmxnet3_xdp_enabled() and run P, while ip link shows no XDP program.
Before this patch, the driver dropped P and left xdp_bpf_prog NULL on
this path, which matched the core's forced detach.
This looks unchanged later in the series. The later commit "vmxnet3:
keep the XDP program across device resets" does not touch err_restore.
Should a call with new_bpf_prog == NULL always leave the driver without
the program and without its reference, even when it fails?
> + if (old_bpf_prog)
> + xdp_features_set_redirect_target(netdev, false);
> + else
> + xdp_features_clear_redirect_target(netdev);
> + return -EOPNOTSUPP;
[Severity: High]
This is a pre-existing issue, not one introduced by this patch, but
err_restore only restores software state.
By the time err_restore runs, the following has already happened:
- vmxnet3_quiesce_dev() has disabled NAPI on every rx queue, freed the
IRQs and set QUIESCED.
- vmxnet3_reset_dev() has reset the device.
- The rx rings have been destroyed. If vmxnet3_rq_create_all() is what
failed, its err_out path destroys them a second time.
The function then returns with netif_running() still true. The interface
stays up with no RX or TX. The restored program does not actually run
until the interface is taken down and brought back up.
vmxnet3_change_mtu() runs the same sequence and closes the device when
these steps fail:
out:
clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state);
if (err)
vmxnet3_force_close(adapter);
Can later operations misbehave on an interface left in this state?
vmxnet3_suspend() sees netif_running() and calls napi_disable() on NAPI
instances that are already disabled:
for (i = 0; i < adapter->num_rx_queues; i++)
napi_disable(&adapter->rx_queue[i].napi);
That would loop forever in napi_disable_locked() and hang system suspend.
There is also a failure after vmxnet3_rq_create_all() fails.
vmxnet3_resume() and a pending vmxnet3_reset_work() both call
vmxnet3_activate_dev() without re-creating the rings. vmxnet3_rq_init()
would then write through rq->buf_info[0][i] while buf_info[0] is NULL.
vmxnet3_reset_work() can already be waiting at this point. It sets
RESETTING before rtnl_lock(), so it can be queued (by tx_timeout or a
TQERR/RQERR event) and wait for RTNL while vmxnet3_xdp_set() runs.
vmxnet3_xdp_set() never sets RESETTING itself.
Should vmxnet3_xdp_set() call vmxnet3_force_close() on these failures,
as vmxnet3_change_mtu() does?
> }
>
> /* This is the main xdp call used by kernel to set/unset eBPF program. */
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123124855.1021-1-filzador%40gmail.com
Technical Details
Message-ID:
<179552678713.3135.6451619234057473485@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370379-linux-kernel-netdev=dewy.ruReferences:
<20261123124855.1021-3-filzador@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370379-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 2/5] vmxnet3: keep the previous XDP program when attaching fails Date: Tue, 24 Nov 2026 13:26:27 +0000 Organization: Usenet Network Message-ID: <179552678713.3135.6451619234057473485@kernel.org> References: <20261123124855.1021-3-filzador@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4143751"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:6s3WYX78S31Fuu+YXzlcUybyVYA= sha256:DkJMxeCplUX+o3bxv0dGFmX371R+gdhwNjReDI9Q0HQ= sha1:ID6lWxxoZL3N4MTG3Ea+1fmaaM8= sha256:A4Y4mKW5n0+4taVbz1ibWP8XmqDiHpay7OwTHztyi5s= 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 23C1B125E18; Tue, 24 Nov 2026 16:26:48 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org 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 S1TUHpk7BogU; Tue, 24 Nov 2026 16:26:44 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370379-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id A99BE125E16; Tue, 24 Nov 2026 16:26:33 +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 250622A9F5; Tue, 24 Nov 2026 13:26:31 +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=1795526790; b=yrZu2cbEJw++5YpZy1tW7ECNH1NBAlO2+iLoTAv0fURdbk3kUqL+Lb8AT1MkJvsOZyxb jF1sZWEKWr9+jq2VTufoD2M8IIX0IrQ/Pjy1YD3liKH6fTgZW7kmyQYJebu7NovsBde7W IMZNV+Vc70pXMphC+L0pEqn2ArEhiDXYhqFSMvLA4r0CtbxNnHYL9Q6EARP4NoQjWKLmV 2zHMY8WflYCIgIVEd0LlFxKW0mubm+p8JRzuWDN/jQp/wNRQP9m/704wkIg7O63XRTTDc mjWrgxJyjBlNaLOKyA37waFz3mqlHVhmpT50mSa7jpTv8SaUWngcsTcHxzDrpieAyBg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795526790; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=+iD7n72HFOyZmZK5XExAtuSfPQKnaovwWr876cE3qyI=; b=GHpYI88IsrjUwO8FvKR94P1JPCay4qyR9BAQGdUomO0+q+w6UtpqQzWpSDWYi20X4kif C2kUd7nVl8QfD9dbhg4LcerIlP1OUDkWx17SsKUKy0jb2lMqWvROvsvItyYMhgbjmij8d n32oRV3R9V01QlIcbSkAhprtsVzSMzH8O7Y4B7IgaMI9uBNpHpyi/STLchffoILT7qAkf xPCTI95AWxd1gZDgMRoRp0mu7n/OsUyU2yIZWe91sSJ57GMUCrTo8XssnpzE8P8WGWdNg HV7xndHLyctC1yk0/mNPnHCFFAKVOzawyjYdLVaExS0TkZa18AeaZxpjsvLGgQKobXA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="gbEj/tdd"; 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 EC686606A334; Tue, 24 Nov 2026 13:26:29 +0000 (UTC) X-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=gbEj/tdd X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795526789; b=IRBSSbOy4gJtHu/ET2pDjqZHfndF7GUu+pnZmfiZL6kqmGlB8Rpr9H3uhQ4nwg3gKrxO bvB/cZBTb4BZZxSD4vvGsCnOPkkGvXlMr3L+Oqt32iUe3YeWI2bBIpDUq61UpQW4I1sdQ FHNBfBCHKiNL5jz/0fw8VqJRZLfTuubHtW7Q5OowvT/bCqHaRdZdvPZzYF/D59uYPEweD 9nGTIUi5MauB6ZILE4CqSSfoVHd88V/o5fHGwi4V8EzS3daDi2tPTohwRFOsEpSjz7csF jfc21eWr7K5+I39eQF89q2WBKQmpIf+/kXKwLouPtFjRfPJSFpatz1fFFvnMTr314IA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795526789; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=+iD7n72HFOyZmZK5XExAtuSfPQKnaovwWr876cE3qyI=; b=D1ylVZUrVi0hbjgjLo2ov1fpCciNVKx4omaKoN8QmnQqiwCRMUEFCsQS/bvEO9qvkABJ 1nmpBCO6pRLnEIrbTVYBO0RsABudjZp4dZ7CtN1ccI+PJ3tlY8YK1K1PLlND32FN1mFqQ amjUYEaxLxiEVAo2CpFvcMIK5xc1DpCxV/R96rHp5csBuUevxphRABJzKchLMtzgyQAA8 SwG+QOVUiHQ2p12zanxImF1RlQ89nBGMVhZjmYhkwDm3+ovQ+HE6S3UqpCLPqXmS81oyk eZB9hFDasFjqRZHsBEoo+NdyybYVmSd53nfrDllNN/QyhTVEHHjRWaA8en1EA4XgZKA== X-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="gbEj/tdd"; arc=none smtp.remote-ip=100.103.45.18 X-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 192AC606A31E; Tue, 24 Nov 2026 13:26:28 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3BC31F000C4; Tue, 24 Nov 2026 13:26:27 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795526788; bh=+iD7n72HFOyZmZK5XExAtuSfPQKnaovwWr876cE3qyI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=gbEj/tddu9/KzK9pc5AjqNXjxcTmpeMeGVEjHNaX1jtWJDhSBHdrocH2vY9PN9ZuH LsXsAxTza7Xq7VS2UaUJtqOMdProtgDfjvtD6OG0qJKImXysYGJZkxGJoI+uwen1H8 wQSbkRfocpQSPQWU/W3gJZdCKBdUFvsfK98iPHm3k3UGOdTyifzhwauOYm8/GmVfdS SqlfCJk3JXQT8txKlnFmAjT/aCmh28hbImBHXu3LY5jXo9BqTrUT5HcEOM02w/u2Q8 Ubbl3sWMUG3Wi+t5W5Oq9iJC7i27J8NnW1idyhqBJfRaSH2SsqWtlNdYFwZM8dG/Xu 0HxwtjRSQvzkw== X-Cc: ronak.doshi@broadcom.com, bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, bpf@vger.kernel.org, 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, u9012063@gmail.com X-In-Reply-To: <20261123124855.1021-3-filzador@gmail.com> X-sashiko-severity: High 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