Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8A2DA4078CE; Sat, 12 Sep 2026 09:30:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789205436; cv=none; b=Ojna9o5CtgtYbr47FWz3CCyhDkay9D+fngxJi8R35PRTQNJyiFhl9CkuXFfOZANcqM19fSjHUwBbE3mIo7O+EQ0rve8lh49dfp45uwUO3bOo1zg+r1LA91L7DzJ2tEkHT61cTgIbMFhWlLzcAK20VAqhyAntBEZAziKjRZdgRy4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789205436; c=relaxed/simple; bh=c62XadiZl8Nwiq7WIuTIl2HG742bw1+hUteYeDleNDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yn78nE+RIjNOXDq799jVj3rS2nUwXAyTy1X7mKSjGIQwG7Xumowzy5BjgvvxCX6mHyiM2nXD29uWfV2y9NK6NX5CEdCy4xUKt9923ziDqIpgms0fHWFH0ie9sY09tGmYv2v1n9MUL3ipau05xGbAjLQQ32exdM5XcvYrB+tj4tg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YfcKk4ho; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="YfcKk4ho" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F8A61F000FF; Sat, 12 Sep 2026 09:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789205435; bh=ApiDR6UiJmO1nrYL/CrMmZDzyJoGDNxrxDeXb0RlS5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YfcKk4hotl50ZF5IYMLWZaVlkrCy4nChGDSy2i0BFZwRureY3hMQwfHwQNRhTrlsz gLhBridkggn6RaXhh3UnBcLNjflL0r8xOgNmIAAE1oWJc1l3VhR9cow9NmhnXO9BMP ZkEbWuBZJg0kAC2yETbiYAKA+NW+cOX+ExYHMuf4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 7.2 1786/1815] netfilter: nf_tables: move hardware offload step after building the chain blob Date: Sat, 12 Sep 2026 08:58:56 +0200 Message-ID: <20260912065730.961092067@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065648.999753832@linuxfoundation.org> References: <20260912065648.999753832@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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pablo Neira Ayuso [ Upstream commit b1881d362e1924b66f6016c3efd28807032b41bf ] Allocate the chain blob before the ruleset offload to reduce chances of entering an inconsistent state where the offloaded ruleset in the nic and the software ruleset differ. Fixes: c9626a2cbdb2 ("netfilter: nf_tables: add hardware offload support") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_tables_api.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 3a7c8f7a63041..2ee49aaf172af 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -10941,10 +10941,6 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) return -EAGAIN; } - err = nft_flow_rule_offload_commit(net); - if (err < 0) - return err; - /* 1. Allocate space for next generation rules_gen_X[] */ list_for_each_entry_safe(trans, next, &nft_net->commit_list, list) { struct nft_table *table = trans->table; @@ -10969,6 +10965,16 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) } } + /* must be last, so audit and chain blob set up does not leave hardware + * in consistent state. + */ + err = nft_flow_rule_offload_commit(net); + if (err < 0) { + nf_tables_commit_chain_prepare_cancel(net); + nf_tables_commit_audit_free(&adl); + return err; + } + /* step 2. Make rules_gen_X visible to packet path */ list_for_each_entry(table, &nft_net->tables, list) { list_for_each_entry(chain, &table->chains, list) -- 2.53.0