lvs-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: shaozhengchao <shaozhengchao@huawei.com>
To: Julian Anastasov <ja@ssi.bg>
Cc: netdev@vger.kernel.org, lvs-devel@vger.kernel.org,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	Simon Horman <horms@verge.net.au>,
	pablo@netfilter.org, weiyongjun1@huawei.com,
	yuehaibing@huawei.com
Subject: Re: [PATCH net] ipvs: fix WARNING in __ip_vs_cleanup_batch()
Date: Mon, 31 Oct 2022 18:46:01 +0800	[thread overview]
Message-ID: <1158a4b3-69ce-e7c6-c4dd-84f66dd8f065@huawei.com> (raw)
In-Reply-To: <a92e1453-aa84-92f-5f6f-de1b7ec5d381@ssi.bg>



On 2022/10/31 18:35, Julian Anastasov wrote:
> 
> 	Hello,
> 
> On Mon, 31 Oct 2022, Zhengchao Shao wrote:
> 
>> During the initialization of ip_vs_conn_net_init(), if file ip_vs_conn
>> or ip_vs_conn_sync fails to be created, the initialization is successful
>> by default. Therefore, the ip_vs_conn or ip_vs_conn_sync file doesn't
>> be found during the remove.
>>
>> The following is the stack information:
>> name 'ip_vs_conn_sync'
>> WARNING: CPU: 3 PID: 9 at fs/proc/generic.c:712
>> remove_proc_entry+0x389/0x460
>> Modules linked in:
>> Workqueue: netns cleanup_net
>> RIP: 0010:remove_proc_entry+0x389/0x460
>> Call Trace:
>> <TASK>
>> __ip_vs_cleanup_batch+0x7d/0x120
>> ops_exit_list+0x125/0x170
>> cleanup_net+0x4ea/0xb00
>> process_one_work+0x9bf/0x1710
>> worker_thread+0x665/0x1080
>> kthread+0x2e4/0x3a0
>> ret_from_fork+0x1f/0x30
>> </TASK>
>>
>> Fixes: 61b1ab4583e2 ("IPVS: netns, add basic init per netns.")
>> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>> ---
>>   net/netfilter/ipvs/ip_vs_conn.c | 20 +++++++++++++++-----
>>   1 file changed, 15 insertions(+), 5 deletions(-)
>>
>> diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
>> index 8c04bb57dd6f..b126bd7df321 100644
>> --- a/net/netfilter/ipvs/ip_vs_conn.c
>> +++ b/net/netfilter/ipvs/ip_vs_conn.c
>> @@ -1447,12 +1447,22 @@ int __net_init ip_vs_conn_net_init(struct netns_ipvs *ipvs)
>>   {
>>   	atomic_set(&ipvs->conn_count, 0);
>>   
>> -	proc_create_net("ip_vs_conn", 0, ipvs->net->proc_net,
>> -			&ip_vs_conn_seq_ops, sizeof(struct ip_vs_iter_state));
>> -	proc_create_net("ip_vs_conn_sync", 0, ipvs->net->proc_net,
>> -			&ip_vs_conn_sync_seq_ops,
>> -			sizeof(struct ip_vs_iter_state));
>> +	if (!proc_create_net("ip_vs_conn", 0, ipvs->net->proc_net,
>> +			     &ip_vs_conn_seq_ops,
>> +			     sizeof(struct ip_vs_iter_state)))
>> +		goto err_conn;
>> +
>> +	if (!proc_create_net("ip_vs_conn_sync", 0, ipvs->net->proc_net,
>> +			     &ip_vs_conn_sync_seq_ops,
>> +			     sizeof(struct ip_vs_iter_state)))
>> +		goto err_conn_sync;
>> +
>>   	return 0;
>> +
>> +err_conn_sync:
>> +	remove_proc_entry("ip_vs_conn", ipvs->net->proc_net);
>> +err_conn:
>> +	return -ENOMEM;
>>   }
>>   
>>   void __net_exit ip_vs_conn_net_cleanup(struct netns_ipvs *ipvs)
>> -- 
>> 2.17.1
> 
> 	Good catch. But can you add some #ifdef CONFIG_PROC_FS
> as done in commit 4bc3c8dc9f5f ("ipvs: fix possible memory leak in
> ip_vs_control_net_init") ? You can also extend it to include
> ifdefs and ENOMEM in ip_vs_app.c:ip_vs_app_net_init(). If you
> prefer, it can be a separate patch.
> 
> Regards
> 
> --
> Julian Anastasov <ja@ssi.bg>
> 

Hi Anastasov:
	Thank you for your reply. I'd like to do it, and I will
send them in v2.

Zhengchao Shao
> 

      reply	other threads:[~2022-10-31 10:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31  6:49 [PATCH net] ipvs: fix WARNING in __ip_vs_cleanup_batch() Zhengchao Shao
2022-10-31 10:35 ` Julian Anastasov
2022-10-31 10:46   ` shaozhengchao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1158a4b3-69ce-e7c6-c4dd-84f66dd8f065@huawei.com \
    --to=shaozhengchao@huawei.com \
    --cc=coreteam@netfilter.org \
    --cc=horms@verge.net.au \
    --cc=ja@ssi.bg \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=weiyongjun1@huawei.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).