netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf-next v2] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_get_and_ing_cmd
@ 2019-08-19 13:22 wenxu
  2019-08-26  8:38 ` Pablo Neira Ayuso
  2019-09-02  6:14 ` wenxu
  0 siblings, 2 replies; 5+ messages in thread
From: wenxu @ 2019-08-19 13:22 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_get_and_ing_cmd 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>
---
 net/netfilter/nf_tables_offload.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
index b95e27b..5431741 100644
--- a/net/netfilter/nf_tables_offload.c
+++ b/net/netfilter/nf_tables_offload.c
@@ -363,11 +363,12 @@ void nft_indr_block_get_and_ing_cmd(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)) {
 				struct nft_base_chain *basechain;
 
@@ -382,4 +383,5 @@ void nft_indr_block_get_and_ing_cmd(struct net_device *dev,
 			}
 		}
 	}
+	mutex_unlock(&net->nft.commit_mutex);
 }
-- 
1.8.3.1


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

* Re: [PATCH nf-next v2] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_get_and_ing_cmd
  2019-08-19 13:22 [PATCH nf-next v2] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_get_and_ing_cmd wenxu
@ 2019-08-26  8:38 ` Pablo Neira Ayuso
  2019-08-26 13:55   ` wenxu
  2019-09-02  6:14 ` wenxu
  1 sibling, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2019-08-26  8:38 UTC (permalink / raw)
  To: wenxu; +Cc: fw, netfilter-devel

On Mon, Aug 19, 2019 at 09:22:32PM +0800, wenxu@ucloud.cn wrote:
> From: wenxu <wenxu@ucloud.cn>
> 
> The flow_block_ing_cmd() needs to call blocking functions while iterating
> block_ing_cb_list, nft_indr_block_get_and_ing_cmd is in the cb_list,
> So it is the incorrect rcu case. To fix it just traverse the list under
> the commit mutex.

The flow_indr_block_call() is called from a path that already holds
this lock.

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

* Re: [PATCH nf-next v2] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_get_and_ing_cmd
  2019-08-26  8:38 ` Pablo Neira Ayuso
@ 2019-08-26 13:55   ` wenxu
  0 siblings, 0 replies; 5+ messages in thread
From: wenxu @ 2019-08-26 13:55 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: fw, netfilter-devel


在 2019/8/26 16:38, Pablo Neira Ayuso 写道:
> On Mon, Aug 19, 2019 at 09:22:32PM +0800, wenxu@ucloud.cn wrote:
>> From: wenxu <wenxu@ucloud.cn>
>>
>> The flow_block_ing_cmd() needs to call blocking functions while iterating
>> block_ing_cb_list, nft_indr_block_get_and_ing_cmd is in the cb_list,
>> So it is the incorrect rcu case. To fix it just traverse the list under
>> the commit mutex.
> The flow_indr_block_call() is called from a path that already holds
> this lock.

The flow_indr_block_call already hodls this lock. But the flow_block_ing_cmd is not called

by flow_indr_block_call. It is called by offloaded driver with unregister event for indr_dev.

>

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

* Re: [PATCH nf-next v2] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_get_and_ing_cmd
  2019-08-19 13:22 [PATCH nf-next v2] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_get_and_ing_cmd wenxu
  2019-08-26  8:38 ` Pablo Neira Ayuso
@ 2019-09-02  6:14 ` wenxu
  2019-09-02 21:12   ` Pablo Neira Ayuso
  1 sibling, 1 reply; 5+ messages in thread
From: wenxu @ 2019-09-02  6:14 UTC (permalink / raw)
  To: pablo, fw; +Cc: netfilter-devel

Hi pablo,


any other questions about this patch?


BR

wenxu

On 8/19/2019 9:22 PM, wenxu@ucloud.cn wrote:
> From: wenxu <wenxu@ucloud.cn>
>
> The flow_block_ing_cmd() needs to call blocking functions while iterating
> block_ing_cb_list, nft_indr_block_get_and_ing_cmd 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>
> ---
>  net/netfilter/nf_tables_offload.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
> index b95e27b..5431741 100644
> --- a/net/netfilter/nf_tables_offload.c
> +++ b/net/netfilter/nf_tables_offload.c
> @@ -363,11 +363,12 @@ void nft_indr_block_get_and_ing_cmd(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)) {
>  				struct nft_base_chain *basechain;
>  
> @@ -382,4 +383,5 @@ void nft_indr_block_get_and_ing_cmd(struct net_device *dev,
>  			}
>  		}
>  	}
> +	mutex_unlock(&net->nft.commit_mutex);
>  }

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

* Re: [PATCH nf-next v2] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_get_and_ing_cmd
  2019-09-02  6:14 ` wenxu
@ 2019-09-02 21:12   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-02 21:12 UTC (permalink / raw)
  To: wenxu; +Cc: fw, netfilter-devel

On Mon, Sep 02, 2019 at 02:14:54PM +0800, wenxu wrote:
> Hi pablo,
> 
> any other questions about this patch?

Please, rebase:

https://patchwork.ozlabs.org/patch/1156728/
https://patchwork.ozlabs.org/patch/1156729/

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

end of thread, other threads:[~2019-09-02 21:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 13:22 [PATCH nf-next v2] netfilter: nf_table_offload: Fix the incorrect rcu usage in nft_indr_block_get_and_ing_cmd wenxu
2019-08-26  8:38 ` Pablo Neira Ayuso
2019-08-26 13:55   ` wenxu
2019-09-02  6:14 ` wenxu
2019-09-02 21:12   ` Pablo Neira Ayuso

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).