Article View: linux.kernel.netdev
Article #27045RE: [PATCH nf] netfilter: flowtable: remove hw flows before unbinding the flow block
From: "Brien Oberstein"
Date: Fri, 04 Dec 2026 17:14
Date: Fri, 04 Dec 2026 17:14
37 lines
13035 bytes
13035 bytes
On Tue, 3 Nov 2026 23:22:43 +0100, Arnau Valls wrote:
> + if (cmd == FLOW_BLOCK_UNBIND) {
> + nf_flow_table_gc_cleanup(flowtable, dev);
> + nf_flow_table_gc_run(flowtable);
> + nf_flow_table_offload_flush(flowtable);
> + }
nf_flow_table_gc_run() here can run concurrently with the flowtable's
gc worker running the same pass. Nothing serializes the two walks, and
nf_flow_offload_gc_step() frees a torn-down flow (a hardware one once
NF_FLOW_HW_DEAD is set) with flow_offload_del(), which has no guard
against the other walk doing the same to the same flow: call_rcu()
twice on its rcu_head, and its route released twice. Outside the
worker, the pass runs only on the nf_flow_table_free() path, after
cancel_delayed_work_sync() has stopped the worker, and
nf_flow_table_gc_cleanup() runs its own pass by flushing the worker.
Running the second pass on the worker avoids it:
if (cmd == FLOW_BLOCK_UNBIND) {
nf_flow_table_gc_cleanup(flowtable, dev);
mod_delayed_work(system_power_efficient_wq,
&flowtable->gc_work, 0);
flush_delayed_work(&flowtable->gc_work);
nf_flow_table_offload_flush(flowtable);
}
Requeueing first makes the flush wait for a pass that starts after the
teardown and offload flush in nf_flow_table_gc_cleanup(), rather than
for one that may already be under way.
This is from reading the code in the nf tree; I haven't seen the double
free happen. Your patch has run on a MediaTek router here for several
weeks, and the change above for a short time so far: in a firewall
reload test with a flow offloaded, both directions are still
invalidated and bound again.
Technical Details
Message-ID:
<151801dd8412$e3a96470$aafc2d50$@gmail.com>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377509-linux-kernel-netdev=dewy.ruReferences:
<20261103222243.445644-1-vallsfustearnau@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377509-linux-kernel-netdev=dewy.ru
From: brienpub@gmail.com ("Brien Oberstein")
Newsgroups: linux.kernel.netdev
Subject: RE: [PATCH nf] netfilter: flowtable: remove hw flows before unbinding the flow block
Date: Fri, 4 Dec 2026 12:14:14 -0500
Organization: Usenet Network
Message-ID: <151801dd8412$e3a96470$aafc2d50$@gmail.com>
References: <20261103222243.445644-1-vallsfustearnau@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="2815684"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xhjfPuqMJH3OYDTE09gh5QyqsdM= sha256:JMmzn2u2rk7wSDU7u6ilkUg0s3Pt4y6zsiPorrb4Zqw=
sha1:pAdleUq6xGm3iZqddB1HD+ztQjo= sha256:ph4UxBPq5690AWQmNG4v5UGdSzV7RiUt9qMBXAuW+cs=
Content-Language: en-us
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 6F9B1117C7C; Fri, 4 Dec 2026 20:14:52 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.297
X-Spam-Status: No, score=-3.297 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
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=gmail.com
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 UUGYkaTKk3vx;
Fri, 4 Dec 2026 20:14:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377509-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 9115A117C0E; Fri, 4 Dec 2026 20:14:36 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id DDE12467BD; Fri, 4 Dec 2026 17:14:23 +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=1796404463;
b=hwe5zNxnYSW9tLv0PuWuYlvt6yy1fXDWFOSIhFLzL2oXQ4N3iUafiKSNMl5/edfrpNks
/uVMnTl2L+Z4fUL87IHN0z78scnk4z9jUkpjzFTXd16tKgYUKUbt70vl3CbUvRmi7DYCR
MEFFYko1CvvAso44r8HeIGv6qAIGOj+Y3E8B9458zlBTG+IM+CZd/YNjmDzkwQPh7ET2J
SiTrpH4nA6joGUYAa1MaQMxR7PSEXLHtR2QkZ/+BP2Ojcm2kskVqwtLMmwDF3g/EYRtO2
3kaom4jqIN4HishcOlI9uJ42v8Z9p9OXTvzMJrVlmg5OVt+hhsRzOCGWUHfIy3czRRg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796404463;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:References:In-Reply-To:Subject:
Date:Message-ID:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:
Content-Language;
bh=9jW+aFUSPFJSYKX1lGXc3Ajg8lj+IB+8L9jdipijTw8=;
b=ydSLRofrN88SOfNII96EhYadLSxu8Du8Bi7VYFviW+1ZUZ2PBByCf+Y7H8G27TBoFdRX
X9JWjsQBVATRENe7KJCQjCZN8A3n6QSI/mcoyAFXXGjX0nLGzu93qVwW9Xws8vrWc52mg
PufPMtBP7edYOo4+FeQ/eysttOkm7FLN+ROWBnFjS/o1repK+V7pEwqFRnDmEdJFBkRmf
tinGaRkqf3YP/rhH8sAer1xvaySoLl1PmbWlPUC4JT0GXeYWDR2aWhAi8LPisLuV7eVJd
5lbSQomksdRlwRstB/4QcBrerr2UjbeR4KjSj4fabDRbqp4FHOGbBrVw7ueIFA2zt2w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Nw3cEJQZ;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 605DF606A338;
Fri, 4 Dec 2026 17:14:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Nw3cEJQZ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.180
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796404457;
b=g3yUDyVZHAMI6ORhu7kQmh1n45uaKiCBNe+Fboklh3va1vUhiQVBmeBfaxWLbG9dt4ux
GcoZCzjpYUe++JzzKZjxNoLOqNXvSN+vkQHxzxhuz2//VFB1R0KIkl40xtgVkUcGVA6LW
9hdAvzHLCIBzg0FzSGW+9Vw37sNxibAaYEzv4x4ZopReUlyhdcxj+7zL10mbpy7i4k/2J
ZAlMEq9WSk3itcNJLdDu23XjCAvyac++sdkX6TX7MaWyB5mANydxx0MxnWcXnOGhXDKsf
lVl58kXuO7q518vx6SOxU/4xtQ68RlA+gIQEYNgCABsrWAEAJhgtKhaGa7xT9l8DssA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796404457;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:References:In-Reply-To:Subject:Date:Message-ID:
MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:
Thread-Index:Content-Language;
bh=9jW+aFUSPFJSYKX1lGXc3Ajg8lj+IB+8L9jdipijTw8=;
b=IuHdP3VJdMd3iYgi1aAh1BQx2aLMwFXfi9yqeEzEIRIV5b6+JBkVYOrFvk8ah3KEX4lU
MwZU9U/BytxblH1izq0AbigHiYLexkmo5Fintc4Vk9wL/uM58Z8tHA2QLDPkSD4GI6vRD
H32JSb7pTjZngHtK834xWXSl8UvqRVW3EAaK7xk66SL4vxFnBOCF3Xaiix2JkMs8Nb6JH
KDSzNPhue+QEIkRLDNNDOLAhZWQ2Apw/zyzF2MkW0XOISEe9eVucHV1BcFCbWl5KhikuW
RmyztWjVDKdwhJB1QHSZJRFHK7VpTCTnog8p1e3P9UlZ8eQxtTMgiMg+2nOJAO+I1xg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Nw3cEJQZ;
arc=none smtp.remote-ip=209.85.128.180
X-Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2744F606A322
for <netdev@vger.kernel.org>; Fri, 4 Dec 2026 17:14:17 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2744F606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-8b60552bebaso11363667b3.3
for <netdev@vger.kernel.org>; Fri, 04 Dec 2026 09:14:16 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796404456; x=1797009256; darn=vger.kernel.org;
h=content-language:thread-index:content-transfer-encoding
:content-type:mime-version:message-id:date:subject:in-reply-to
:references:cc:to:from:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=9jW+aFUSPFJSYKX1lGXc3Ajg8lj+IB+8L9jdipijTw8=;
b=Nw3cEJQZ8h8bYKaZTtNAogRq0wG1pJQcnCKgDNwaTswLYAMnMqi6/Z6NEXjL1z01ji
UpIPmVVgtmwwwaVGmdWcztl9mdIow215NBmkWAsdatJnsjO/g/yoMFt4UNFXihuO7dy5
JKsaxSkIjCs/S7OVzQFsQqPbmnoekAluByoxiL+0b+qQly2gYPbtp1VQY75wfLzG0K+i
cX5OV+jvR8OQ0ELssK4DEwE4yWVut/i+ffYig5l2Yd+5fCKg3LxMh4hdH9LDlAnEnGmv
QDnw1LXxC97F37At9wq+53eGxdB9I/EyGHxaaswecBD+I+IClbJg7CIVuCbvOSrxIb6/
Ue8A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796404456; x=1797009256;
h=content-language:thread-index:content-transfer-encoding
:content-type:mime-version:message-id:date:subject:in-reply-to
:references:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=9jW+aFUSPFJSYKX1lGXc3Ajg8lj+IB+8L9jdipijTw8=;
b=JiIVT04SeCYiEIAVPzssfe8vi2FEpXgCD3gU9VYEZrijo9S4JY2Yie6o37EJ7CdOa4
fHJawq6U+d/vlsSXUC3E3ux6ADRNn5yMHJVDvjLq+ZGvrE+A9GMofJHWYc1NcC49UajJ
4UYL+6EU8cWixmEjRoDXy0NcSayFRJCAn7XDg6wkTtqAy0pSPgTLfKgfjRC8jMPlxEDn
/msuRVhbGE2y8kUcHeD9DhcACF6/UFW44MD0iUtAVLMGUlOPBxbXwKupp1oci4Baz01q
JVu+Zg5OWiQeBJ2DJIXDz1178bOvCmAqJvhil7jO751GMUAR76sC3KFINOHuuPa+S+rz
EsqA==
X-Forwarded-Encrypted: i=1; AL+hErFVjnzUv9kWoQC1YaTmdC2SLPh8Qj5Kyyhjldam6iPMeXBe9FGK2mTzzAw6TI+qI56n4PKcEgs=@vger.kernel.org
X-Gm-Message-State: AB4q+uFwjXBTF2qLe/HcWpVBgMex+WJZQL01bQ2hD8Foe3c/t82eKXwH
63L10kwrU1LJnplqouIAINzl7YqWTALGn5jyRmFDBk/EA+lAiIG/J35v
X-Gm-Gg: AZFdTZeZke3F2qRid2VWHt+QiZ1g2+rGkbtz47Zel51WJw9sFwWx8LKDNkoJEGV7lBR
hEnHFQ+JlIl5rq7fvEGDuOdpkM35oaCA0H0/knbGngFABfvFE/+MSldwNIE8rGLnwy2eBt+iolQ
QSWfB22Z379A3lrmcq+Lqo+0PmaHf0Yj7NCzSS6/PvilgE7veLbLBDK0Ss6F5ZhpJ6wAOOcObu9
ymxlYC/22vf+VYRi0tqN8RfIUfrlq1bRuSSRm3wAW1EOOBYx5waUNyPRZu4CDd9dAgnDdGH38iD
CCBQgBPEDlikGwsBMhDunUaVG+C22ePLhc8Sr6i5grs30cePrBOTK2f+53e/tpSnF/pvxvqNPPV
XKclnmvrHTzS6Vd6Y9BT1KK5xKCw3/fJXHyeUgUITAWpIz6GYy8UiJrW7bJkWAqlL397uHWzUWa
O8A1iXz88TFKxvjxOjsjybj8g64stMcsdvQHpu3NSjLuQv0OkjocT4dA7jpX+GNW0J1rgNhGjuW
JbU5wEgQX7C4Nr/VaKCYq2hGn5HPjRGY9zVo7/Dyyc7Ak97v+4lqlGuuSJEQWPBu0moPiHQ0dRw
6tS1+cnQPkbAM6ns4TKlKLY9dyadw3A4HYGIxhtbPPbf4wobVNR4N7wjgqQqW9fLTtv8QTkinjS
/n+B4mX9f6UTaaev96L8cYHZcA3v5tCicCWaRXEN0
X-Received: by 2002:a05:690c:692:b0:8b5:341:a113 with SMTP id 00721157ae682-8b660e0da81mr13078017b3.64.1796404455882;
Fri, 04 Dec 2026 09:14:15 -0800 (PST)
X-Received: from WIN6DK41G9CSL2 (c-73-46-105-104.hsd1.fl.comcast.net. [73.46.105.104])
by smtp.gmail.com with ESMTPSA id 00721157ae682-8b6604050e5sm12434417b3.1.2026.12.04.09.14.15
(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Fri, 04 Dec 2026 09:14:15 -0800 (PST)
X-Cc: <pablo@netfilter.org>,
<fw@strlen.de>,
<phil@nwl.cc>,
<coreteam@netfilter.org>,
<netdev@vger.kernel.org>,
<stable@vger.kernel.org>
X-In-Reply-To: <20261103222243.445644-1-vallsfustearnau@gmail.com>
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
X-Mailer: Microsoft Outlook 16.0
X-Thread-Index: AQG21iL+zJQTO7IKYslaHJYnX0HiX7eaeBXQ