From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 703841F000C1; Sun, 29 Nov 2026 08:27:54 +0000 (UTC) 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== Subject: Re: [PATCH net v3 2/5] vmxnet3: fix the error path of XDP program setup From: netdev-bot+sashiko@kernel.org To: filzador@gmail.com 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 Date: Sun, 29 Nov 2026 08:27:53 +0000 Message-ID: <179594087397.3146.5891626181063918087@kernel.org> In-Reply-To: <20261125075255.1517-3-filzador@gmail.com> References: <20261125075255.1517-3-filzador@gmail.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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