🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24012

[PATCH net 13/14] netfilter: nf_tables: flush destroy work from flowtable netdev event handler

#24012
From: Pablo Neira Ayuso
Date: Sun, 29 Nov 2026 00:07
59 lines
10393 bytes
Sashiko reports that the following race is possible while dismantling
the flowtable with hardware offload:

CPU0                                  CPU1 (kworker)
nf_tables_commit()
  list_del_rcu(&flowtable->list)
  nft_unregister_flowtable_net_hooks()
nf_tables_commit_release()
  schedule_work(&destroy_work)
  mutex_unlock(&commit_mutex)
                                      nf_tables_trans_destroy_work()
                                        synchronize_rcu()
                                        ...
unregister_netdevice()
  nf_tables_flowtable_event()
    /* flowtable not in
     * table->flowtables, ops->dev
     * stays on flowtable->hook_list
     */
  free_netdev(dev)
                                        nf_tables_flowtable_destroy()
                                          nft_flowtable_hooks_destroy()
                                            ...
                                            flowtable->data.type->setup(
                                              ..., ops->dev,
                                              FLOW_BLOCK_UNBIND)
                                              <-- use-after-free

A netdevice event could happen in between the commit and commit_release.
After commit, the flowtable has been removed from the table list,
therefore, it is not reachable by the flowtable netdevice handler so the
hook cannot be unregistered and a stale reference to the netdevice
remains in place, leading to possible UaF from the commit_release path
when accessing the netdevice.

