Article View: linux.kernel.netdev
Article #24087Re: [PATCH net v3 2/5] vmxnet3: fix the error path of XDP program setup
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 08:27
Date: Sun, 29 Nov 2026 08:27
142 lines
13017 bytes
13017 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 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_close path in vmxnet3_xdp_set()
(drivers/net/vmxnet3/vmxnet3_xdp.c:121-129) can deadlock RTNL against…
--
vmxnet3: fix the error path of XDP program setup
This commit reworks the error handling in vmxnet3_xdp_set(). A failed
attach now drops the new program and restarts the device without XDP, and
a failed detach completes the detach. If the device cannot be restarted,
the interface is closed with dev_close().
> diff --git a/drivers/net/vmxnet3/vmxnet3_xdp.c b/drivers/net/vmxnet3/vmxnet3_xdp.c
> index 5f470499e6002..a57866753d0fb 100644
> --- a/drivers/net/vmxnet3/vmxnet3_xdp.c
> +++ b/drivers/net/vmxnet3/vmxnet3_xdp.c
[ ... ]
> @@ -55,46 +72,61 @@ vmxnet3_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf,
[ ... ]
> + vmxnet3_quiesce_dev(adapter);
> vmxnet3_xdp_exchange_program(adapter, new_bpf_prog);
[ ... ]
> + err = vmxnet3_xdp_restart_dev(adapter);
> + if (err && new_bpf_prog) {
> + /* Attach failed (old_bpf_prog is NULL here): the core drops
> + * its reference to the new program and keeps nothing
> + * attached. Bring the device back up without XDP.
> + */
> + NL_SET_ERR_MSG_MOD(extack, "failed to restart device for XDP");
> + vmxnet3_xdp_exchange_program(adapter, NULL);
> + if (vmxnet3_xdp_restart_dev(adapter))
> + goto err_close;
> + return err;
> }
> - err = vmxnet3_activate_dev(adapter);
> if (err) {
> - NL_SET_ERR_MSG_MOD(extack,
> - "failed to activate device for XDP.");
> - return -EOPNOTSUPP;
> + /* Detach failed. The core may ignore an error here (XDP link
> + * release), so complete the detach on a closed device.
> + */
> + netdev_err(netdev, "XDP removal failed to restart, closing\n");
> + goto err_close;
> }
> clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state);
[ ... ]
> +err_close:
> + /* The device is left quiesced, with IRQs freed and NAPI disabled,
> + * as vmxnet3_close() expects after a quiesce: close the interface.
> + * vmxnet3_force_close() would quiesce it and free the IRQs again.
> + */
> + dev_close(netdev);
[Severity: High]
Can this dev_close() call deadlock RTNL against vmxnet3_reset_work()?
vmxnet3_xdp_set() runs as ndo_bpf with RTNL held and never takes
VMXNET3_STATE_BIT_RESETTING. dev_close() ends up in vmxnet3_close(), which
waits for that bit with no timeout:
drivers/net/vmxnet3/vmxnet3_drv.c:vmxnet3_close() {
...
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state))
usleep_range(1000, 2000);
...
}
vmxnet3_reset_work() takes the bit first and RTNL second:
drivers/net/vmxnet3/vmxnet3_drv.c:vmxnet3_reset_work() {
...
if (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state))
return;
/* if the device is closed, we must leave it alone */
rtnl_lock();
...
}
reset_work can be queued by a tx timeout (vmxnet3_tx_timeout()) or a
device error event (vmxnet3_process_events()) while an XDP attach or detach
holds RTNL. If that happens, the sequence could be:
reset_work vmxnet3_xdp_set() (RTNL held)
test_and_set_bit(RESETTING)
rtnl_lock() <- blocks
vmxnet3_quiesce_dev()
vmxnet3_xdp_restart_dev() fails
dev_close()
vmxnet3_close()
spins on RESETTING
The RTNL holder then waits for a bit that only the RTNL waiter can clear.
Both the failed detach path and the failed second restart on the attach
path reach err_close.
Before this patch these failure paths returned -EOPNOTSUPP without calling
dev_close(), so reset_work would eventually get RTNL and run. The commit
message lists "a pending vmxnet3_reset_work() can then hang or crash" as
one of the hazards being fixed. A hang still looks reachable through the
new dev_close() call.
vmxnet3_force_close() guards against this case:
/*
* we must clear VMXNET3_STATE_BIT_RESETTING, otherwise
* vmxnet3_close() will deadlock.
*/
BUG_ON(test_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state));
The err_close comment explains why dev_close() is used instead of
vmxnet3_force_close() in terms of IRQ and NAPI state. It does not cover who
owns RESETTING.
The RESETTING-before-RTNL ordering in vmxnet3_reset_work() is older than
this patch and also affects a plain ifdown, but this patch adds a new path
into it. Would taking rtnl_lock() before test_and_set_bit() in
vmxnet3_reset_work() be a reasonable complementary fix?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125075255.1517-1-filzador%40gmail.com
Technical Details
Message-ID:
<179594087397.3146.5891626181063918087@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373415-linux-kernel-netdev=dewy.ruReferences:
<20261125075255.1517-3-filzador@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373415-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v3 2/5] vmxnet3: fix the error path of XDP program setup Date: Sun, 29 Nov 2026 08:27:53 +0000 Organization: Usenet Network Message-ID: <179594087397.3146.5891626181063918087@kernel.org> References: <20261125075255.1517-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="1132872"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Q/8uVPlwjG4nOIs4ycrCASHOrVI= sha256:/nPJOYOXWpwSJF5sTpAv7FIsRung2pRbkVenNsjfJp4= sha1:S4mzupOPrZTjDfXOiQDjPmMrnqc= sha256:wFqeoKIibDu9Q+ueyIh+2eocn0LiZj2mXdfqnfWBDmM= 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 3A05E125F97; Sun, 29 Nov 2026 11:28:21 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.5 X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[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 Rhn5y1XyVuMo; Sun, 29 Nov 2026 11:28:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373415-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 31F95125F96; Sun, 29 Nov 2026 11:28:04 +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 E814524D8E; Sun, 29 Nov 2026 08:28:01 +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=1795940881; b=XWDZb93TxgvL/fQBvgpKimwnOMPzwsRtwk1QTet/owo2JzOYNwrI3ncoMGEHAdwmebYq q4kkE6EU6a9UyvGS5rZzpcXSyQHSPzF32QfYqbaM21OVMgPUPGpJAFLAhQXrwLRkIkqP+ 5KXsrMQao+bJN8NdiowbKzMkBkqR9mG5X8wtXKUWc4ktcYyj24imHoZSEns1m7yzz7bJn QTYCr9uz89n+uyJPzjAs0RuWhoqHNVEikmQojTkCoyVlTkXFf6+RpqKb/Y21zrwpxWsf8 TGdH+b6DYMPKaCh7TNozUkSEXhlsAz/xDKPFprKtraJfMporY4tEQpKgm0a8Yl28xGA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795940881; 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=VgE0VLztb9OlLcXE1deHh0FqwpShzqmJWxCljADG9f4=; b=txcTq7L+LG6juweeeyrEHXjfBr2isCEAX7E1TYo9jYG1mIZcFX/bis2hYZJnyPMbTzm0 5rgo8y5nRlSUngpyVlV8knmFJkBq7/cULRpt3ceAApRFbXwgdW0pBNdAkI026ttiokNSc y08K4KJz2ya2fjwEWmixdrCvV7/Po9Zxi+d3azQzuwtnSFhK4hazTMZUfiDZFlgdI6skj TKTaG4l8nVi0kdde7qEzJYRur18dsfYaetrWoFUMLK1/Yev3wbK8LyNEvCfUKGy2tcXys Cy2Q8ngyRdPGCaceBOq5bzO1YkLoSdzeiluhgHomUwohr2/LkQdQA7zQVQjIDdqt9yw== 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=cXGXNvE1; 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 AB1FB606A32C; Sun, 29 Nov 2026 08:28:01 +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=cXGXNvE1 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=1795940875; b=H2vOamQOYq5hBqUHcK+022TD6Gb/Em0e41ovZSDSlwAWOMlmAWubQuQD24lKYrOcyV8d qRtwT0sStvjbMq6VYaXc51RAQ91hepwHYOUWre40+9F5UgkG6w2Ed3dZLS3XaXry2z/zp iJSbjj57Z3yCRpuHZx+2t9Sw9knF5UO+uLcmhfh/uZg0vlysgzQYmsSwhzGLZusSOywNh QI+IUtbwLi+Z6h+1siHvajoYhryttbH08jmIz6Pdo35I4iMwpblB5AEO8vDwiTssTBmA7 Gy98SiAO0eCUClXaJENJHFRuuUCrEKvHWlQ3S3unlGRqqNI0oI3e6sHnDxXHq1Hn/Wg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795940875; 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=VgE0VLztb9OlLcXE1deHh0FqwpShzqmJWxCljADG9f4=; b=Gs+jbHeNypuYNrkHQjNaZJmLAGzA4jF7pTsFx07PLwBJ9tXEWk2V7Rmf0G/Jqr3NQtCw p8zXXsNoZXv09tyYyBgzU3KA9/7Sqys0d+LR8+6UKlDIIHTpueueq1rhfSxpovQvWzwHm vy9Q8bjE6RP3raNZaQYUZnCXcHXfmxLeey3nij7bzO4rUan/UUTovjMqAfICQAEWvJTjk 4yJ0Uzt0dLQs7LDKxRl4fHpUckZ78h7K0fUyVmQ58Gk0wuhxab5+7N+jVfoN06adr/0SB Q1wFJXhD6bCKntoYEt9UdqYwP51IebqkMdr6gcLs6Wb+KXAIvSOsTvV4ba2+uZquyoQ== 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=cXGXNvE1; 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 C68BA606A31C; Sun, 29 Nov 2026 08:27:55 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 703841F000C1; Sun, 29 Nov 2026 08:27:54 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795940875; bh=VgE0VLztb9OlLcXE1deHh0FqwpShzqmJWxCljADG9f4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=cXGXNvE14U/nc2NuBQImYZugN+fFQ7bWlnp+1NYPjE1sWGL0ghrzK0BpFphK8pi9Z PBi3kCxREFhk7sZZ8Gkcb4mWhVMTE5N1UI0fmN/++r3ANuR/BLbY/PVPmP+NK0Ln7l 1oIbtqz7yn9UiICc6lFuXU4+ipkE2QuH1Fq91HmLj1/zxHn6jBMdtdHHF3P8pUDJou 9TXT2rEwaPxEMqAQTKGbJ+q+FPVXsR1IrcKPqj7lWFDdh/fMPaaB1ilJ68+ZJ443z2 S4tf+vWkbgoFgu13R2Ro2vE4x/uHm/CHftcebLLL+YnaEjopm6PhsM5a9VcUKujnfT hdLDPa39uijOA== 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: <20261125075255.1517-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