exit_net checks for objects initialized in net_init hook
Subsystems (10)
cover exit_net checks for objects initialized in net_init hook
This patch set checks that lists initialized in net_init hooks were return to initial state at end of net_exit hooks.
Vasily Averin (21):
exit_net cleanup: geneve sock_list check
ppp: exit_net cleanup checks added
vxlan: exit_net cleanup checks added
netdev: exit_net cleanup check added
nfs4blocklayout: exit_net cleanup check added nfs client: exit_net cleanup check added
fib_notifier: exit_net cleanup check added
fib_rules: exit_net cleanup check added
clusterip: exit_net cleanup check added
xfrm6_tunnel: exit_net cleanup check added
af_key: replace BUG_ON on WARN_ON in net_exit hook
l2tp: exit_net cleanup check added
nf_tables: exit_net cleanup check added
nfnetlink_log: exit_net cleanup check added
nfnetlink_gueue: exit_net cleanup check added
x_tables: exit_net cleanup check added
hashlimit: exit_net cleanup check added
recent: exit_net cleanup check added
packet: exit_net cleanup check added
phonet: exit_net cleanup check added
sunrpc: exit_net cleanup check added
drivers/net/geneve.c | 2 ++ drivers/net/ppp/ppp_generic.c | 4 ++++ drivers/net/vxlan.c | 6 ++++++ fs/nfs/blocklayout/rpc_pipefs.c | 2 ++ fs/nfs/client.c | 4 ++++ net/core/dev.c | 3 +++ net/core/fib_notifier.c | 7 +++++++ net/core/fib_rules.c | 7 +++++++ net/ipv4/netfilter/ipt_CLUSTERIP.c | 2 ++ net/ipv6/xfrm6_tunnel.c | 12 ++++++++++++ net/key/af_key.c | 2 +- net/l2tp/l2tp_core.c | 6 ++++++ net/netfilter/nf_tables_api.c | 9 +++++++++ net/netfilter/nfnetlink_log.c | 7 +++++++ net/netfilter/nfnetlink_queue.c | 8 ++++++++ net/netfilter/x_tables.c | 10 ++++++++++ net/netfilter/xt_hashlimit.c | 4 ++++ net/netfilter/xt_recent.c | 4 ++++ net/packet/af_packet.c | 2 ++ net/phonet/pn_dev.c | 2 ++ net/sunrpc/sunrpc_syms.c | 4 ++++ 21 files changed, 106 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
v2 cover exit_net checks for objects initialized in net_init hook
This patch set checks that lists initialized in net_init hooks were return to initial state at end of net_exit hooks.
I hope such checks allows to detect leaked per-netns objects. Also I hope that all new pernet_operations will inherit such checks too.
I assume that elements added into per-net lists should not live longer than net namespace, and should be deleted from the list. I think exit_net hook is good place for such check.
Recently I've found lost list_entry and enabled timer on stop of net namespace. Then I've reviewed all existing pernet_operations and found that many drivers have such checks already. So I decided to complete this task and add such checks into all affected subsystems.
v2:
- net pointer removed from output
- fixed compilation for phonet driver
Vasily Averin (21):
exit_net cleanup: geneve sock_list check
ppp: exit_net cleanup checks added
vxlan: exit_net cleanup checks added
netdev: exit_net cleanup check added
nfs4blocklayout: exit_net cleanup check added nfs client: exit_net cleanup check added
fib_notifier: exit_net cleanup check added
fib_rules: exit_net cleanup check added
clusterip: exit_net cleanup check added
xfrm6_tunnel: exit_net cleanup check added
af_key: replace BUG_ON on WARN_ON in net_exit hook
l2tp: exit_net cleanup check added
nf_tables: exit_net cleanup check added
nfnetlink_log: exit_net cleanup check added
nfnetlink_gueue: exit_net cleanup check added
x_tables: exit_net cleanup check added
hashlimit: exit_net cleanup check added
recent: exit_net cleanup check added
packet: exit_net cleanup check added
phonet: exit_net cleanup check added
sunrpc: exit_net cleanup check added
drivers/net/geneve.c | 2 ++ drivers/net/ppp/ppp_generic.c | 4 ++++ drivers/net/vxlan.c | 6 ++++++ fs/nfs/blocklayout/rpc_pipefs.c | 2 ++ fs/nfs/client.c | 4 ++++ net/core/dev.c | 3 +++ net/core/fib_notifier.c | 7 +++++++ net/core/fib_rules.c | 7 +++++++ net/ipv4/netfilter/ipt_CLUSTERIP.c | 2 ++ net/ipv6/xfrm6_tunnel.c | 12 ++++++++++++ net/key/af_key.c | 2 +- net/l2tp/l2tp_core.c | 6 ++++++ net/netfilter/nf_tables_api.c | 9 +++++++++ net/netfilter/nfnetlink_log.c | 6 ++++++ net/netfilter/nfnetlink_queue.c | 7 +++++++ net/netfilter/x_tables.c | 10 ++++++++++ net/netfilter/xt_hashlimit.c | 4 ++++ net/netfilter/xt_recent.c | 4 ++++ net/packet/af_packet.c | 2 ++ net/phonet/pn_dev.c | 4 ++++ net/sunrpc/sunrpc_syms.c | 4 ++++ 21 files changed, 106 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
v3 cover exit_net checks for objects initialized in net_init hook
This patch set checks that lists initialized in net_init hooks were return to initial state at end of net_exit hooks.
I hope such checks allows to detect leaked per-netns objects. Also I hope that all new pernet_operations will inherit such checks too.
I assume that elements added into per-net lists should not live longer than net namespace, and should be deleted from the list. I think exit_net hook is good place for such check.
Recently I've found lost list_entry and enabled timer on stop of net namespace. Then I've reviewed all existing pernet_operations and found that many drivers have such checks already. So I decided to complete this task and add such checks into all affected subsystems.
v3:
- use net->ns.inum as net Id
- removed patches for hashlimit and recent,
they handle tables list in exit_net hook.
- added patches for grace and lockd
v2:
- net pointer removed from output
- fixed compilation for phonet driver
Vasily Averin (21):
grace: replace BUG_ON by WARN_ONCE in exit_net hook
lockd: added cleanup checks in exit_net hook exit_net cleanup: geneve sock_list check
ppp: exit_net cleanup checks added
vxlan: exit_net cleanup checks added
netdev: exit_net cleanup check added
nfs4blocklayout: exit_net cleanup check added nfs client: exit_net cleanup check added
fib_notifier: exit_net cleanup check added
fib_rules: exit_net cleanup check added
clusterip: exit_net cleanup check added
xfrm6_tunnel: exit_net cleanup check added
af_key: replace BUG_ON on WARN_ONCE in net_exit hook
l2tp: exit_net cleanup check added
nf_tables: exit_net cleanup check added
nfnetlink_log: exit_net cleanup check added
nfnetlink_gueue: exit_net cleanup check added
x_tables: exit_net cleanup check added
packet: exit_net cleanup check added
phonet: exit_net cleanup check added
sunrpc: exit_net cleanup check added
drivers/net/geneve.c | 3 +++ drivers/net/ppp/ppp_generic.c | 6 ++++++ drivers/net/vxlan.c | 7 +++++++ fs/lockd/svc.c | 11 +++++++++++ fs/nfs/blocklayout/rpc_pipefs.c | 3 +++ fs/nfs/client.c | 4 ++++ fs/nfs_common/grace.c | 4 +++- net/core/dev.c | 4 ++++ net/core/fib_notifier.c | 8 ++++++++ net/core/fib_rules.c | 8 ++++++++ net/ipv4/netfilter/ipt_CLUSTERIP.c | 3 +++ net/ipv6/xfrm6_tunnel.c | 14 ++++++++++++++ net/key/af_key.c | 4 +++- net/l2tp/l2tp_core.c | 7 +++++++ net/netfilter/nf_tables_api.c | 11 +++++++++++ net/netfilter/nfnetlink_log.c | 7 +++++++ net/netfilter/nfnetlink_queue.c | 8 ++++++++ net/netfilter/x_tables.c | 12 ++++++++++++ net/packet/af_packet.c | 2 ++ net/phonet/pn_dev.c | 5 +++++ net/sunrpc/sunrpc_syms.c | 5 +++++ 21 files changed, 134 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
v4 cover exit_net checks for objects initialized in net_init hook
OpenVz kernel team have a long history of fighting against namespace-related bugs, some of them could be excluded by using simple checks described below.
One of typical errors is related to live cycle of namespaces:
usually objects created for some namespace should not live longer than namespace itself.
Such kind of issues can be invisible on usual systems where additional namespaces are not used, because initial namespaces usually lives forever and never destroyed.
However in systems with namespaces it can lead to memory leaks or to use-after-free. Both of them are critical for systems with running containers.
As you knows it's quite hard to find the reason of such issues, especially in rarely-triggered scenarios on production nodes on default kernels without specially enabled debug settings. Any additional hints can be useful here.
This patch set should help to detect some of these issues.
It is based on assumption that objects initialized in init hook of pernet_operations should return to initial state until end of exit hook.
Many drivers and subsystems already have such checks, however I've found number of places where list_empty check would be useful at least as smoke test.
These checks are useful for long-term stable kernels, they allows to detect problems related to incomplete or incorrectly backported patches.
Also this patch set replaces BUG_ON in existing checks:
memory leaks and possible memory corruptions are bad of course, however in many cases they are not fatal
and should not crash production hosts unconditionally.
Changes:
v4:
- excluded grace and lockd patches taken by Bruce Fields
- let's use WARN_ON_ONCE without any extra messages
adobriyan@ is right, output of net Id gives nothing to host admin, and developers in any case will extract information from core dump
- updated description in cover letter
- dropped nfs4blocklayout patch: waitqueue check does not look useful
- patches was reordered to be per-subsystem grouped
- cover letter should be sent to all people included into cc: of any patches
- minor cosmetic changes in some patches
v3:
- use net->ns.inum as net Id
- removed patches for hashlimit and recent,
they handle tables list in exit_net hook.
- added patches for grace and lockd
v2:
- net pointer removed from output
- fixed compilation for phonet driver
Vasily Averin (18):
af_key: replace BUG_ON on WARN_ON in net_exit hook
geneve: exit_net cleanup check added
packet: exit_net cleanup check added
vxlan: exit_net cleanup checks added
netdev: exit_net cleanup check added
fib_notifier: exit_net cleanup check added
fib_rules: exit_net cleanup check added
l2tp: exit_net cleanup check added
clusterip: exit_net cleanup check added
nf_tables: exit_net cleanup check added
nfnetlink_log: exit_net cleanup check added
nfnetlink_gueue: exit_net cleanup check added
x_tables: exit_net cleanup check added
nfs client: exit_net cleanup check added
sunrpc: exit_net cleanup check added
phonet: exit_net cleanup check added
ppp: exit_net cleanup checks added
xfrm6_tunnel: exit_net cleanup check added
drivers/net/geneve.c | 1 + drivers/net/ppp/ppp_generic.c | 2 ++ drivers/net/vxlan.c | 5 +++++ fs/nfs/inode.c | 4 ++++ net/core/dev.c | 2 ++ net/core/fib_notifier.c | 6 ++++++ net/core/fib_rules.c | 6 ++++++ net/ipv4/netfilter/ipt_CLUSTERIP.c | 1 + net/ipv6/xfrm6_tunnel.c | 10 ++++++++++ net/key/af_key.c | 2 +- net/l2tp/l2tp_core.c | 5 +++++ net/netfilter/nf_tables_api.c | 7 +++++++ net/netfilter/nfnetlink_log.c | 5 +++++ net/netfilter/nfnetlink_queue.c | 6 ++++++ net/netfilter/x_tables.c | 10 ++++++++++ net/packet/af_packet.c | 1 + net/phonet/pn_dev.c | 3 +++ net/sunrpc/sunrpc_syms.c | 3 +++ 18 files changed, 78 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
v5 cover netfilter: exit_net checks for objects initialized in net_init hook
OpenVz kernel team have a long history of fighting against namespace-related bugs, some of them could be excluded by using simple checks described below.
One of typical errors is related to live cycle of namespaces:
usually objects created for some namespace should not live longer than namespace itself.
Such kind of issues can be invisible on usual systems where additional namespaces are not used, because initial namespaces usually lives forever and never destroyed.
However in systems with namespaces it can lead to memory leaks or to use-after-free. Both of them are critical for systems with running containers.
As you knows it's quite hard to find the reason of such issues, especially in rarely-triggered scenarios on production nodes on default kernels without specially enabled debug settings. Any additional hints can be useful here.
This patch set should help to detect some of these issues.
It is based on assumption that objects initialized in init hook of pernet_operations should return to initial state until end of exit hook.
Many drivers and subsystems already have such checks, however I've found number of places where list_empty check would be useful at least as smoke test.
These checks are useful for long-term stable kernels, they allows to detect problems related to incomplete or incorrectly backported patches.
Changes:
v5:
- fixed nit pointed by Florian Westphal
- netfilter patches are send separately to netfilter-devel@
v4:
- excluded grace and lockd patches taken by Bruce Fields
- let's use WARN_ON_ONCE without any extra messages
adobriyan@ is right, output of net Id gives nothing to host admin, and developers in any case will extract information from core dump
- updated description in cover letter
- dropped nfs4blocklayout patch: waitqueue check does not look useful
- patches was reordered to be per-subsystem grouped
- cover letter should be sent to all people included into cc: of any patches
- minor cosmetic changes in some patches
v3:
- use net->ns.inum as net Id
- removed patches for hashlimit and recent,
they handle tables list in exit_net hook.
- added patches for grace and lockd
v2:
- net pointer removed from output
- fixed compilation for phonet driver
Vasily Averin (5):
clusterip: exit_net cleanup check added
nf_tables: exit_net cleanup check added
nfnetlink_log: exit_net cleanup check added
nfnetlink_gueue: exit_net cleanup check added
x_tables: exit_net cleanup check added
net/ipv4/netfilter/ipt_CLUSTERIP.c | 1 + net/netfilter/nf_tables_api.c | 7 +++++++ net/netfilter/nfnetlink_log.c | 4 ++++ net/netfilter/nfnetlink_queue.c | 5 +++++ net/netfilter/x_tables.c | 9 +++++++++ 5 files changed, 26 insertions(+)
Signature · 1 line
2.7.4
Florian Westphal
maintainerRe: [PATCH v5 0/5] netfilter: exit_net checks for objects initialized in net_init hook
Quoted 5 lines · Vasily Averin
OpenVz kernel team have a long history of fighting against namespace-related bugs, some of them could be excluded by using simple checks described below.
One of typical errors is related to live cycle of namespaces:
usually objects created for some namespace should not live longer than namespace itself.
These changes look good to me, thank you.
Pablo Neira Ayuso
maintainerRe: [PATCH v5 0/5] netfilter: exit_net checks for objects initialized in net_init hook
In reply to Vasily AverinHi Vasily,
Quoted 2 lines · Vasily Averin
OpenVz kernel team have a long history of fighting against namespace-related bugs, some of them could be excluded by using simple checks described below.
I'm folding this series into one single patch, description looks like this:
netfilter: exit_net cleanup check added
Be sure that lists initialized in net_init hook was return to initial state.
I understand your goal is to make it easier for review, but given this is all part of the same logic change, I just hope you don't mind I have squashed them into one single patch like I did.
Thanks.
PATCH v5 1/5 clusterip: exit_net cleanup check added
In reply to Vasily AverinBe sure that configs list initialized in net_init hook was return to initial state.
--- net/ipv4/netfilter/ipt_CLUSTERIP.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/netfilter/ipt_CLUSTERIP.c +1 -0
@@ -819,6 +819,7 @@ static void clusterip_net_exit(struct net *net) cn->procdir =NULL ;#endif nf_unregister_net_hook (net, &cip_arp_ops); +WARN_ON_ONCE (!list_empty (&cn->configs)); }static struct pernet_operations clusterip_net_ops = {
Signature · 1 line
2.7.4
PATCH v5 2/5 nf_tables: exit_net cleanup check added
In reply to Vasily AverinBe sure that lists initialized in net_init hook were return to initial state.
--- net/netfilter/nf_tables_api.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/netfilter/nf_tables_api.c +7 -0
@@ -5778,6 +5778,12 @@ static int __net_init nf_tables_init_net(struct net *net)return 0 ; } +static void __net_exit nf_tables_exit_net(struct net *net) +{ +WARN_ON_ONCE (!list_empty (&net->nft.af_info)); +WARN_ON_ONCE (!list_empty (&net->nft.commit_list)); +} +int __nft_release_basechain (struct nft_ctx *ctx) {struct nft_rule *rule, *nr;
@@ -5848,6 +5854,7 @@ static void __nft_release_afinfo(struct net *net, struct nft_af_info *afi)static struct pernet_operations nf_tables_net_ops = { .init = nf_tables_init_net, + .exit = nf_tables_exit_net, };static int __init nf_tables_module_init (void )
Signature · 1 line
2.7.4
PATCH v5 3/5 nfnetlink_log: exit_net cleanup check added
In reply to Vasily AverinBe sure that instance_table array initialized in net_init hook was return to initial state.
--- net/netfilter/nfnetlink_log.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/nfnetlink_log.c +4 -0
@@ -1093,10 +1093,14 @@ static int __net_init nfnl_log_net_init(struct net *net) static void __net_exit nfnl_log_net_exit(struct net *net) { +unsigned int i; +struct nfnl_log_net *log =nfnl_log_pernet (net);#ifdef CONFIG_PROC_FS remove_proc_entry ("nfnetlink_log" , net->nf.proc_netfilter);#endif nf_log_unset (net, &nfulnl_logger); +for (i =0 ; i <INSTANCE_BUCKETS ; i++) +WARN_ON_ONCE (!hlist_empty (&log->instance_table[i])); }static struct pernet_operations nfnl_log_net_ops = {
Signature · 1 line
2.7.4
PATCH v5 4/5 nfnetlink_gueue: exit_net cleanup check added
In reply to Vasily AverinBe sure that instance_table array initialized in net_init hook was return to initial state.
--- net/netfilter/nfnetlink_queue.c | 5 +++++ 1 file changed, 5 insertions(+)
net/netfilter/nfnetlink_queue.c +5 -0
@@ -1512,10 +1512,15 @@ static int __net_init nfnl_queue_net_init(struct net *net) static void __net_exit nfnl_queue_net_exit(struct net *net) { +unsigned int i; +struct nfnl_queue_net *q =nfnl_queue_pernet (net); +nf_unregister_queue_handler (net);#ifdef CONFIG_PROC_FS remove_proc_entry ("nfnetlink_queue" , net->nf.proc_netfilter);#endif +for (i =0 ; i <INSTANCE_BUCKETS ; i++) +WARN_ON_ONCE (!hlist_empty (&q->instance_table[i])); }static void nfnl_queue_net_exit_batch (struct list_head *net_exit_list)
Signature · 1 line
2.7.4
PATCH v5 5/5 x_tables: exit_net cleanup check added
In reply to Vasily AverinBe sure that xt.tables array initialized in net_init hook was return to initial state.
--- net/netfilter/x_tables.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/netfilter/x_tables.c +9 -0
@@ -1714,8 +1714,17 @@ static int __net_init xt_net_init(struct net *net)return 0 ; } +static void __net_exit xt_net_exit(struct net *net) +{ +int i; + +for (i =0 ; i <NFPROTO_NUMPROTO ; i++) +WARN_ON_ONCE (!list_empty (&net->xt.tables[i])); +} +static struct pernet_operations xt_net_ops = { .init = xt_net_init, + .exit = xt_net_exit, };static int __init xt_init (void )
Signature · 1 line
2.7.4
Quoted 5 lines · Vasily Averin
clusterip:
exit_netcleanup check added
nf_tables:exit_netcleanup check added
nfnetlink_log:exit_netcleanup check added
nfnetlink_gueue:exit_netcleanup check added
x_tables:exit_netcleanup check added
netfilter-related patches was sent separately to netfilter-devel@ mailing list
v5 cover exit_net checks for objects initialized in net_init hook
In reply to Vasily AverinOpenVz kernel team have a long history of fighting against namespace-related bugs, some of them could be prevented by using simple checks described below.
One of typical errors is related to live cycle of namespaces:
usually objects created for some namespace should not live longer than namespace itself.
Such kind of issues can be invisible on usual systems where additional namespaces are not used, because initial namespaces usually lives forever and never destroyed.
However in systems with namespaces it can lead to memory leaks or to use-after-free. Both of them are critical for systems with running containers.
As you knows it's quite hard to find the reason of such issues, especially in rarely-triggered scenarios on production nodes on default kernels without specially enabled debug settings. Any additional hints can be useful here.
This patch set should help to detect some of these issues.
It is based on assumption that objects initialized in init hook of pernet_operations should return to initial state until end of exit hook.
Many drivers and subsystems already have such checks, however I've found number of places where list_empty check would be useful at least as smoke test.
These checks are useful for long-term stable kernels, they allows to detect problems related to incomplete or incorrectly backported patches.
Changes:
v5:
- fixed nit pointed by Florian Westphal
- netfilter patches are send separately to netfilter-devel@
v4:
- excluded grace and lockd patches taken by Bruce Fields
- let's use WARN_ON_ONCE without any extra messages
adobriyan@ is right, output of net Id gives nothing to host admin, and developers in any case will extract information from core dump
- updated description in cover letter
- dropped nfs4blocklayout patch: waitqueue check does not look useful
- patches was reordered to be per-subsystem grouped
- cover letter should be sent to all people included into cc: of any patches
- minor cosmetic changes in some patches
v3:
- use net->ns.inum as net Id
- removed patches for hashlimit and recent,
they handle tables list in exit_net hook.
- added patches for grace and lockd
v2:
- net pointer removed from output
- fixed compilation for phonet driver
Vasily Averin (13):
af_key: replace BUG_ON on WARN_ON in net_exit hook
geneve: exit_net cleanup check added
packet: exit_net cleanup check added
vxlan: exit_net cleanup checks added
netdev: exit_net cleanup check added
fib_notifier: exit_net cleanup check added
fib_rules: exit_net cleanup check added
l2tp: exit_net cleanup check added
nfs client: exit_net cleanup check added
sunrpc: exit_net cleanup check added
phonet: exit_net cleanup check added
ppp: exit_net cleanup checks added
xfrm6_tunnel: exit_net cleanup check added
drivers/net/geneve.c | 1 + drivers/net/ppp/ppp_generic.c | 2 ++ drivers/net/vxlan.c | 4 ++++ fs/nfs/inode.c | 4 ++++ net/core/dev.c | 2 ++ net/core/fib_notifier.c | 6 ++++++ net/core/fib_rules.c | 6 ++++++ net/ipv6/xfrm6_tunnel.c | 8 ++++++++ net/key/af_key.c | 2 +- net/l2tp/l2tp_core.c | 4 ++++ net/packet/af_packet.c | 1 + net/phonet/pn_dev.c | 3 +++ net/sunrpc/sunrpc_syms.c | 3 +++ 13 files changed, 45 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
David Miller
maintainerFrom: Vasily Averin <[email protected]>
Date: Sun, 12 Nov 2017 22:26:44 +0300
Quoted 19 lines
OpenVz kernel team have a long history of fighting against namespace-related bugs, some of them could be prevented by using simple checks described below.
One of typical errors is related to live cycle of namespaces:
usually objects created for some namespace should not live longer than namespace itself.Such kind of issues can be invisible on usual systems where additional namespaces are not used, because initial namespaces usually lives forever and never destroyed.
However in systems with namespaces it can lead to memory leaks or to use-after-free. Both of them are critical for systems with running containers.
As you knows it's quite hard to find the reason of such issues, especially in rarely-triggered scenarios on production nodes on default kernels without specially enabled debug settings. Any additional hints can be useful here.This patch set should help to detect some of these issues.
It is based on assumption that objects initialized in init hook ofpernet_operationsshould return to initial state until end of exit hook.
Quoted 6 lines
Many drivers and subsystems already have such checks, however I've found number of places where
list_emptycheck would be useful at least as smoke test.These checks are useful for long-term stable kernels, they allows to detect problems related to incomplete or incorrectly backported patches.
All applied to net-next except patch #9 and #10 which need to go via the NFS maintainer.
A message that is not in the archive (sent off-list or not yet received): 20171114.154720.1071922306148362515.davem-fT/PcQaiUtIeIZ0/[email protected]
Quoted 11 lines · David Miller
From: Vasily Averin <[email protected]>
Date: Sun, 12 Nov 2017 22:26:44 +0300Quoted 5 lines
OpenVz kernel team have a long history of fighting against namespace-related bugs, some of them could be prevented by using simple checks described below.
One of typical errors is related to live cycle of namespaces:
usually objects created for some namespace should not live longer than namespace itself.All applied to net-next except patch #9 and #10 which need to go via the NFS maintainer.
As far as I see Anna included them into Anna's linux-nfs work git.
Thank you!
Vasily Averin
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 1/13 af_key: replace BUG_ON on WARN_ON in net_exit hook
In reply to Vasily Averin--- net/key/af_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/key/af_key.c +1 -1
@@ -3845,7 +3845,7 @@ static void __net_exit pfkey_net_exit(struct net *net)struct netns_pfkey *net_pfkey =net_generic (net, pfkey_net_id);pfkey_exit_proc (net); -BUG_ON (!hlist_empty (&net_pfkey->table)); +WARN_ON (!hlist_empty (&net_pfkey->table)); }static struct pernet_operations pfkey_net_ops = {
Signature · 1 line
2.7.4
PATCH v5 2/13 geneve: exit_net cleanup check added
In reply to Vasily AverinBe sure that sock_list initialized in net_init hook was return to initial state.
--- drivers/net/geneve.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/geneve.c +1 -0
@@ -1673,6 +1673,7 @@ static void __net_exit geneve_exit_net(struct net *net)/* unregister the devices gathered above */ unregister_netdevice_many (&list);rtnl_unlock (); +WARN_ON_ONCE (!list_empty (&gn->sock_list)); }static struct pernet_operations geneve_net_ops = {
Signature · 1 line
2.7.4
PATCH v5 3/13 packet: exit_net cleanup check added
In reply to Vasily AverinBe sure that packet.sklist initialized in net_init hook was return to initial state.
--- net/packet/af_packet.c | 1 + 1 file changed, 1 insertion(+)
net/packet/af_packet.c +1 -0
@@ -4562,6 +4562,7 @@ static int __net_init packet_net_init(struct net *net) static void __net_exit packet_net_exit(struct net *net) {remove_proc_entry ("packet" , net->proc_net); +WARN_ON_ONCE (!hlist_empty (&net->packet.sklist)); }static struct pernet_operations packet_net_ops = {
Signature · 1 line
2.7.4
PATCH v5 4/13 vxlan: exit_net cleanup checks added
In reply to Vasily AverinBe sure that sock_list array initialized in net_init hook was return to initial state
--- drivers/net/vxlan.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/vxlan.c +4 -0
@@ -3704,6 +3704,7 @@ static void __net_exit vxlan_exit_net(struct net *net)struct vxlan_net *vn =net_generic (net, vxlan_net_id);struct vxlan_dev *vxlan, *next;struct net_device *dev, *aux; +unsigned int h;LIST_HEAD (list);rtnl_lock ();
@@ -3723,6 +3724,9 @@ static void __net_exit vxlan_exit_net(struct net *net)unregister_netdevice_many (&list);rtnl_unlock (); + +for (h =0 ; h <PORT_HASH_SIZE ; ++h) +WARN_ON_ONCE (!hlist_empty (&vn->sock_list[h])); }static struct pernet_operations vxlan_net_ops = {
Signature · 1 line
2.7.4
PATCH v5 5/13 netdev: exit_net cleanup check added
In reply to Vasily AverinBe sure that dev_base_head list initialized in net_init hook was return to initial state
--- net/core/dev.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/dev.c +2 -0
@@ -8562,6 +8562,8 @@ static void __net_exit netdev_exit(struct net *net) {kfree (net->dev_name_head);kfree (net->dev_index_head); +if (net != &init_net) +WARN_ON_ONCE (!list_empty (&net->dev_base_head)); }static struct pernet_operations __net_initdata netdev_net_ops = {
Signature · 1 line
2.7.4
PATCH v5 6/13 fib_notifier: exit_net cleanup check added
In reply to Vasily AverinBe sure that fib_notifier_ops list initilized in net_init hook was return to initial state.
--- net/core/fib_notifier.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/fib_notifier.c +6 -0
@@ -161,8 +161,14 @@ static int __net_init fib_notifier_net_init(struct net *net)return 0 ; } +static void __net_exit fib_notifier_net_exit(struct net *net) +{ +WARN_ON_ONCE (!list_empty (&net->fib_notifier_ops)); +} +static struct pernet_operations fib_notifier_net_ops = { .init = fib_notifier_net_init, + .exit = fib_notifier_net_exit, };static int __init fib_notifier_init (void )
Signature · 1 line
2.7.4
PATCH v5 7/13 fib_rules: exit_net cleanup check added
In reply to Vasily AverinBe sure that rules_ops list initialized in net_init hook was return to initial state.
--- net/core/fib_rules.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/fib_rules.c +6 -0
@@ -1019,8 +1019,14 @@ static int __net_init fib_rules_net_init(struct net *net)return 0 ; } +static void __net_exit fib_rules_net_exit(struct net *net) +{ +WARN_ON_ONCE (!list_empty (&net->rules_ops)); +} +static struct pernet_operations fib_rules_net_ops = { .init = fib_rules_net_init, + .exit = fib_rules_net_exit, };static int __init fib_rules_init (void )
Signature · 1 line
2.7.4
PATCH v5 8/13 l2tp: exit_net cleanup check added
In reply to Vasily AverinBe sure that l2tp_session_hlist array initialized in net_init hook was return to initial state.
--- net/l2tp/l2tp_core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/l2tp/l2tp_core.c +4 -0
@@ -1888,6 +1888,7 @@ static __net_exit void l2tp_exit_net(struct net *net) {struct l2tp_net *pn =l2tp_pernet (net);struct l2tp_tunnel *tunnel =NULL ; +int hash;rcu_read_lock_bh ();list_for_each_entry_rcu (tunnel, &pn->l2tp_tunnel_list, list) {
@@ -1897,6 +1898,9 @@ static __net_exit void l2tp_exit_net(struct net *net)flush_workqueue (l2tp_wq);rcu_barrier (); + +for (hash =0 ; hash <L2TP_HASH_SIZE_2 ; hash++) +WARN_ON_ONCE (!hlist_empty (&pn->l2tp_session_hlist[hash])); }static struct pernet_operations l2tp_net_ops = {
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): cb06dace-88a8-fecf-92ad-02920920a0d3-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org
PATCH v5 9/13 nfs client: exit_net cleanup check added
Be sure that nfs_client_list and nfs_volume_list lists initialized in net_init hook were return to initial state in net_exit hook.
--- fs/nfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfs/inode.c +4 -0
@@ -2084,8 +2084,12 @@ static int nfs_net_init(struct net *net)static void nfs_net_exit (struct net *net) { +struct nfs_net *nn =net_generic (net, nfs_net_id); +nfs_fs_proc_net_exit (net);nfs_cleanup_cb_ident_idr (net); +WARN_ON_ONCE (!list_empty (&nn->nfs_client_list)); +WARN_ON_ONCE (!list_empty (&nn->nfs_volume_list)); }static struct pernet_operations nfs_net_ops = {
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 10/13 sunrpc: exit_net cleanup check added
In reply to a message not in the archiveBe sure that all_clients list initialized in net_init hook was return to initial state.
--- net/sunrpc/sunrpc_syms.c | 3 +++ 1 file changed, 3 insertions(+)
net/sunrpc/sunrpc_syms.c +3 -0
@@ -65,10 +65,13 @@ static __net_init int sunrpc_init_net(struct net *net) static __net_exit void sunrpc_exit_net(struct net *net) { +struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +rpc_pipefs_exit_net (net);unix_gid_cache_destroy (net);ip_map_cache_destroy (net);rpc_proc_exit (net); +WARN_ON_ONCE (!list_empty (&sn->all_clients)); }static struct pernet_operations sunrpc_net_ops = {
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v5 11/13 phonet: exit_net cleanup check added
In reply to Vasily AverinBe sure that pndevs.list initialized in net_init hook was return to initial state.
--- net/phonet/pn_dev.c | 3 +++ 1 file changed, 3 insertions(+)
net/phonet/pn_dev.c +3 -0
@@ -331,7 +331,10 @@ static int __net_init phonet_init_net(struct net *net) static void __net_exit phonet_exit_net(struct net *net) { +struct phonet_net *pnn =phonet_pernet (net); +remove_proc_entry ("phonet" , net->proc_net); +WARN_ON_ONCE (!list_empty (&pnn->pndevs.list)); }static struct pernet_operations phonet_net_ops = {
Signature · 1 line
2.7.4
PATCH v5 12/13 ppp: exit_net cleanup checks added
In reply to Vasily AverinBe sure that lists initialized in net_init hook were return to initial state.
--- drivers/net/ppp/ppp_generic.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ppp/ppp_generic.c +2 -0
@@ -960,6 +960,8 @@ static __net_exit void ppp_exit_net(struct net *net)rtnl_unlock ();idr_destroy (&pn->units_idr); +WARN_ON_ONCE (!list_empty (&pn->all_channels)); +WARN_ON_ONCE (!list_empty (&pn->new_channels)); }static struct pernet_operations ppp_net_ops = {
Signature · 1 line
2.7.4
PATCH v5 13/13 xfrm6_tunnel: exit_net cleanup check added
In reply to Vasily AverinBe sure that spi_byaddr and spi_byspi arrays initialized in net_init hook were return to initial state
--- net/ipv6/xfrm6_tunnel.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/ipv6/xfrm6_tunnel.c +8 -0
@@ -338,6 +338,14 @@ static int __net_init xfrm6_tunnel_net_init(struct net *net) static void __net_exit xfrm6_tunnel_net_exit(struct net *net) { +struct xfrm6_tunnel_net *xfrm6_tn =xfrm6_tunnel_pernet (net); +unsigned int i; + +for (i =0 ; i <XFRM6_TUNNEL_SPI_BYADDR_HSIZE ; i++) +WARN_ON_ONCE (!hlist_empty (&xfrm6_tn->spi_byaddr[i])); + +for (i =0 ; i <XFRM6_TUNNEL_SPI_BYSPI_HSIZE ; i++) +WARN_ON_ONCE (!hlist_empty (&xfrm6_tn->spi_byspi[i])); }static struct pernet_operations xfrm6_tunnel_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 1/18 af_key: replace BUG_ON on WARN_ON in net_exit hook
In reply to Vasily Averin--- net/key/af_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/key/af_key.c +1 -1
@@ -3845,7 +3845,7 @@ static void __net_exit pfkey_net_exit(struct net *net)struct netns_pfkey *net_pfkey =net_generic (net, pfkey_net_id);pfkey_exit_proc (net); -BUG_ON (!hlist_empty (&net_pfkey->table)); +WARN_ON (!hlist_empty (&net_pfkey->table)); }static struct pernet_operations pfkey_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 2/18 geneve: exit_net cleanup check added
In reply to Vasily AverinBe sure that sock_list initialized in net_init hook was return to initial state.
--- drivers/net/geneve.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/geneve.c +1 -0
@@ -1673,6 +1673,7 @@ static void __net_exit geneve_exit_net(struct net *net)/* unregister the devices gathered above */ unregister_netdevice_many (&list);rtnl_unlock (); +WARN_ON_ONCE (!list_empty (&gn->sock_list)); }static struct pernet_operations geneve_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 3/18 packet: exit_net cleanup check added
In reply to Vasily AverinBe sure that packet.sklist initialized in net_init hook was return to initial state.
--- net/packet/af_packet.c | 1 + 1 file changed, 1 insertion(+)
net/packet/af_packet.c +1 -0
@@ -4562,6 +4562,7 @@ static int __net_init packet_net_init(struct net *net) static void __net_exit packet_net_exit(struct net *net) {remove_proc_entry ("packet" , net->proc_net); +WARN_ON_ONCE (!hlist_empty (&net->packet.sklist)); }static struct pernet_operations packet_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 4/18 vxlan: exit_net cleanup checks added
In reply to Vasily AverinBe sure that sock_list array initialized in net_init hook was return to initial state
--- drivers/net/vxlan.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/vxlan.c +5 -0
@@ -3704,6 +3704,7 @@ static void __net_exit vxlan_exit_net(struct net *net)struct vxlan_net *vn =net_generic (net, vxlan_net_id);struct vxlan_dev *vxlan, *next;struct net_device *dev, *aux; +unsigned int h;LIST_HEAD (list);rtnl_lock ();
@@ -3723,6 +3724,10 @@ static void __net_exit vxlan_exit_net(struct net *net)unregister_netdevice_many (&list);rtnl_unlock (); + +for (h =0 ; h <PORT_HASH_SIZE ; ++h) +if (WARN_ON_ONCE (!hlist_empty (&vn->sock_list[h]))) +break ; }static struct pernet_operations vxlan_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 5/18 netdev: exit_net cleanup check added
In reply to Vasily AverinBe sure that dev_base_head list initialized in net_init hook was return to initial state
--- net/core/dev.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/dev.c +2 -0
@@ -8562,6 +8562,8 @@ static void __net_exit netdev_exit(struct net *net) {kfree (net->dev_name_head);kfree (net->dev_index_head); +if (net != &init_net) +WARN_ON_ONCE (!list_empty (&net->dev_base_head)); }static struct pernet_operations __net_initdata netdev_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 6/18 fib_notifier: exit_net cleanup check added
In reply to Vasily AverinBe sure that fib_notifier_ops list initilized in net_init hook was return to initial state.
--- net/core/fib_notifier.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/fib_notifier.c +6 -0
@@ -161,8 +161,14 @@ static int __net_init fib_notifier_net_init(struct net *net)return 0 ; } +static void __net_exit fib_notifier_net_exit(struct net *net) +{ +WARN_ON_ONCE (!list_empty (&net->fib_notifier_ops)); +} +static struct pernet_operations fib_notifier_net_ops = { .init = fib_notifier_net_init, + .exit = fib_notifier_net_exit, };static int __init fib_notifier_init (void )
Signature · 1 line
2.7.4
PATCH v4 7/18 fib_rules: exit_net cleanup check added
In reply to Vasily AverinBe sure that rules_ops list initialized in net_init hook was return to initial state.
--- net/core/fib_rules.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/fib_rules.c +6 -0
@@ -1019,8 +1019,14 @@ static int __net_init fib_rules_net_init(struct net *net)return 0 ; } +static void __net_exit fib_rules_net_exit(struct net *net) +{ +WARN_ON_ONCE (!list_empty (&net->rules_ops)); +} +static struct pernet_operations fib_rules_net_ops = { .init = fib_rules_net_init, + .exit = fib_rules_net_exit, };static int __init fib_rules_init (void )
Signature · 1 line
2.7.4
PATCH v4 8/18 l2tp: exit_net cleanup check added
In reply to Vasily AverinBe sure that l2tp_session_hlist array initialized in net_init hook was return to initial state.
--- net/l2tp/l2tp_core.c | 5 +++++ 1 file changed, 5 insertions(+)
net/l2tp/l2tp_core.c +5 -0
@@ -1888,6 +1888,7 @@ static __net_exit void l2tp_exit_net(struct net *net) {struct l2tp_net *pn =l2tp_pernet (net);struct l2tp_tunnel *tunnel =NULL ; +int hash;rcu_read_lock_bh ();list_for_each_entry_rcu (tunnel, &pn->l2tp_tunnel_list, list) {
@@ -1897,6 +1898,10 @@ static __net_exit void l2tp_exit_net(struct net *net)flush_workqueue (l2tp_wq);rcu_barrier (); + +for (hash =0 ; hash <L2TP_HASH_SIZE_2 ; hash++) +if (WARN_ON_ONCE (!hlist_empty (&pn->l2tp_session_hlist[hash]))) +break ; }static struct pernet_operations l2tp_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 9/18 clusterip: exit_net cleanup check added
In reply to Vasily AverinBe sure that configs list initialized in net_init hook was return to initial state.
--- net/ipv4/netfilter/ipt_CLUSTERIP.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/netfilter/ipt_CLUSTERIP.c +1 -0
@@ -819,6 +819,7 @@ static void clusterip_net_exit(struct net *net) cn->procdir =NULL ;#endif nf_unregister_net_hook (net, &cip_arp_ops); +WARN_ON_ONCE (!list_empty (&cn->configs)); }static struct pernet_operations clusterip_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 10/18 nf_tables: exit_net cleanup check added
In reply to Vasily AverinBe sure that lists initialized in net_init hook were return to initial state.
--- net/netfilter/nf_tables_api.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/netfilter/nf_tables_api.c +7 -0
@@ -5778,6 +5778,12 @@ static int __net_init nf_tables_init_net(struct net *net)return 0 ; } +static void __net_exit nf_tables_exit_net(struct net *net) +{ +WARN_ON_ONCE (!list_empty (&net->nft.af_info)); +WARN_ON_ONCE (!list_empty (&net->nft.commit_list)); +} +int __nft_release_basechain (struct nft_ctx *ctx) {struct nft_rule *rule, *nr;
@@ -5848,6 +5854,7 @@ static void __nft_release_afinfo(struct net *net, struct nft_af_info *afi)static struct pernet_operations nf_tables_net_ops = { .init = nf_tables_init_net, + .exit = nf_tables_exit_net, };static int __init nf_tables_module_init (void )
Signature · 1 line
2.7.4
PATCH v4 11/18 nfnetlink_log: exit_net cleanup check added
In reply to Vasily AverinBe sure that instance_table array initialized in net_init hook was return to initial state.
--- net/netfilter/nfnetlink_log.c | 5 +++++ 1 file changed, 5 insertions(+)
net/netfilter/nfnetlink_log.c +5 -0
@@ -1093,10 +1093,15 @@ static int __net_init nfnl_log_net_init(struct net *net) static void __net_exit nfnl_log_net_exit(struct net *net) { +unsigned int i; +struct nfnl_log_net *log =nfnl_log_pernet (net);#ifdef CONFIG_PROC_FS remove_proc_entry ("nfnetlink_log" , net->nf.proc_netfilter);#endif nf_log_unset (net, &nfulnl_logger); +for (i =0 ; i <INSTANCE_BUCKETS ; i++) +if (WARN_ON_ONCE (!hlist_empty (&log->instance_table[i]))) +break ; }static struct pernet_operations nfnl_log_net_ops = {
Signature · 1 line
2.7.4
Re: [PATCH v4 11/18] nfnetlink_log: exit_net cleanup check added
Quoted 2 lines · Vasily Averin
Be sure that
instance_tablearray initialized innet_inithook was return to initial state.
Re: [PATCH v4 11/18] nfnetlink_log: exit_net cleanup check added
In reply to Vasily AverinHello!
Quoted 13 lines · Vasily Averin
Be sure that
instance_tablearray initialized innet_inithook was return to initial state.Signed-off-by Vasily Averin <[email protected]>--- net/netfilter/nfnetlink_log.c | 5 +++++ 1 file changed, 5 insertions(+)net/netfilter/nfnetlink_log.c +0
-0
net/netfilter/nfnetlink_log.c static int __net_init nfnl_log_net_init(struct net *net) · line 1097
Quoted 5 lines
net/netfilter/nfnetlink_log.c +2
-0@@ -1093,10 +1093,15 @@ static int __net_init nfnl_log_net_init(struct net *net) static void __net_exit nfnl_log_net_exit(struct net *net) { +unsigned int i; +struct nfnl_log_net *log =nfnl_log_pernet (net);
Need empty line after the declarations.
net/netfilter/nfnetlink_log.c static int __net_init nfnl_log_net_init(struct net *net) · line 1105
Quoted 8 lines
net/netfilter/nfnetlink_log.c +3
-0#ifdef CONFIG_PROC_FS remove_proc_entry ("nfnetlink_log" , net->nf.proc_netfilter);#endif nf_log_unset (net, &nfulnl_logger); +for (i =0 ; i <INSTANCE_BUCKETS ; i++) +if (WARN_ON_ONCE (!hlist_empty (&log->instance_table[i]))) +break ; }
[...]
MBR, Sergei
PATCH v4 12/18 nfnetlink_gueue: exit_net cleanup check added
In reply to Vasily AverinBe sure that instance_table array initialized in net_init hook was return to initial state.
--- net/netfilter/nfnetlink_queue.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/netfilter/nfnetlink_queue.c +6 -0
@@ -1512,10 +1512,16 @@ static int __net_init nfnl_queue_net_init(struct net *net) static void __net_exit nfnl_queue_net_exit(struct net *net) { +unsigned int i; +struct nfnl_queue_net *q =nfnl_queue_pernet (net); +nf_unregister_queue_handler (net);#ifdef CONFIG_PROC_FS remove_proc_entry ("nfnetlink_queue" , net->nf.proc_netfilter);#endif +for (i =0 ; i <INSTANCE_BUCKETS ; i++) +if (WARN_ON_ONCE (!hlist_empty (&q->instance_table[i]))) +break ; }static void nfnl_queue_net_exit_batch (struct list_head *net_exit_list)
Signature · 1 line
2.7.4
Re: [PATCH v4 12/18] nfnetlink_gueue: exit_net cleanup check added
net/netfilter/nfnetlink_queue.c static int __net_init nfnl_queue_net_init(struct net *net) · line 1524
Quoted 6 lines · Vasily Averin
Be sure that
instance_tablearray initialized innet_inithook was return to initial state.net/netfilter/nfnetlink_queue.c +3
-0+for (i =0 ; i <INSTANCE_BUCKETS ; i++) +if (WARN_ON_ONCE (!hlist_empty (&q->instance_table[i]))) +break ;
This looks strange, why if/break?
Plain WARN_ON_ONCE should be enough, but thats a nit so:
Re: [PATCH v4 12/18] nfnetlink_gueue: exit_net cleanup check added
Quoted 9 lines · Florian Westphal
net/netfilter/nfnetlink_queue.c static int __net_init nfnl_queue_net_init(struct net *net) · line 1524
Quoted 6 lines · Vasily Averin
Be sure that
instance_tablearray initialized innet_inithook was return to initial state.net/netfilter/nfnetlink_queue.c +3
-0+for (i =0 ; i <INSTANCE_BUCKETS ; i++) +if (WARN_ON_ONCE (!hlist_empty (&q->instance_table[i]))) +break ;This looks strange, why if/break?
I did not want to generate huge number of messages on each non-empty hash bucket.
Quoted 1 line
Plain
WARN_ON_ONCEshould be enough, but thats a nit so:
Oh, you're right.
In first patch version WARN_ON was used here.
I've missed that only first message will be printed with _ONCE check.
Quoted 2 lines
Acked-by Florian Westphal <[email protected]>
PATCH v4 13/18 x_tables: exit_net cleanup check added
In reply to Vasily AverinBe sure that xt.tables array initialized in net_init hook was return to initial state.
--- net/netfilter/x_tables.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/netfilter/x_tables.c +10 -0
@@ -1714,8 +1714,18 @@ static int __net_init xt_net_init(struct net *net)return 0 ; } +static void __net_exit xt_net_exit(struct net *net) +{ +int i; + +for (i =0 ; i <NFPROTO_NUMPROTO ; i++) +if (WARN_ON_ONCE (!list_empty (&net->xt.tables[i]))) +break ; +} +static struct pernet_operations xt_net_ops = { .init = xt_net_init, + .exit = xt_net_exit, };static int __init xt_init (void )
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): 9dfa013e-9098-e155-9c47-a73753338288-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org
PATCH v4 14/18 nfs client: exit_net cleanup check added
Be sure that nfs_client_list and nfs_volume_list lists initialized in net_init hook were return to initial state in net_exit hook.
--- fs/nfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfs/inode.c +4 -0
@@ -2084,8 +2084,12 @@ static int nfs_net_init(struct net *net)static void nfs_net_exit (struct net *net) { +struct nfs_net *nn =net_generic (net, nfs_net_id); +nfs_fs_proc_net_exit (net);nfs_cleanup_cb_ident_idr (net); +WARN_ON_ONCE (!list_empty (&nn->nfs_client_list)); +WARN_ON_ONCE (!list_empty (&nn->nfs_volume_list)); }static struct pernet_operations nfs_net_ops = {
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 15/18 sunrpc: exit_net cleanup check added
In reply to a message not in the archiveBe sure that all_clients list initialized in net_init hook was return to initial state.
--- net/sunrpc/sunrpc_syms.c | 3 +++ 1 file changed, 3 insertions(+)
net/sunrpc/sunrpc_syms.c +3 -0
@@ -65,10 +65,13 @@ static __net_init int sunrpc_init_net(struct net *net) static __net_exit void sunrpc_exit_net(struct net *net) { +struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +rpc_pipefs_exit_net (net);unix_gid_cache_destroy (net);ip_map_cache_destroy (net);rpc_proc_exit (net); +WARN_ON_ONCE (!list_empty (&sn->all_clients)); }static struct pernet_operations sunrpc_net_ops = {
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 16/18 phonet: exit_net cleanup check added
In reply to Vasily AverinBe sure that pndevs.list initialized in net_init hook was return to initial state.
--- net/phonet/pn_dev.c | 3 +++ 1 file changed, 3 insertions(+)
net/phonet/pn_dev.c +3 -0
@@ -331,7 +331,10 @@ static int __net_init phonet_init_net(struct net *net) static void __net_exit phonet_exit_net(struct net *net) { +struct phonet_net *pnn =phonet_pernet (net); +remove_proc_entry ("phonet" , net->proc_net); +WARN_ON_ONCE (!list_empty (&pnn->pndevs.list)); }static struct pernet_operations phonet_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 17/18 ppp: exit_net cleanup checks added
In reply to Vasily AverinBe sure that lists initialized in net_init hook were return to initial state.
--- drivers/net/ppp/ppp_generic.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ppp/ppp_generic.c +2 -0
@@ -960,6 +960,8 @@ static __net_exit void ppp_exit_net(struct net *net)rtnl_unlock ();idr_destroy (&pn->units_idr); +WARN_ON_ONCE (!list_empty (&pn->all_channels)); +WARN_ON_ONCE (!list_empty (&pn->new_channels)); }static struct pernet_operations ppp_net_ops = {
Signature · 1 line
2.7.4
PATCH v4 18/18 xfrm6_tunnel: exit_net cleanup check added
In reply to Vasily AverinBe sure that spi_byaddr and spi_byspi arrays initialized in net_init hook were return to initial state
--- net/ipv6/xfrm6_tunnel.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/ipv6/xfrm6_tunnel.c +10 -0
@@ -338,6 +338,16 @@ static int __net_init xfrm6_tunnel_net_init(struct net *net) static void __net_exit xfrm6_tunnel_net_exit(struct net *net) { +struct xfrm6_tunnel_net *xfrm6_tn =xfrm6_tunnel_pernet (net); +unsigned int i; + +for (i =0 ; i <XFRM6_TUNNEL_SPI_BYADDR_HSIZE ; i++) +if (WARN_ON_ONCE (!hlist_empty (&xfrm6_tn->spi_byaddr[i]))) +break ; + +for (i =0 ; i <XFRM6_TUNNEL_SPI_BYSPI_HSIZE ; i++) +if (WARN_ON_ONCE (!hlist_empty (&xfrm6_tn->spi_byspi[i]))) +break ; }static struct pernet_operations xfrm6_tunnel_net_ops = {
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): 4fdc4264-e338-6ee8-a662-7d98b45733a1-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org
PATCH v3 1/21 grace: replace BUG_ON by WARN_ONCE in exit_net hook
--- fs/nfs_common/grace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfs_common/grace.c +3 -1
@@ -104,7 +104,9 @@ grace_exit_net(struct net *net) {struct list_head *grace_list =net_generic (net, grace_net_id); -BUG_ON (!list_empty (grace_list)); +WARN_ONCE (!list_empty (grace_list), +"net %x %s: grace_list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations grace_net_ops = {
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 01/21] grace: replace BUG_ON by WARN_ONCE in exit_net hook
I'm assuming you want me to apply this (and the following lockd patch), but I'm not clear why this is part of a bigger series going to netdev.
--b.
Quoted 27 lines · Vasily Averin
Signed-off-by Vasily Averin <[email protected]>--- fs/nfs_common/grace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/nfs_common/grace.c +3
-1@@ -104,7 +104,9 @@ grace_exit_net(struct net *net) {struct list_head *grace_list =net_generic (net, grace_net_id); -BUG_ON (!list_empty (grace_list)); +WARN_ONCE (!list_empty (grace_list), +"net %x %s: grace_list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations grace_net_ops = {Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): a059abdd-e727-adcb-7b43-976be1d0a08e-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org
Re: [PATCH v3 01/21] grace: replace BUG_ON by WARN_ONCE in exit_net hook
Applied for 4.15, thanks.--b.
Quoted 22 lines · Vasily Averin
Signed-off-by Vasily Averin <[email protected]>--- fs/nfs_common/grace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/nfs_common/grace.c +3
-1@@ -104,7 +104,9 @@ grace_exit_net(struct net *net) {struct list_head *grace_list =net_generic (net, grace_net_id); -BUG_ON (!list_empty (grace_list)); +WARN_ONCE (!list_empty (grace_list), +"net %x %s: grace_list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations grace_net_ops = {Signature · 1 line
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 7/21 nfs4blocklayout: exit_net cleanup check added
In reply to a message not in the archiveBe sure that bl_wq wait queue initialized in net_init hook is not used anymore.
--- fs/nfs/blocklayout/rpc_pipefs.c | 3 +++ 1 file changed, 3 insertions(+)
fs/nfs/blocklayout/rpc_pipefs.c +3 -0
@@ -256,6 +256,9 @@ static void nfs4blocklayout_net_exit(struct net *net)nfs4blocklayout_unregister_net (net, nn->bl_device_pipe);rpc_destroy_pipe_data (nn->bl_device_pipe); nn->bl_device_pipe =NULL ; +WARN_ONCE (!list_empty (&nn->bl_wq.head), +"net %x %s: bl_wq head is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations nfs4blocklayout_net_ops = {
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 2/21 lockd: added cleanup checks in exit_net hook
In reply to Vasily Averin--- fs/lockd/svc.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/lockd/svc.c +11 -0
@@ -690,6 +690,17 @@ static int lockd_init_net(struct net *net)static void lockd_exit_net (struct net *net) { +struct lockd_net *ln =net_generic (net, lockd_net_id); + +WARN_ONCE (!list_empty (&ln->lockd_manager.list), +"net %x %s: lockd_manager.list is not empty\n" , + net->ns.inum, __func__); +WARN_ONCE (!list_empty (&ln->nsm_handles), +"net %x %s: nsm_handles list is not empty\n" , + net->ns.inum, __func__); +WARN_ONCE (delayed_work_pending (&ln->grace_period_end), +"net %x %s: grace_period_end was not cancelled\n" , + net->ns.inum, __func__); }static struct pernet_operations lockd_net_ops = {
Signature · 1 line
2.7.4
J. Bruce Fields
AppliedRe: [PATCH v3 02/21] lockd: added cleanup checks in exit_net hook
Applied.--b.
Quoted 29 lines · Vasily Averin
Signed-off-by Vasily Averin <[email protected]>--- fs/lockd/svc.c | 11 +++++++++++ 1 file changed, 11 insertions(+)fs/lockd/svc.c +11
-0@@ -690,6 +690,17 @@ static int lockd_init_net(struct net *net)static void lockd_exit_net (struct net *net) { +struct lockd_net *ln =net_generic (net, lockd_net_id); + +WARN_ONCE (!list_empty (&ln->lockd_manager.list), +"net %x %s: lockd_manager.list is not empty\n" , + net->ns.inum, __func__); +WARN_ONCE (!list_empty (&ln->nsm_handles), +"net %x %s: nsm_handles list is not empty\n" , + net->ns.inum, __func__); +WARN_ONCE (delayed_work_pending (&ln->grace_period_end), +"net %x %s: grace_period_end was not cancelled\n" , + net->ns.inum, __func__); }static struct pernet_operations lockd_net_ops = {Signature · 1 line
2.7.4
PATCH v3 3/21 exit_net cleanup: geneve sock_list check
In reply to Vasily AverinBe sure that sock_list initialized in net_init hook was return to initial state.
--- drivers/net/geneve.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/geneve.c +3 -0
@@ -1673,6 +1673,9 @@ static void __net_exit geneve_exit_net(struct net *net)/* unregister the devices gathered above */ unregister_netdevice_many (&list);rtnl_unlock (); +WARN_ONCE (!list_empty (&gn->sock_list), +"net %x &s: sock_list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations geneve_net_ops = {
Signature · 1 line
2.7.4
PATCH v3 4/21 ppp: exit_net cleanup checks added
In reply to Vasily AverinBe sure that lists initialized in net_init hook were return to initial state.
--- drivers/net/ppp/ppp_generic.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ppp/ppp_generic.c +6 -0
@@ -960,6 +960,12 @@ static __net_exit void ppp_exit_net(struct net *net)rtnl_unlock ();idr_destroy (&pn->units_idr); +WARN_ONCE (!list_empty (&pn->all_channels), +"net %x %s: all_channels list is not empty\n" , + net->ns.inum, __func__); +WARN_ONCE (!list_empty (&pn->new_channels), +"net %x %s: new_channels list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations ppp_net_ops = {
Signature · 1 line
2.7.4
Re: [PATCH v3 04/21] ppp: exit_net cleanup checks added
Hello Vasily Averin,
just a general hint:
when you send new versions of a patch please document also what you have changed. Here an example from an other ML:
The problematic code looks like this:
res_seq = res_hdr->xd_hdr.length_sn & TB_XDOMAIN_SN_MASK; res_seq >>= TB_XDOMAIN_SN_SHIFT;
TB_XDOMAIN_SN_SHIFT is 27, and right shifting a u8 27 bits is always going to result in zero. The fix is to declare these variables as u32.
---
v2: I accidentally sent this through the wrong list, so I'm resending to
netdev. Also Mika asked me to split it up because the Fixes tags are different for these patches.
please notice the V2. that tell the reader what has changes against the V1.
re,
wh
Am 06.11.2017 14:23, schrieb Vasily Averin:
Quoted 25 lines
Be sure that lists initialized in
net_inithook were return to initial state.Signed-off-by Vasily Averin <[email protected]>--- drivers/net/ppp/ppp_generic.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/ppp/ppp_generic.c +6
-0@@ -960,6 +960,12 @@ static __net_exit void ppp_exit_net(struct net *net)rtnl_unlock ();idr_destroy (&pn->units_idr); +WARN_ONCE (!list_empty (&pn->all_channels), +"net %x %s: all_channels list is not empty\n" , + net->ns.inum, __func__); +WARN_ONCE (!list_empty (&pn->new_channels), +"net %x %s: new_channels list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations ppp_net_ops = {
Re: [PATCH v3 04/21] ppp: exit_net cleanup checks added
In reply to Vasily AverinDear Walter,
thank you for feedback, I'll do it next time.
Changes was listed in cover letter, that was not not submitted into linux-ppp@ list
"This patch set checks that lists initialized in net_init hooks were return to initial state at end of net_exit hooks.
I hope such checks allows to detect leaked per-netns objects. Also I hope that all new pernet_operations will inherit such checks too.
I assume that elements added into per-net lists should not live longer than net namespace, and should be deleted from the list. I think exit_net hook is good place for such check.
Recently I've found lost list_entry and enabled timer on stop of net namespace. Then I've reviewed all existing pernet_operations and found that many drivers have such checks already. So I decided to complete this task and add such checks into all affected subsystems.
v3:
- use net->ns.inum as net Id
- removed patches for hashlimit and recent,
they handle tables list in exit_net hook.
- added patches for grace and lockd
v2:
- net pointer removed from output
- fixed compilation for phonet driver
"
Quoted 54 lines · walter harms
Hello Vasily Averin,
just a general hint:
when you send new versions of a patch please document also what you have changed. Here an example from an other ML:The problematic code looks like this:
res_seq = res_hdr->xd_hdr.length_sn & TB_XDOMAIN_SN_MASK; res_seq >>= TB_XDOMAIN_SN_SHIFT;
TB_XDOMAIN_SN_SHIFTis 27, and right shifting a u8 27 bits is always going to result in zero. The fix is to declare these variables as u32.Fixes d1ff70241a27 ("thunderbolt: Add support for XDomain discovery protocol")Signed-off-by Dan Carpenter <[email protected]>---
v2: I accidentally sent this through the wrong list, so I'm resending to
netdev. Also Mika asked me to split it up because the Fixes tags are different for these patches.please notice the V2. that tell the reader what has changes against the V1.
re,
whAm 06.11.2017 14:23, schrieb Vasily Averin:
Quoted 25 lines
Be sure that lists initialized in
net_inithook were return to initial state.Signed-off-by Vasily Averin <[email protected]>--- drivers/net/ppp/ppp_generic.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/net/ppp/ppp_generic.c +6
-0@@ -960,6 +960,12 @@ static __net_exit void ppp_exit_net(struct net *net)rtnl_unlock ();idr_destroy (&pn->units_idr); +WARN_ONCE (!list_empty (&pn->all_channels), +"net %x %s: all_channels list is not empty\n" , + net->ns.inum, __func__); +WARN_ONCE (!list_empty (&pn->new_channels), +"net %x %s: new_channels list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations ppp_net_ops = {
PATCH v3 5/21 vxlan: exit_net cleanup checks added
In reply to Vasily AverinBe sure that sock_list array initialized in net_init hook was return to initial state
--- drivers/net/vxlan.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/vxlan.c +7 -0
@@ -3704,6 +3704,7 @@ static void __net_exit vxlan_exit_net(struct net *net)struct vxlan_net *vn =net_generic (net, vxlan_net_id);struct vxlan_dev *vxlan, *next;struct net_device *dev, *aux; +unsigned int h;LIST_HEAD (list);rtnl_lock ();
@@ -3723,6 +3724,12 @@ static void __net_exit vxlan_exit_net(struct net *net)unregister_netdevice_many (&list);rtnl_unlock (); + +for (h =0 ; h <PORT_HASH_SIZE ; ++h) +if (WARN_ONCE (!hlist_empty (&vn->sock_list[h]), +"net %x %s: sock_list is not empty\n" , + net->ns.inum, __func__)) +break ; }static struct pernet_operations vxlan_net_ops = {
Signature · 1 line
2.7.4
PATCH v3 6/21 netdev: exit_net cleanup check added
In reply to Vasily AverinBe sure that dev_base_head list initialized in net_init hook was return to initial state
--- net/core/dev.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/dev.c +4 -0
@@ -8562,6 +8562,10 @@ static void __net_exit netdev_exit(struct net *net) {kfree (net->dev_name_head);kfree (net->dev_index_head); +if (net != &init_net) +WARN_ONCE (!list_empty (&net->dev_base_head), +"net %x %s: dev_base_head is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations __net_initdata netdev_net_ops = {
Signature · 1 line
2.7.4
PATCH v3 8/21 nfs client: exit_net cleanup check added
In reply to Vasily AverinBe sure that nfs_client_list and nfs_volume_list lists initialized in net_init hook were return to initial state in net_exit hook.
--- fs/nfs/client.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfs/client.c +4 -0
@@ -204,6 +204,10 @@ void nfs_cleanup_cb_ident_idr(struct net *net)struct nfs_net *nn =net_generic (net, nfs_net_id);idr_destroy (&nn->cb_ident_idr); +WARN_ONCE (!list_empty (&nn->nfs_client_list), +"net %x exit: nfs_client_list is not empty\n" , net->ns.inum); +WARN_ONCE (!list_empty (&nn->nfs_volume_list), +"net %x exit: nfs_volume_list is not empty\n" , net->ns.inum); }/* nfs_client_lock held */
Signature · 1 line
2.7.4
PATCH v3 9/21 fib_notifier: exit_net cleanup check added
In reply to Vasily AverinBe sure that fib_notifier_ops list initilized in net_init hook was return to initial state.
--- net/core/fib_notifier.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/core/fib_notifier.c +8 -0
@@ -161,8 +161,16 @@ static int __net_init fib_notifier_net_init(struct net *net)return 0 ; } +static void __net_exit fib_notifier_net_exit(struct net *net) +{ +WARN_ONCE (!list_empty (&net->fib_notifier_ops), +"net %x %s: fib_notifier_ops list is not empty\n" , + net->ns.inum, __func__); +} +static struct pernet_operations fib_notifier_net_ops = { .init = fib_notifier_net_init, + .exit = fib_notifier_net_exit, };static int __init fib_notifier_init (void )
Signature · 1 line
2.7.4
PATCH v3 10/21 fib_rules: exit_net cleanup check added
In reply to Vasily AverinBe sure that rules_ops list initialized in net_init hook was return to initial state.
--- net/core/fib_rules.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/core/fib_rules.c +8 -0
@@ -1019,8 +1019,16 @@ static int __net_init fib_rules_net_init(struct net *net)return 0 ; } +static void __net_exit fib_rules_net_exit(struct net *net) +{ +WARN_ONCE (!list_empty (&net->rules_ops), +"net %x %s: rules_ops list is not empty\n" , + net->ns.inum, __func__); +} +static struct pernet_operations fib_rules_net_ops = { .init = fib_rules_net_init, + .exit = fib_rules_net_exit, };static int __init fib_rules_init (void )
Signature · 1 line
2.7.4
PATCH v3 11/21 clusterip: exit_net cleanup check added
In reply to Vasily AverinBe sure that configs list initialized in net_init hook was return to initial state.
--- net/ipv4/netfilter/ipt_CLUSTERIP.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/netfilter/ipt_CLUSTERIP.c +3 -0
@@ -819,6 +819,9 @@ static void clusterip_net_exit(struct net *net) cn->procdir =NULL ;#endif nf_unregister_net_hook (net, &cip_arp_ops); +WARN_ONCE (!list_empty (&cn->configs), +"net %x %s: configs list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations clusterip_net_ops = {
Signature · 1 line
2.7.4
Re: [PATCH v3 11/21] clusterip: exit_net cleanup check added
Hello Vasily,
Quoted 2 lines · Vasily Averin
Be sure that configs list initialized in
net_inithook was return to initial state.
What is the goal of the patch series you sent in the third version in a row?
- If the deinitializations are missing from the files, the patches do not fix them, just emit warnings.
- If the deinitializations are not missing, the patches are totally unnecessary.
It looks like debugging... but not expressed that way, neither in the subject lines nor in the patch descriptions.
Best regards,
Jozsef
Quoted 23 lines
Signed-off-by Vasily Averin <[email protected]>--- net/ipv4/netfilter/ipt_CLUSTERIP.c | 3 +++ 1 file changed, 3 insertions(+)net/ipv4/netfilter/ipt_CLUSTERIP.c +3
-0@@ -819,6 +819,9 @@ static void clusterip_net_exit(struct net *net) cn->procdir =NULL ;#endif nf_unregister_net_hook (net, &cip_arp_ops); +WARN_ONCE (!list_empty (&cn->configs), +"net %x %s: configs list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations clusterip_net_ops = {Signature · 1 line
2.7.4
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
H-1525 Budapest 114, POB. 49, Hungary
Re: [PATCH v3 11/21] clusterip: exit_net cleanup check added
Dear Jozsef,
thank you for your feedback,
I've added description into cover letter, however it was not sent into netfilters mailing lists:
"This patch set checks that lists initialized in net_init hooks were return to initial state at end of net_exit hooks.
I hope such checks allows to detect leaked per-netns objects. Also I hope that all new pernet_operations will inherit such checks too.
I assume that elements added into per-net lists should not live longer than net namespace, and should be deleted from the list. I think exit_net hook is good place for such check.
Recently I've found lost list_entry and enabled timer on stop of net namespace. Then I've reviewed all existing pernet_operations and found that many drivers have such checks already. So I decided to complete this task and add such checks into all affected subsystems.
v3:
- use net->ns.inum as net Id
- removed patches for hashlimit and recent,
they handle tables list in exit_net hook.
- added patches for grace and lockd
v2:
- net pointer removed from output
- fixed compilation for phonet driver
"
Quoted 51 lines · Jozsef Kadlecsik
Hello Vasily,
Quoted 2 lines · Vasily Averin
Be sure that configs list initialized in
net_inithook was return to initial state.What is the goal of the patch series you sent in the third version in a row?
- If the deinitializations are missing from the files, the patches do not fix them, just emit warnings.
- If the deinitializations are not missing, the patches are totally unnecessary.It looks like debugging... but not expressed that way, neither in the subject lines nor in the patch descriptions.
Best regards,
JozsefQuoted 23 lines
Signed-off-by Vasily Averin <[email protected]>--- net/ipv4/netfilter/ipt_CLUSTERIP.c | 3 +++ 1 file changed, 3 insertions(+)net/ipv4/netfilter/ipt_CLUSTERIP.c +3
-0@@ -819,6 +819,9 @@ static void clusterip_net_exit(struct net *net) cn->procdir =NULL ;#endif nf_unregister_net_hook (net, &cip_arp_ops); +WARN_ONCE (!list_empty (&cn->configs), +"net %x %s: configs list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations clusterip_net_ops = {Signature · 1 line
2.7.4-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of SciencesH-1525 Budapest 114, POB. 49, Hungary
PATCH v3 12/21 xfrm6_tunnel: exit_net cleanup check added
In reply to Vasily AverinBe sure that spi_byaddr and spi_byspi arrays initialized in net_init hook were return to initial state
--- net/ipv6/xfrm6_tunnel.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
net/ipv6/xfrm6_tunnel.c +14 -0
@@ -338,6 +338,20 @@ static int __net_init xfrm6_tunnel_net_init(struct net *net) static void __net_exit xfrm6_tunnel_net_exit(struct net *net) { +struct xfrm6_tunnel_net *xfrm6_tn =xfrm6_tunnel_pernet (net); +unsigned int i; + +for (i =0 ; i <XFRM6_TUNNEL_SPI_BYADDR_HSIZE ; i++) +if (WARN_ONCE (!hlist_empty (&xfrm6_tn->spi_byaddr[i]), +"net %x %s: spi_byaddr is not empty\n" , + net->ns.inum, __func__)) +break ; + +for (i =0 ; i <XFRM6_TUNNEL_SPI_BYSPI_HSIZE ; i++) +if (WARN_ONCE (!hlist_empty (&xfrm6_tn->spi_byspi[i]), +"net %x %s: spi_byspi is not empty\n" , + net->ns.inum, __func__)) +break ; }static struct pernet_operations xfrm6_tunnel_net_ops = {
Signature · 1 line
2.7.4
PATCH v3 13/21 af_key: replace BUG_ON on WARN_ONCE in net_exit hook
In reply to Vasily Averin--- net/key/af_key.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/key/af_key.c +3 -1
@@ -3845,7 +3845,9 @@ static void __net_exit pfkey_net_exit(struct net *net)struct netns_pfkey *net_pfkey =net_generic (net, pfkey_net_id);pfkey_exit_proc (net); -BUG_ON (!hlist_empty (&net_pfkey->table)); +WARN_ONCE (!hlist_empty (&net_pfkey->table), +"net %x %s table hlist is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations pfkey_net_ops = {
Signature · 1 line
2.7.4
PATCH v3 14/21 l2tp: exit_net cleanup check added
In reply to Vasily AverinBe sure that l2tp_session_hlist array initialized in net_init hook was return to initial state.
--- net/l2tp/l2tp_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/l2tp/l2tp_core.c +7 -0
@@ -1888,6 +1888,7 @@ static __net_exit void l2tp_exit_net(struct net *net) {struct l2tp_net *pn =l2tp_pernet (net);struct l2tp_tunnel *tunnel =NULL ; +int hash;rcu_read_lock_bh ();list_for_each_entry_rcu (tunnel, &pn->l2tp_tunnel_list, list) {
@@ -1897,6 +1898,12 @@ static __net_exit void l2tp_exit_net(struct net *net)flush_workqueue (l2tp_wq);rcu_barrier (); + +for (hash =0 ; hash <L2TP_HASH_SIZE_2 ; hash++) +if (WARN_ONCE (!hlist_empty (&pn->l2tp_session_hlist[hash]), +"net %x %s: session_hlist is not empty\n" , + net->ns.inum, __func__)) +break ; }static struct pernet_operations l2tp_net_ops = {
Signature · 1 line
2.7.4
PATCH v3 15/21 nf_tables: exit_net cleanup check added
In reply to Vasily AverinBe sure that lists initialized in net_init hook were return to initial state.
--- net/netfilter/nf_tables_api.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/netfilter/nf_tables_api.c +11 -0
@@ -5778,6 +5778,16 @@ static int __net_init nf_tables_init_net(struct net *net)return 0 ; } +static void __net_exit nf_tables_exit_net(struct net *net) +{ +WARN_ONCE (!list_empty (&net->nft.af_info), +"net %x %s: af_info list is not empty\n" , + net->ns.inum, __func__); +WARN_ONCE (!list_empty (&net->nft.commit_list), +"net %x %s: commit_list is not empty\n" , + net->ns.inum, __func__); +} +int __nft_release_basechain (struct nft_ctx *ctx) {struct nft_rule *rule, *nr;
@@ -5848,6 +5858,7 @@ static void __nft_release_afinfo(struct net *net, struct nft_af_info *afi)static struct pernet_operations nf_tables_net_ops = { .init = nf_tables_init_net, + .exit = nf_tables_exit_net, };static int __init nf_tables_module_init (void )
Signature · 1 line
2.7.4
PATCH v3 16/21 nfnetlink_log: exit_net cleanup check added
In reply to Vasily AverinBe sure that instance_table array initialized in net_init hook was return to initial state.
--- net/netfilter/nfnetlink_log.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/netfilter/nfnetlink_log.c +7 -0
@@ -1093,10 +1093,17 @@ static int __net_init nfnl_log_net_init(struct net *net) static void __net_exit nfnl_log_net_exit(struct net *net) { +unsigned int i; +struct nfnl_log_net *log =nfnl_log_pernet (net);#ifdef CONFIG_PROC_FS remove_proc_entry ("nfnetlink_log" , net->nf.proc_netfilter);#endif nf_log_unset (net, &nfulnl_logger); +for (i =0 ; i <INSTANCE_BUCKETS ; i++) +if (WARN_ONCE (!hlist_empty (&log->instance_table[i]), +"net %x %s: instance_table is not empty\n" , + net->ns.inum, __func__)) +break ; }static struct pernet_operations nfnl_log_net_ops = {
Signature · 1 line
2.7.4
PATCH v3 17/21 nfnetlink_gueue: exit_net cleanup check added
In reply to Vasily AverinBe sure that instance_table array initialized in net_init hook was return to initial state.
--- net/netfilter/nfnetlink_queue.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/netfilter/nfnetlink_queue.c +8 -0
@@ -1512,10 +1512,18 @@ static int __net_init nfnl_queue_net_init(struct net *net) static void __net_exit nfnl_queue_net_exit(struct net *net) { +unsigned int i; +struct nfnl_queue_net *q =nfnl_queue_pernet (net); +nf_unregister_queue_handler (net);#ifdef CONFIG_PROC_FS remove_proc_entry ("nfnetlink_queue" , net->nf.proc_netfilter);#endif +for (i =0 ; i <INSTANCE_BUCKETS ; i++) +if (WARN_ONCE (!hlist_empty (&q->instance_table[i]), +"net %x %s: instance_table isn't empty\n" , + net->ns.inum, __func__)) +break ; }static void nfnl_queue_net_exit_batch (struct list_head *net_exit_list)
Signature · 1 line
2.7.4
PATCH v3 18/21 x_tables: exit_net cleanup check added
In reply to Vasily AverinBe sure that xt.tables array initialized in net_init hook was return to initial state.
--- net/netfilter/x_tables.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/netfilter/x_tables.c +12 -0
@@ -1714,8 +1714,20 @@ static int __net_init xt_net_init(struct net *net)return 0 ; } +static void __net_exit xt_net_exit(struct net *net) +{ +int i; + +for (i =0 ; i <NFPROTO_NUMPROTO ; i++) +if (WARN_ONCE (!list_empty (&net->xt.tables[i]), +"net %x %s: tables list is not empty\n" , + net->ns.inum. __func__) +break ; +} +static struct pernet_operations xt_net_ops = { .init = xt_net_init, + .exit = xt_net_exit, };static int __init xt_init (void )
Signature · 1 line
2.7.4
PATCH v3 19/21 packet: exit_net cleanup check added
In reply to Vasily AverinBe sure that packet.sklist initialized in net_init hook was return to initial state.
--- net/packet/af_packet.c | 2 ++ 1 file changed, 2 insertions(+)
net/packet/af_packet.c +2 -0
@@ -4562,6 +4562,8 @@ static int __net_init packet_net_init(struct net *net) static void __net_exit packet_net_exit(struct net *net) {remove_proc_entry ("packet" , net->proc_net); +WARN_ONCE (!hlist_empty (&net->packet.sklist), +"net %x %s: sklist is not empty\n" , net->ns.inum, __func__); }static struct pernet_operations packet_net_ops = {
Signature · 1 line
2.7.4
PATCH v3 20/21 phonet: exit_net cleanup check added
In reply to Vasily AverinBe sure that pndevs.list initialized in net_init hook was return to initial state.
--- net/phonet/pn_dev.c | 5 +++++ 1 file changed, 5 insertions(+)
net/phonet/pn_dev.c +5 -0
@@ -331,7 +331,12 @@ static int __net_init phonet_init_net(struct net *net) static void __net_exit phonet_exit_net(struct net *net) { +struct phonet_net *pnn =phonet_pernet (net); +remove_proc_entry ("phonet" , net->proc_net); +WARN_ONCE (!list_empty (&pnn->pndevs.list), +"net %x %s: pndevs.list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations phonet_net_ops = {
Signature · 1 line
2.7.4
Re: [PATCH v3 20/21] phonet: exit_net cleanup check added
Quoted 15 lines · Le maanantaina 6. marraskuuta 2017, 16.25.54 EET Vasily Averin a écrit :
Be sure that pndevs.list initialized in
net_inithook was return to initial state.Signed-off-by Vasily Averin <[email protected]>--- net/phonet/pn_dev.c | 5 +++++ 1 file changed, 5 insertions(+)net/phonet/pn_dev.c +0
-0@@ -331,7 +331,12 @@ static int __net_init phonet_init_net(struct net *net) static void __net_exit phonet_exit_net(struct net *net)
net/phonet/pn_dev.c static int __net_init phonet_init_net(struct net *net) · line 342
Quoted 10 lines
net/phonet/pn_dev.c +5
-0{ +struct phonet_net *pnn =phonet_pernet (net); +remove_proc_entry ("phonet" , net->proc_net); +WARN_ONCE (!list_empty (&pnn->pndevs.list), +"net %x %s: pndevs.list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations phonet_net_ops = {
In my opinon, tis is still utterly pointless. Really, what bug did this specific patch help to fix?
If you want to debug network namespaces, I have a feeling that the network namespace code is a better place to do so than individual protocol stacks.
Signature · 2 lines
雷米‧德尼-库尔蒙 https://www.remlab.net/
Re: [PATCH v3 20/21] phonet: exit_net cleanup check added
Quoted 2 lines · Rémi Denis-Courmont
In my opinon, tis is still utterly pointless. Really, what bug did this specific patch help to fix?
I'm maintainer of legacy OpenVz kernels, we release containers-ready kernels 15+ years, they are widely used by hosting providers, usually they use 30-300 containers per node. In this scenario if any of container causes the problem it affects many other.
For many years we got lot of strange memory corruptions and found lot of memory leaks in namespace-fied subsytems.
These bugs are invisible on usual kernls, because init_net lives forever and never destroyed. However they are quite important for systems running lott of independent namespaces, that can be restarted many times without host admin assistance.
Each memory leak can be repeated many times and finally it enables OOM-killer that disables whole node. And nobody understand what's happen.
Such kind of checks allows to be sure that net namespace exit was clear and leaked nothing.
Quoted 2 lines
If you want to debug network namespaces, I have a feeling that the network namespace code is a better place to do so than individual protocol stacks.
Common network namespace code knows nothing about specific of each individual driver/subsystem. I do not understand how it's possible to do it in common netns code.
Thank you,
Vasily Averin
PATCH v3 21/21 sunrpc: exit_net cleanup check added
In reply to Vasily AverinBe sure that all_clients list initialized in net_init hook was return to initial state.
--- net/sunrpc/sunrpc_syms.c | 5 +++++ 1 file changed, 5 insertions(+)
net/sunrpc/sunrpc_syms.c +5 -0
@@ -65,10 +65,15 @@ static __net_init int sunrpc_init_net(struct net *net) static __net_exit void sunrpc_exit_net(struct net *net) { +struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +rpc_pipefs_exit_net (net);unix_gid_cache_destroy (net);ip_map_cache_destroy (net);rpc_proc_exit (net); +WARN_ONCE (!list_empty (&sn->all_clients), +"net %x %s: all_clients list is not empty\n" , + net->ns.inum, __func__); }static struct pernet_operations sunrpc_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 1/21 exit_net cleanup: geneve sock_list check
In reply to Vasily AverinBe sure that sock_list initialized in net_init hook was return to initial state.
--- drivers/net/geneve.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/geneve.c +2 -0
@@ -1673,6 +1673,8 @@ static void __net_exit geneve_exit_net(struct net *net)/* unregister the devices gathered above */ unregister_netdevice_many (&list);rtnl_unlock (); +WARN (!list_empty (&gn->sock_list), +"&s: sock_list is not empty\n" , __func__); }static struct pernet_operations geneve_net_ops = {
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH v2 01/21] exit_net cleanup: geneve sock_list check
Thank you for the patch! Perhaps something to improve:
Hi Vasily,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net/master]
[also build test WARNING on v4.14-rc8 next-20171106]
[cannot apply to net-next/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Vasily-Averin/exit_net-checks-for-objects-initialized-in-net_init-hook/20171107-094512
config: i386-randconfig-x001-201745 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:
# save the attached .config to linux build tree
make ARCH=i386 All warnings (new ones prefixed by >>):
In file included from arch/x86/include/asm/bug.h:82:0,
from include/linux/bug.h:5,
from include/linux/thread_info.h:12,
from arch/x86/include/asm/preempt.h:7,
from include/linux/preempt.h:81,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from include/linux/stat.h:19,
from include/linux/module.h:10,
from drivers/net/geneve.c:14:
drivers/net/geneve.c: In function 'geneve_exit_net':
>> drivers/net/geneve.c:1671:7: warning: too many arguments for format [-Wformat-extra-args]
"&s: sock_list is not empty\n", __func__);
^
include/asm-generic/bug.h:94:43: note: in definition of macro '__WARN_printf'
#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
^~~
>> drivers/net/geneve.c:1670:2: note: in expansion of macro 'WARN'
WARN(!list_empty(&gn->sock_list),
^~~~vim +1671 drivers/net/geneve.c
1643
1644 static void __net_exit geneve_exit_net(struct net *net)
1645 {
1646 struct geneve_net *gn = net_generic(net, geneve_net_id);
1647 struct geneve_dev *geneve, *next;
1648 struct net_device *dev, *aux;
1649 LIST_HEAD(list);
1650
1651 rtnl_lock();
1652
1653 /* gather any geneve devices that were moved into this ns */
1654 for_each_netdev_safe(net, dev, aux)
1655 if (dev->rtnl_link_ops == &geneve_link_ops)
1656 unregister_netdevice_queue(dev, &list);
1657
1658 /* now gather any other geneve devices that were created in this ns */
1659 list_for_each_entry_safe(geneve, next, &gn->geneve_list, next) {
1660 /* If geneve->dev is in the same netns, it was already added
1661 * to the list by the previous loop.
1662 */
1663 if (!net_eq(dev_net(geneve->dev), net))
1664 unregister_netdevice_queue(geneve->dev, &list);
1665 }
1666
1667 /* unregister the devices gathered above */
1668 unregister_netdevice_many(&list);
1669 rtnl_unlock();
> 1670 WARN(!list_empty(&gn->sock_list), > 1671 "&s: sock_list is not empty\n", __func__);
1672 }
1673
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v2 2/21 ppp: exit_net cleanup checks added
In reply to Vasily AverinBe sure that lists initialized in net_init hook were return to initial state.
--- drivers/net/ppp/ppp_generic.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ppp/ppp_generic.c +4 -0
@@ -960,6 +960,10 @@ static __net_exit void ppp_exit_net(struct net *net)rtnl_unlock ();idr_destroy (&pn->units_idr); +WARN (!list_empty (&pn->all_channels), +"%s: all_channels list is not empty\n" , __func__); +WARN (!list_empty (&pn->new_channels), +"%s: new_channels list is not empty\n" , __func__); }static struct pernet_operations ppp_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 3/21 vxlan: exit_net cleanup checks added
In reply to Vasily AverinBe sure that sock_list array initialized in net_init hook was return to initial state
--- drivers/net/vxlan.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/vxlan.c +6 -0
@@ -3704,6 +3704,7 @@ static void __net_exit vxlan_exit_net(struct net *net)struct vxlan_net *vn =net_generic (net, vxlan_net_id);struct vxlan_dev *vxlan, *next;struct net_device *dev, *aux; +unsigned int h;LIST_HEAD (list);rtnl_lock ();
@@ -3723,6 +3724,11 @@ static void __net_exit vxlan_exit_net(struct net *net)unregister_netdevice_many (&list);rtnl_unlock (); + +for (h =0 ; h <PORT_HASH_SIZE ; ++h) +if (WARN (!hlist_empty (&vn->sock_list[h]), +"%s: sock_list is not empty\n" , __func__)) +break ; }static struct pernet_operations vxlan_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 4/21 netdev: exit_net cleanup check added
In reply to Vasily AverinBe sure that dev_base_head list initialized in net_init hook was return to initial state
--- net/core/dev.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/dev.c +3 -0
@@ -8562,6 +8562,9 @@ static void __net_exit netdev_exit(struct net *net) {kfree (net->dev_name_head);kfree (net->dev_index_head); +if (net != &init_net) +WARN (!list_empty (&net->dev_base_head), +"%s: dev_base_head is not empty\n" , __func__); }static struct pernet_operations __net_initdata netdev_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 5/21 nfs4blocklayout: exit_net cleanup check added
In reply to Vasily AverinBe sure that bl_wq wait queue initialized in net_init hook is not used anymore.
--- fs/nfs/blocklayout/rpc_pipefs.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfs/blocklayout/rpc_pipefs.c +2 -0
@@ -256,6 +256,8 @@ static void nfs4blocklayout_net_exit(struct net *net)nfs4blocklayout_unregister_net (net, nn->bl_device_pipe);rpc_destroy_pipe_data (nn->bl_device_pipe); nn->bl_device_pipe =NULL ; +WARN (!list_empty (&nn->bl_wq.head), +"%s: bl_wq head is not empty\n" , __func__); }static struct pernet_operations nfs4blocklayout_net_ops = {
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): bafb347d-e36e-8b2b-7646-afc458a7a32a-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org
PATCH v2 6/21 nfs client: exit_net cleanup check added
Be sure that nfs_client_list and nfs_volume_list lists initialized in net_init hook were return to initial state in net_exit hook.
--- fs/nfs/client.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfs/client.c +4 -0
@@ -204,6 +204,10 @@ void nfs_cleanup_cb_ident_idr(struct net *net)struct nfs_net *nn =net_generic (net, nfs_net_id);idr_destroy (&nn->cb_ident_idr); +WARN (!list_empty (&nn->nfs_client_list), +"nfs net_exit: nfs_client_list is not empty\n" ); +WARN (!list_empty (&nn->nfs_volume_list), +"nfs net_exit: nfs_volume_list is not empty\n" ); }/* nfs_client_lock held */
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 21/21 sunrpc: exit_net cleanup check added
In reply to a message not in the archiveBe sure that all_clients list initialized in net_init hook was return to initial state.
--- net/sunrpc/sunrpc_syms.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sunrpc/sunrpc_syms.c +4 -0
@@ -65,10 +65,14 @@ static __net_init int sunrpc_init_net(struct net *net) static __net_exit void sunrpc_exit_net(struct net *net) { +struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +rpc_pipefs_exit_net (net);unix_gid_cache_destroy (net);ip_map_cache_destroy (net);rpc_proc_exit (net); +WARN (!list_empty (&sn->all_clients), +"%s: all_clients list is not empty\n" , __func__); }static struct pernet_operations sunrpc_net_ops = {
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 7/21 fib_notifier: exit_net cleanup check added
In reply to Vasily AverinBe sure that fib_notifier_ops list initilized in net_init hook was return to initial state.
--- net/core/fib_notifier.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/fib_notifier.c +7 -0
@@ -161,8 +161,15 @@ static int __net_init fib_notifier_net_init(struct net *net)return 0 ; } +static void __net_exit fib_notifier_net_exit(struct net *net) +{ +WARN (!list_empty (&net->fib_notifier_ops), +"%s: fib_notifier_ops list is not empty\n" , __func__); +} +static struct pernet_operations fib_notifier_net_ops = { .init = fib_notifier_net_init, + .exit = fib_notifier_net_exit, };static int __init fib_notifier_init (void )
Signature · 1 line
2.7.4
PATCH v2 8/21 fib_rules: exit_net cleanup check added
In reply to Vasily AverinBe sure that rules_ops list initialized in net_init hook was return to initial state.
--- net/core/fib_rules.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/core/fib_rules.c +7 -0
@@ -1019,8 +1019,15 @@ static int __net_init fib_rules_net_init(struct net *net)return 0 ; } +static void __net_exit fib_rules_net_exit(struct net *net) +{ +WARN (!list_empty (&net->rules_ops), +"%s: rules_ops list is not empty\n" , __func__); +} +static struct pernet_operations fib_rules_net_ops = { .init = fib_rules_net_init, + .exit = fib_rules_net_exit, };static int __init fib_rules_init (void )
Signature · 1 line
2.7.4
PATCH v2 9/21 clusterip: exit_net cleanup check added
In reply to Vasily AverinBe sure that configs list initialized in net_init hook was return to initial state.
--- net/ipv4/netfilter/ipt_CLUSTERIP.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/netfilter/ipt_CLUSTERIP.c +2 -0
@@ -819,6 +819,8 @@ static void clusterip_net_exit(struct net *net) cn->procdir =NULL ;#endif nf_unregister_net_hook (net, &cip_arp_ops); +WARN (!list_empty (&cn->configs), +"%s: configs list is not empty\n" i, __func__); }static struct pernet_operations clusterip_net_ops = {
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH v2 09/21] clusterip: exit_net cleanup check added
Thank you for the patch! Yet something to improve:
Hi Vasily,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on net/master]
[also build test ERROR on v4.14-rc8 next-20171106]
[cannot apply to net-next/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Vasily-Averin/exit_net-checks-for-objects-initialized-in-net_init-hook/20171107-094512
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa
All error/warnings (new ones prefixed by >>):
In file included from ./arch/xtensa/include/generated/asm/bug.h:1:0,
from include/linux/bug.h:5,
from include/linux/thread_info.h:12,
from include/asm-generic/preempt.h:5, from ./arch/xtensa/include/generated/asm/preempt.h:1, from include/linux/preempt.h:81,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from include/linux/stat.h:19,
from include/linux/module.h:10,
from net/ipv4//netfilter/ipt_CLUSTERIP.c:13:
net/ipv4//netfilter/ipt_CLUSTERIP.c: In function 'clusterip_net_exit':
>> net/ipv4//netfilter/ipt_CLUSTERIP.c:823:40: error: expected ')' before 'i'
"%s: configs list is not empty\n"i, __func__);
^
include/asm-generic/bug.h:89:69: note: in definition of macro '__WARN_printf'
#define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg)
^
>> net/ipv4//netfilter/ipt_CLUSTERIP.c:822:2: note: in expansion of macro 'WARN'
WARN(!list_empty(&cn->configs),
^
>> net/ipv4//netfilter/ipt_CLUSTERIP.c:823:40: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
"%s: configs list is not empty\n"i, __func__);
^
include/asm-generic/bug.h:89:69: note: in definition of macro '__WARN_printf'
#define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg)
^
>> net/ipv4//netfilter/ipt_CLUSTERIP.c:822:2: note: in expansion of macro 'WARN'
WARN(!list_empty(&cn->configs),
^vim +823 net/ipv4//netfilter/ipt_CLUSTERIP.c
813
814 static void clusterip_net_exit(struct net *net)
815 {
816 #ifdef CONFIG_PROC_FS
817 struct clusterip_net *cn = net_generic(net, clusterip_net_id);
818 proc_remove(cn->procdir);
819 cn->procdir = NULL;
820 #endif
821 nf_unregister_net_hook(net, &cip_arp_ops);
> 822 WARN(!list_empty(&cn->configs), > 823 "%s: configs list is not empty\n"i, __func__);
824 }
825
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v2 10/21 xfrm6_tunnel: exit_net cleanup check added
In reply to Vasily AverinBe sure that spi_byaddr and spi_byspi arrays initialized in net_init hook were return to initial state
--- net/ipv6/xfrm6_tunnel.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/ipv6/xfrm6_tunnel.c +12 -0
@@ -338,6 +338,18 @@ static int __net_init xfrm6_tunnel_net_init(struct net *net) static void __net_exit xfrm6_tunnel_net_exit(struct net *net) { +struct xfrm6_tunnel_net *xfrm6_tn =xfrm6_tunnel_pernet (net); +unsigned int i; + +for (i =0 ; i <XFRM6_TUNNEL_SPI_BYADDR_HSIZE ; i++) +if (WARN (!hlist_empty (&xfrm6_tn->spi_byaddr[i]), +"%s: spi_byaddr is not empty\n" , __func__)) +break ; + +for (i =0 ; i <XFRM6_TUNNEL_SPI_BYSPI_HSIZE ; i++) +if (WARN (!hlist_empty (&xfrm6_tn->spi_byspi[i]), +"%s: spi_byspi is not empty\n" , __func__)) +break ; }static struct pernet_operations xfrm6_tunnel_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 11/21 af_key: replace BUG_ON on WARN_ON in net_exit hook
In reply to Vasily Averin--- net/key/af_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/key/af_key.c +1 -1
@@ -3845,7 +3845,7 @@ static void __net_exit pfkey_net_exit(struct net *net)struct netns_pfkey *net_pfkey =net_generic (net, pfkey_net_id);pfkey_exit_proc (net); -BUG_ON (!hlist_empty (&net_pfkey->table)); +WARN_ON (!hlist_empty (&net_pfkey->table)); }static struct pernet_operations pfkey_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 12/21 l2tp: exit_net cleanup check added
In reply to Vasily AverinBe sure that l2tp_session_hlist array initialized in net_init hook was return to initial state.
--- net/l2tp/l2tp_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/l2tp/l2tp_core.c +6 -0
@@ -1888,6 +1888,7 @@ static __net_exit void l2tp_exit_net(struct net *net) {struct l2tp_net *pn =l2tp_pernet (net);struct l2tp_tunnel *tunnel =NULL ; +int hash;rcu_read_lock_bh ();list_for_each_entry_rcu (tunnel, &pn->l2tp_tunnel_list, list) {
@@ -1897,6 +1898,11 @@ static __net_exit void l2tp_exit_net(struct net *net)flush_workqueue (l2tp_wq);rcu_barrier (); + +for (hash =0 ; hash <L2TP_HASH_SIZE_2 ; hash++) +if (WARN (!hlist_empty (&pn->l2tp_session_hlist[hash]), +"%s: session_hlist is not empty\n" , __func__)) +break ; }static struct pernet_operations l2tp_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 13/21 nf_tables: exit_net cleanup check added
In reply to Vasily AverinBe sure that lists initialized in net_init hook were return to initial state.
--- net/netfilter/nf_tables_api.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/netfilter/nf_tables_api.c +9 -0
@@ -5778,6 +5778,14 @@ static int __net_init nf_tables_init_net(struct net *net)return 0 ; } +static void __net_exit nf_tables_exit_net(struct net *net) +{ +WARN (!list_empty (&net->nft.af_info), +"%s: af_info list is not empty\n" , __func__); +WARN (!list_empty (&net->nft.commit_list), +"%s: commit_list is not empty\n" , __func__); +} +int __nft_release_basechain (struct nft_ctx *ctx) {struct nft_rule *rule, *nr;
@@ -5848,6 +5856,7 @@ static void __nft_release_afinfo(struct net *net, struct nft_af_info *afi)static struct pernet_operations nf_tables_net_ops = { .init = nf_tables_init_net, + .exit = nf_tables_exit_net, };static int __init nf_tables_module_init (void )
Signature · 1 line
2.7.4
PATCH v2 14/21 nfnetlink_log: exit_net cleanup check added
In reply to Vasily AverinBe sure that instance_table array initialized in net_init hook was return to initial state.
--- net/netfilter/nfnetlink_log.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/netfilter/nfnetlink_log.c +6 -0
@@ -1093,10 +1093,16 @@ static int __net_init nfnl_log_net_init(struct net *net) static void __net_exit nfnl_log_net_exit(struct net *net) { +unsigned int i; +struct nfnl_log_net *log =nfnl_log_pernet (net);#ifdef CONFIG_PROC_FS remove_proc_entry ("nfnetlink_log" , net->nf.proc_netfilter);#endif nf_log_unset (net, &nfulnl_logger); +for (i =0 ; i <INSTANCE_BUCKETS ; i++) +if (WARN (!hlist_empty (&log->instance_table[i]), +"%s: instance_table is not empty\n" , __func__)) +break ; }static struct pernet_operations nfnl_log_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 15/21 nfnetlink_gueue: exit_net cleanup check added
In reply to Vasily AverinBe sure that instance_table array initialized in net_init hook was return to initial state.
--- net/netfilter/nfnetlink_queue.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/netfilter/nfnetlink_queue.c +7 -0
@@ -1512,10 +1512,17 @@ static int __net_init nfnl_queue_net_init(struct net *net) static void __net_exit nfnl_queue_net_exit(struct net *net) { +unsigned int i; +struct nfnl_queue_net *q =nfnl_queue_pernet (net); +nf_unregister_queue_handler (net);#ifdef CONFIG_PROC_FS remove_proc_entry ("nfnetlink_queue" , net->nf.proc_netfilter);#endif +for (i =0 ; i <INSTANCE_BUCKETS ; i++) +if (WARN (!hlist_empty (&q->instance_table[i]), +"%s: instance_table isn't empty\n" , __func__)) +break ; }static void nfnl_queue_net_exit_batch (struct list_head *net_exit_list)
Signature · 1 line
2.7.4
PATCH v2 16/21 x_tables: exit_net cleanup check added
In reply to Vasily AverinBe sure that xt.tables array initialized in net_init hook was return to initial state.
--- net/netfilter/x_tables.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/netfilter/x_tables.c +10 -0
@@ -1714,8 +1714,18 @@ static int __net_init xt_net_init(struct net *net)return 0 ; } +static void __net_exit xt_net_exit(struct net *net) +{ +int i; + +for (i =0 ; i <NFPROTO_NUMPROTO ; i++) +WARN (!list_empty (&net->xt.tables[i]), +"%s: tables list is not empty\n" , __func__); +} +static struct pernet_operations xt_net_ops = { .init = xt_net_init, + .exit = xt_net_exit, };static int __init xt_init (void )
Signature · 1 line
2.7.4
PATCH v2 17/21 hashlimit: exit_net cleanup check added
In reply to Vasily AverinBe sure that htables array initialized in net_init hook was return to initial state.
--- net/netfilter/xt_hashlimit.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/xt_hashlimit.c +4 -0
@@ -1338,7 +1338,11 @@ static int __net_init hashlimit_net_init(struct net *net) static void __net_exit hashlimit_net_exit(struct net *net) { +struct hashlimit_net *hashlimit_net =hashlimit_pernet (net); +hashlimit_proc_net_exit (net); +WARN (!hlist_empty (&hashlimit_net->htables), +"%s: htables hlist is not empty\n" , __func__); }static struct pernet_operations hashlimit_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 18/21 recent: exit_net cleanup check added
In reply to Vasily AverinBe sure that tables list initialized in net_init hook was return to initial state.
--- net/netfilter/xt_recent.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/xt_recent.c +4 -0
@@ -681,7 +681,11 @@ static int __net_init recent_net_init(struct net *net) static void __net_exit recent_net_exit(struct net *net) { +struct recent_net *recent_net =recent_pernet (net); +recent_proc_net_exit (net); +WARN (!list_empty (&recent_net->tables), +"%s: tables list is not empty\n" , __func__); }static struct pernet_operations recent_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 19/21 packet: exit_net cleanup check added
In reply to Vasily AverinBe sure that packet.sklist initialized in net_init hook was return to initial state.
--- net/packet/af_packet.c | 2 ++ 1 file changed, 2 insertions(+)
net/packet/af_packet.c +2 -0
@@ -4562,6 +4562,8 @@ static int __net_init packet_net_init(struct net *net) static void __net_exit packet_net_exit(struct net *net) {remove_proc_entry ("packet" , net->proc_net); +WARN (!hlist_empty (&net->packet.sklist), +"%s: sklist is not empty\n" , __func__); }static struct pernet_operations packet_net_ops = {
Signature · 1 line
2.7.4
PATCH v2 20/21 phonet: exit_net cleanup check added
In reply to Vasily AverinBe sure that pndevs.list initialized in net_init hook was return to initial state.
--- net/phonet/pn_dev.c | 4 ++++ 1 file changed, 4 insertions(+)
net/phonet/pn_dev.c +4 -0
@@ -331,7 +331,11 @@ static int __net_init phonet_init_net(struct net *net) static void __net_exit phonet_exit_net(struct net *net) { +struct phonet_net *pnn =phonet_pernet (net); +remove_proc_entry ("phonet" , net->proc_net); +WARN (!list_empty (&pnn->pndevs.list), +"%s: pndevs.list is not empty\n" , __func__); }static struct pernet_operations phonet_net_ops = {
Signature · 1 line
2.7.4