From mboxrd@z Thu Jan 1 00:00:00 1970 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 4BB29823DD; Mon, 23 Mar 2026 14:10:32 +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=1774275032; cv=none; b=KKox7X2UVS/BD4btzf8byR/Kh6R5RN59Wih2H9al7uMYz7cNNcD9bkHthervErj3Ku/1aMPzV9L0XdXG0EX69frFBAoq9+vIvZpNU7LJO2//gHslRnf0lz2zrB+Lhn+cLYQ6GnXS4jW8I83UDc9jvzIMakzflUsbALyoyq0rlKY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774275032; c=relaxed/simple; bh=czMRImCI0YTC5LVXJg+LgwKCXKQxI412QI334XW4quk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lNv1AQ7QyNKICtcVlwCmFKRJ2xfEFUC9AZ6yZ+fZjI9AhIJBvIHy6vfj8v7eiieFU+I3ZDOrnFi1e0fdW3hFOh7nRSjO5HrcKY1reVJAQ2XGri8zXYsIvDVFu9NGepUZ7SdyvYk+NQqekyj2vK7r28Fq6dWDnm200ZGNkqK62TY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FLM7eWwb; 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="FLM7eWwb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C445CC4CEF7; Mon, 23 Mar 2026 14:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774275032; bh=czMRImCI0YTC5LVXJg+LgwKCXKQxI412QI334XW4quk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FLM7eWwbuSfzgKbFmbxjQOzFGnx8N/8/5rmjpnA0bZd4d63Xl7vHjE1KuMIChqG+w Npz3apCXGsg1osJgiOtyXEBRqT98YkHSG0mmkjoZlB5AVfVPtDXQXIVJm3ea1alkl6 20LTEcaNRWQtatHfPmV7fUwqc7YYtsup3uNv6LQU= 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.18 172/212] netfilter: nf_tables: release flowtable after rcu grace period on error Date: Mon, 23 Mar 2026 14:46:33 +0100 Message-ID: <20260323134509.206081955@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134503.770111826@linuxfoundation.org> References: <20260323134503.770111826@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 0992869b33b35..a6a7fe216396d 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -9369,6 +9369,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