netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf-next v3] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_cb
@ 2019-09-03  3:15 wenxu
  2019-09-03 17:27 ` Pablo Neira Ayuso
  2019-09-03 20:06 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: wenxu @ 2019-09-03  3:15 UTC (permalink / raw)
  To: pablo, fw; +Cc: netfilter-devel

From: wenxu <wenxu@ucloud.cn>

The flow_block_ing_cmd() needs to call blocking functions while iterating
block_ing_cb_list, nft_indr_block_cb is in the cb_list,
So it is the incorrect rcu case. To fix it just traverse the list under
the commit mutex.

Fixes: 9a32669fecfb ("netfilter: nf_tables_offload: support indr block call")
Signed-off-by: wenxu <wenxu@ucloud.cn>
---
v3: rebase to patches 1156728 and 1156729

 net/netfilter/nf_tables_offload.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
index 113ac40..ca9e0cb 100644
--- a/net/netfilter/nf_tables_offload.c
+++ b/net/netfilter/nf_tables_offload.c
@@ -357,11 +357,12 @@ static void nft_indr_block_cb(struct net_device *dev,
 	const struct nft_table *table;
 	const struct nft_chain *chain;
 
-	list_for_each_entry_rcu(table, &net->nft.tables, list) {
+	mutex_lock(&net->nft.commit_mutex);
+	list_for_each_entry(table, &net->nft.tables, list) {
 		if (table->family != NFPROTO_NETDEV)
 			continue;
 
-		list_for_each_entry_rcu(chain, &table->chains, list) {
+		list_for_each_entry(chain, &table->chains, list) {
 			if (!nft_is_base_chain(chain))
 				continue;
 
@@ -370,9 +371,11 @@ static void nft_indr_block_cb(struct net_device *dev,
 				continue;
 
 			nft_indr_block_ing_cmd(dev, basechain, cb, cb_priv, cmd);
+			mutex_unlock(&net->nft.commit_mutex);
 			return;
 		}
 	}
+	mutex_unlock(&net->nft.commit_mutex);
 }
 
 static struct flow_indr_block_ing_entry block_ing_entry = {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-03 23:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03  3:15 [PATCH nf-next v3] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_cb wenxu
2019-09-03 17:27 ` Pablo Neira Ayuso
2019-09-03 20:06 ` Pablo Neira Ayuso
2019-09-03 23:16   ` wenxu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).