🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Binbin Deng Tue, 20 Oct 2026 02:26
[PATCH v1] net: atlantic: Unregister before clearing RXNFC rules
#5259
Author: Binbin Deng
Date: Tue, 20 Oct 2026 02:26
48 lines
10334 bytes
aq_pci_remove() clears the driver's RXNFC rule list before unregistering
the netdevice.  Until unregister_netdev() returns, ethtool operations can
still call aq_get_rxnfc_rule(), aq_get_rxnfc_all_rules(),
aq_add_rxnfc_rule(), or aq_del_rxnfc_rule().  Those paths traverse the
same unlocked hlist that aq_clear_rxnfc_all_rules() is mutating and
freeing.

The race is reachable by issuing RXNFC ethtool commands concurrently with
PCI device removal or driver unbind.  A reader can dereference a node that
has just been freed, and two writers can corrupt the list or free the same
rule more than once, causing KASAN reports, list corruption, or a kernel
panic.

Reverse the removal order: unregister the netdevice first, then clear the
RXNFC rules.  After unregister_netdev() returns, ethtool can no longer
enter the driver, while the PCI device is still available for the
rule-clearing routine to issue hardware commands.

Found during a static-analysis-assisted audit: candidate sites were
surfaced by a Coccinelle rule, and the reader/writer paths were
confirmed by LLM-assisted (GLM-5.3) code inspection.  The issue was
not observed at runtime; it is identified by code inspection only.

Fixes: 8d0bcb012f57 ("net: aquantia: add infrastructure for ntuple rules")
Assisted-by: GLM-5.3 coccinelle
Signed-off-by: Binbin Deng <18983559317@163.com>
---
 drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
index 005d6ef4fc36..881727c3aa0a 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
@@ -344,9 +344,9 @@ static void aq_pci_remove(struct pci_dev *pdev)
 	struct aq_nic_s *self = pci_get_drvdata(pdev);
 
 	if (self->ndev) {
-		aq_clear_rxnfc_all_rules(self);
 		if (self->ndev->reg_state == NETREG_REGISTERED)
 			unregister_netdev(self->ndev);
+		aq_clear_rxnfc_all_rules(self);
 
 #if IS_ENABLED(CONFIG_MACSEC)
 		aq_macsec_free(self);
-- 
2.43.0
Re: [PATCH v1] net: atlantic: Unregister before clearing RXNFC rules
#5669
Author: Jakub Kicinski
Date: Tue, 20 Oct 2026 19:36
7 lines
7834 bytes
On Tue, 20 Oct 2026 10:26:30 +0800 Binbin Deng wrote:
> From: Binbin Deng <18983559317@163.com>

Please slow down, you're clearly sending untested LLM output.
We don't want to see more than 8 outstanding networking patches
at any given time from you.
Re: [PATCH v1] net: atlantic: Unregister before clearing RXNFC rules
#7693
Author: patchwork-bot+netdevbpf
Date: Tue, 27 Oct 2026 00:20
24 lines
8637 bytes
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 20 Oct 2026 10:26:30 +0800 you wrote:
> aq_pci_remove() clears the driver's RXNFC rule list before unregistering
> the netdevice.  Until unregister_netdev() returns, ethtool operations can
> still call aq_get_rxnfc_rule(), aq_get_rxnfc_all_rules(),
> aq_add_rxnfc_rule(), or aq_del_rxnfc_rule().  Those paths traverse the
> same unlocked hlist that aq_clear_rxnfc_all_rules() is mutating and
> freeing.
> 
> [...]

Here is the summary with links:
  - [v1] net: atlantic: Unregister before clearing RXNFC rules
    https://git.kernel.org/netdev/net/c/13b364c765e6

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads