Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.70.190.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796131589; b=d3i3nWMvChomF81inj+jhOaBf7GtKaafbo4hNIW4rB/OURBXpapSL3exPfbCEBoc/Yh8 hk6wduaKEpo/+/Nhyg5iiVXe4u01dhWLuma03TF84YFk7kTpbW/Wxscw3YUPyFjP+27Ez NKBwVouOnZN2MCWZO/ioQMq5KA4y5hCvrAnNXTBWkqFAWZ6HDST1g9FsMB89yBmBYsm6T t8vKwg4n83Te3WMvaSJ30f641Lg9gUfDEPOlEvG8jOFvt5fD9FHuy7tleSF6mgXt4rQFk HOrgpQhJc8rx9okEJ/0/ASUvY4VHgZmKrfnx0U0DSIuR8f9Yrdoz6kIf/3Pc5RBh6bA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796131589; h=DMARC-Filter:DKIM-Signature:Received:From:To:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Spam-Status:X-Spam-Checker-Version; bh=Fw310WSY35Phv3MSygJu3ULTgL16fxbgLUNkiRx/NoY=; b=VJADlCKgbyLyP5fPDwAKfHt5baCKuJi37Z2eBbcEZNdcWzvlwZE5rSpOQLPDTG/PtP56 ASJ0OMteEHGnZBS6Oj57Uzvkul8Livnmuf8LEI8Dfjt/7qPQsD7BTwGnvRzif1TOKbbBd A03gcjgcoQrW1yVIdzhOlSnijHsm5yrE2SpH8hBWnzMfhZWFjzdm4D1ZoXABZPvtiCy/H DJ9BuA/1tamkknh42aanMXrWx0AuKZS/el7nVuttGdlcaxBU/khrSuc1liUalxj00aG8b 6KAZrOYDi5BAx1wPvk4K68KBKt/JjXNQwlRuEu5PV47L1gln6Fq4INZaHPI1QPnn8qQ== 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=JLze2VWw; arc=none smtp.remote-ip=217.70.190.124 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 462AE606A31A for ; Tue, 1 Dec 2026 13:26:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 462AE606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org 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=JLze2VWw DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1796131581; bh=Fw310WSY35Phv3MSygJu3ULTgL16fxbgLUNkiRx/NoY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JLze2VWwc8C3XR86oVP/W0CLXYIWvgQuJUnBYrecMo1Tv+QpbQpga75ZXNjIcmkRs U/2fusds8VGwedjEGitibRDYGekkUFxhkRORdECSQMHo+Ayi8n4cKXjFjQDymu+EDb 2RcqiIp+7HPppqJGjjyoDvktFqy60J/2DDfmEoC+prGwbbuCGR6C8rWf6LzYQbw63O pqtNoUmkTiU+9oNujxQT0vRsO0UQN3EfQaZKN6SOB6F9QNW/NR5dKvXJgPS/lss5mV rUPEdsRlKaJle7S0P0ApqAO69jooX+JI3W7RZxAEItnFfxI+2BkwAE0h8sY5H1bV2e S4JRXLh94OAaw== Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id B87656007C for ; Tue, 1 Dec 2026 14:26:21 +0100 (CET) From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Subject: [PATCH nf,v6 3/5] netfilter: nf_tables: flush destroy work from flowtable netdev event handler Date: Tue, 1 Dec 2026 14:26:14 +0100 Message-ID: <20261201132616.1131793-3-pablo@netfilter.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201132616.1131793-1-pablo@netfilter.org> References: <20261201132616.1131793-1-pablo@netfilter.org> X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Fixes: 13210fc63f35 ("netfilter: nf_tables: imbalance in flowtable binding") Signed-off-by: Pablo Neira Ayuso --- v6: no changes 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 70ac5bbe7877..4f48a11aeb9f 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -9933,6 +9933,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