Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BF153B9611; Mon, 23 Mar 2026 15:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774279316; cv=none; b=e0eDGBYPJ0690xKTvrVyvbakEz3QIGl7cRW3PSk4jieMTzbuGWwsr9EWbWmat9g+ZJJIt48KTT3jiD1TdSUtuKp43ucS0MXWhxE5OaqWfd9nXnLvLs/d83+W9tgvRNbjvvAqs3qN7M2N4mcIiSHMrcTrb3tbCPJ7YmMPPafl874= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774279316; c=relaxed/simple; bh=PdVVWFCLb38mUXPgG4rVheOeSssuffIAYeD2+yMMWUY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qIZmJmURErk6NcPu4Wr61DtmNJCj3cXFAi0l9bJvmAg/eR3k4R1KD8KQvNgVwa5v4+DpTemNPvwHWhwiI8vhd5ROg8sEA24GN1nDfItr4fMQ4mK8hIDvcN3vOHNMcXtj0/MITXJUgYICRYJakQwDR/26UMdGFm8Vd40APdY7B8E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iYrzEmDa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="iYrzEmDa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CCD8C4CEF7; Mon, 23 Mar 2026 15:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774279315; bh=PdVVWFCLb38mUXPgG4rVheOeSssuffIAYeD2+yMMWUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iYrzEmDadzDfo+Kfok8G8WCPPSVT+2X4DR0mvABP26Ln3JulakqN4xMGHDJZp2+9O EE0DP06QzJ3OD8/3BerxZoTYtRKMaBPWCRWCsKKLTjf4y90e/NOpQj2IQ//X7OKiB0 rrRLTbTXg6ZSwI/YXC65i6hrd2IYK94Nm9gfxOK4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yiming Qian , Pablo Neira Ayuso , Florian Westphal , Sasha Levin Subject: [PATCH 6.6 544/567] netfilter: nf_tables: release flowtable after rcu grace period on error Date: Mon, 23 Mar 2026 14:47:44 +0100 Message-ID: <20260323134547.465879828@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134533.749096647@linuxfoundation.org> References: <20260323134533.749096647@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pablo Neira Ayuso [ Upstream commit d73f4b53aaaea4c95f245e491aa5eeb8a21874ce ] Call synchronize_rcu() after unregistering the hooks from error path, since a hook that already refers to this flowtable can be already registered, exposing this flowtable to packet path and nfnetlink_hook control plane. This error path is rare, it should only happen by reaching the maximum number hooks or by failing to set up to hardware offload, just call synchronize_rcu(). There is a check for already used device hooks by different flowtable that could result in EEXIST at this late stage. The hook parser can be updated to perform this check earlier to this error path really becomes rarely exercised. Uncovered by KASAN reported as use-after-free from nfnetlink_hook path when dumping hooks. Fixes: 3b49e2e94e6e ("netfilter: nf_tables: add flow table netlink frontend") Reported-by: Yiming Qian Signed-off-by: Pablo Neira Ayuso Signed-off-by: Florian Westphal Signed-off-by: Sasha Levin --- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 41614e897ec8f..a3f7c7ae55b8c 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -8772,6 +8772,7 @@ static int nf_tables_newflowtable(struct sk_buff *skb, return 0; err_flowtable_hooks: + synchronize_rcu(); nft_trans_destroy(trans); err_flowtable_trans: nft_hooks_destroy(&flowtable->hook_list); -- 2.51.0