Fix this by flushing the pending destroy work before handling netdevice
events.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 0189375e4063..9ea8789f5664 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -9929,6 +9929,8 @@ static int nf_tables_flowtable_event(struct notifier_block *this,
 	nft_net = nft_pernet(net);
 	mutex_lock(&nft_net->commit_mutex);
 
+	nf_tables_trans_destroy_flush_work(net);
+
 	if (event == NETDEV_CHANGENAME) {
 		if (__nf_tables_flowtable_event(NETDEV_REGISTER, dev, true)) {
 			ret = NOTIFY_BAD;
-- 
2.47.3
Technical Details
Message-ID: <20261129000724.797425-14-pablo@netfilter.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-373310-linux-kernel-netdev=dewy.ru
References: <20261129000724.797425-1-pablo@netfilter.org>

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-373310-linux-kernel-netdev=dewy.ru
From: pablo@netfilter.org (Pablo Neira Ayuso)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 13/14] netfilter: nf_tables: flush destroy work from flowtable netdev event handler
Date: Sun, 29 Nov 2026 01:07:23 +0100
Organization: Usenet Network
Message-ID: <20261129000724.797425-14-pablo@netfilter.org>
References: <20261129000724.797425-1-pablo@netfilter.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1064491"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VPLSDhvhIKVqz5u0cMXEfny4/4Y= sha256:xL/Ig3tsk2W6HnLR/8BNqx/JGyVbM44CEBgyALSbIU0=
	sha1:ZUaBO9CNuVllqUy5poto3Rei4Gw= sha256:Q8e+YSRTk6LnzYMvSi8V8TMjHkqUZoY3kSsxSIta/Hw=
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 33744125F90; Sun, 29 Nov 2026 03:08:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=netfilter.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 3-0eqv3xNtes;
	Sun, 29 Nov 2026 03:08:11 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-373310-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 00E60125F8A; Sun, 29 Nov 2026 03:08:02 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 807A0234A1; Sun, 29 Nov 2026 00:08:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1795910871;
	b=RetfxXAdgGDgF+Gnl4AwjlHHCXE83OlOKE3tuGgFRYHP3+NuvWqQbAqL0Tt06QP7D1A2
	 WtBpqp5t1hYgfz8zEzsNVUwkDLehikyjjIrH6HqtTgV1+OteU48G4ITzg/9jK3Q8rKv43
	 xIcWPLqB2/lm/sDy6v1hlyUHuHsx39DCOH+6Q5zZ9vekZ7E8JYZUEAfldHVfIa4jM8iIT
	 wksylyzk7M4QC2KrtfF6pz3Q9UF4875g5sQDC8Egc7EK20TqnKAboLXrkX8L0/7HoHVv5
	 iLp+R2Mu/cwODkxFwXOjlfZFtbyMgAu5uy+1owByN44a6n5Zc2sk+OfmjjLQYFJY4fA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795910871;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To:
	 Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=kBGiScU/saKNsDrDwB2nVX7HaK1FjhlxMtcUmwuAY0A=;
	b=sumhlSVJ28lzqbVwcUBvlOVRwgnxGoyYqQ1rLK84KuXiNPpFn9OXjRKx7+GKkBIFDLXJ
	 xq+5vfxbSW3aYbhdHaUcMCPcXwvbkeuvf5CHRmlGfUFOZjwpXTccKlyN/AZ2oZJlxwbra
	 Z7F+mahe8tUGtjzqfano+f9jLG5c2TPeZQpqiy9EPVngWHDzHfYhMZaARfxPcfujoDkMB
	 F/y7zcXNmNvpH2ib0/NiUC2PNEov0UaS4F50s82WBHEst1r4j4BAXRdpEhq3TI0txp5qC
	 PHyJPQKV+qj173uqGnsvKvdIY8mfW2RfnveRS1GZ+Zm10oc+omp7VDM2bh8+8czogiA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=jYfRnm0q;
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	arc=fail 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 B62B2606A69B;
	Sun, 29 Nov 2026 00:07:51 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=jYfRnm0q
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795910870;
	b=XKdCLicQMX9upy64HCAqMhOCyQ/3xe9wbiJn5p8bwpLraMSVxr/iJSQGtS9gFrPIFY9B
	 0tCEohJO4bLoW5OWvHSKlIsdgRz7pXVaQZ/F3HRy6WVpydGFI9RvA+mQRZujmP9lVMwwH
	 yiuondgN++C88DXhuwx7SsnGLd+fl1rRLp3odwhi4L2jvg7QRWNpDR/DmQ7tgIEylaMJC
	 ojEjrsG1I4Pd5W5UfQ0i05xLvqxU3lOAbgTRljF5v9glUUMmW3rXGZrzFHOX0fJrejl0G
	 MSLcfyrdngJTqHS91/eTTmhtmY+Anhi9NBhHtYc7bW6O+rz3rWwZOgtf22K5WdZPXgA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795910870;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:X-Spam-Status:X-Spam-Checker-Version;
	bh=kBGiScU/saKNsDrDwB2nVX7HaK1FjhlxMtcUmwuAY0A=;
	b=4HjMPPkdcqpenITfCAoU8raLWFK1XRWn+y1IHAYBrurxqEdcPDYj0UgfnugVn3Vh/U+W
	 FEcsR5JNsfce2EfF5/CLEd7OQbckAPrs/MOA2xhqKl4b9EUFBdF1h3gwxjI8zZcnSepZe
	 q0PaoInBarAaS+St40Lm7zXTbfO1bL4cChiwDaMZDZO0xG5oRfU9AbL/o9kOIdAvY+IVF
	 UQCx8AM9IWquW5EwnlE82TLRPNX9xrv/KfPCl7rLygQDVPqz+hqI5cIyF3ngTTplZMR5U
	 YQJ7O1rTRJ0vuU0WU++0zeujtWQzLhT30a0xX/JjJVL+jEWbFTG/JClI17iUewlZzKg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=netfilter.org;
	spf=pass smtp.mailfrom=netfilter.org;
	dkim=pass header.d=netfilter.org header.i=@netfilter.org header.a=rsa-sha256 header.s=2025 header.b=jYfRnm0q;
	arc=none smtp.remote-ip=217.70.190.124
X-Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124])
	(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 6C66F606A33F;
	Sun, 29 Nov 2026 00:07:50 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6C66F606A33F
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org;
	s=2025; t=1795910868;
	bh=kBGiScU/saKNsDrDwB2nVX7HaK1FjhlxMtcUmwuAY0A=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=jYfRnm0qx+cVHjVuu9aeGvkpkxzTryfFeqmj84aIavqbC5pJQTObK4vbZmFquvWtr
	 CkKGPps4egYZm6hQkFX2rXH/aRdCrRwCKHSLdKwf6B9aKCZrDd0TEJ9fJk4A7VPDUl
	 FnsIsK9M32lMVYSFd9u1pgLsltbGdqA+dD4bWawnpbVxFvHaI4nt6fhxUwV8Emyi/H
	 sJjUzcSMqnr7JQMLvLecspXHbLeMwWZW6sD2FZuWN8UUOQ05LukjxKUdw5C7otCHbZ
	 1x59ZkzuzdlyGU79L2LI6PFZ/XLeFJ6r/Gz8YpHYH8d5Q98eZAVFpVdin3e9RmeoGp
	 lh34N/Cza+NqA==
X-Received: from localhost.localdomain (mail-agni [217.70.190.124])
	by mail.netfilter.org (Postfix) with ESMTPSA id 2503A601B8;
	Sun, 29 Nov 2026 01:07:48 +0100 (CET)
X-Cc: davem@davemloft.net,
	netdev@vger.kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	edumazet@kernel.org,
	horms@kernel.org,
	fw@strlen.de,
	ja@ssi.bg
X-Mailer: git-send-email 2.47.3
X-In-Reply-To: <20261129000724.797425-1-pablo@netfilter.org>
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