From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796404457; b=K7kFhncRCVt9kTjiHmbm579ftiucsOLgbiahTLTvpiBoq4aDP5gfBNrQZT2UGl+UfGi8 DydmMI07yhTvcYmyjf76b33ReHHWOB0GlP+NOGLhWYjqGe6V4r7rZAVrnJoN3qJZ/KY97 EaTlGG1BNBQWSRSxiuzHwYV4vvEVm45hL+x2yafxPirwL7brk8SPv8ZkA68r7k6+iNArE nbD9XYKfU6yePh9zLQFLLELfqUkUI75a8AWYEoBZxSsPPaVCuNJOZEeED8kaTpGXOv9Je ETh+E8jtlYkS9hK6P+pbKz1AMxZa6gKcDysM3iyngEq9v1MutTzFLMU695NdyRNM/mg== 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=pO9a/Wz0v+D3KKGsKgurhv5cDHNJuVs8DEBMI8txGQ8naVSHTzJSWdo4GSn4yXAtm10G UbDIF7t30z2+XrzWLU/OGUTJWszwZSjmulVGetVawQBvbxBJh+g46LxAG1btSdnUcog9t qoAaWtUkx8ZoWdJ916qbBfNt2het766gybThwAi8HQNwXJoeAVyEtA7fnPJg6rHigh+CM ogXglPIONU84ZJSS9+fvq3/pUt1qNOnNFloda8AK+E/YgERtYYy9u7sKabFxkp+ybH1z2 P7dVK58CDosJHYl7R3hgr/Bnoy9Ly1S47Ya9YgUD7sHZ5ZJrOWvaHH/8h0cdCcieC6A== 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.177 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 3332B606A32F for ; Fri, 4 Dec 2026 17:14:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3332B606A32F 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, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Nw3cEJQZ Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-8b30cbfa628so8028827b3.0 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=nyYAE2glQMhXxZZJ0wnzsTvQlJiNBGrMSnw2vxlIQSCgGn2tXFVCTduF+yiggCw2Rf zAJivwj87RHf08H/vghnQy/VZK3LLdH0f9CDL4coesrXa4B4Zu0ukmew8qBCVteI92Vm cPt3jqr9LlHEWpHAEFrZVI1Bw7yvV82X01KkgIzOy9NZDDPB8ldKuoxNUu9MLEsN7OZa thWgcw5wSLSF8qIu32/hDnHCEpOKgIhl06vPfsKwLD34A8riH5ntAFSx9zKfTz4+6Ls7 vuMswCCrzab7QbAQ0SwKZVetfi8OqI5xFXvUG6gbmQM4XMoR8vNSjtr4wFFfEurUIS8v WGTw== X-Forwarded-Encrypted: i=1; AL+hErG62bC/ExpHXcTmTzNTTUSCNpXityUYuaKEalgcQgdPnEL41gCzHuaRTTc0aejFzqg7IFUUq6w=@vger.kernel.org X-Gm-Message-State: AB4q+uFv//6i37a8gGoU3ZqgQJ0oSdNBK1X1IyginCZPOSrMId+X3DyL JLTRmOj6nwce/x5h6QhUTSZcUwa263PT0q8E52UpfV0cTVCwfcPp3rOi X-Gm-Gg: AZFdTZdtR+CuIFWb6cFNtJEIqF+b9FHcXqsCYnYh1UGL/Zl3rqM3st5/EsXgGM9iomI eKHPsQmdLlsAigG+ozmVQt5cIhY/Ni3j5qaM+W0mPIc8Q8ApXYjgaaHXSjaisrtCyjzRPD1x/nz DUzPNclfbXqbqKKyoCt+BFGGnblCi9BuHyFJQ4h21Y08eEiox+C4OXSNjFdLbTXNAumkmtwXf0R aLtU1b/Pp5p2RJOvnkw8X+IKHe6i3uvB8bvf5lareJFLkWXwnFuAqLDoS2hfcZfw9tUq6C56vd6 UFQZJ+uHTgkSqvk5dx+DCSW8HSbjNf9fyYyriDNj3msmIhwaa6yzqPa/HtRb5MW/k6j4PVWaREG JLO0reSDSWf40JM5VE1eUndLxckMC5eC53hFNodTL5GzDnKZQh4IFG3LmGV0GFHy+ocTkpNz5Oj 4N0EsSCRxW7cRrBklRwq/wepsN0+IVvDIDuIGdgPzI9jASS62rdK2L/93T395+4WFhh+NX22YEv l9CK69kE+Rkj+VD5ROwJ0BJ4+SAlA+SllT/kSKz3Gc5ffRRCkknZHw2UdKYAusTjEKYCY1V1Ogi 5wo+h4lBML9EQV8izrInA+7O9Z3uITamUP6Kb5pi+7w8kSDgWyFj26V6xWdCtavH21/OL7CNvTF ErMpZro8oDgFzH9vcf7SOd4Lf90WKf8DXsTT1RYfx 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: stable@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.