From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.180 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== 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== 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 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 ; Fri, 4 Dec 2026 17:14:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2744F606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-8b60552bebaso11363667b3.3 for ; Fri, 04 Dec 2026 09:14:16 -0800 (PST) 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) 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) From: "Brien Oberstein" To: "'Arnau Valls'" , Cc: , , , , , References: <20261103222243.445644-1-vallsfustearnau@gmail.com> In-Reply-To: <20261103222243.445644-1-vallsfustearnau@gmail.com> Subject: RE: [PATCH nf] netfilter: flowtable: remove hw flows before unbinding the flow block Date: Fri, 4 Dec 2026 12:14:14 -0500 Message-ID: <151801dd8412$e3a96470$aafc2d50$@gmail.com> 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQG21iL+zJQTO7IKYslaHJYnX0HiX7eaeBXQ Content-Language: en-us 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.