Commit 0d98da5d authored by Gao feng's avatar Gao feng Committed by Pablo Neira Ayuso

netfilter: nf_conntrack: register pernet subsystem before register L4 proto

In (c296bb4d netfilter: nf_conntrack: refactor l4proto support for netns)
the l4proto gre/dccp/udplite/sctp registration happened before the pernet
subsystem, which is wrong.

Register pernet subsystem before register L4proto since after register
L4proto, init_conntrack may try to access the resources which allocated
in register_pernet_subsys.
Reported-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarGao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent cca7af38
...@@ -969,6 +969,10 @@ static int __init nf_conntrack_proto_dccp_init(void) ...@@ -969,6 +969,10 @@ static int __init nf_conntrack_proto_dccp_init(void)
{ {
int ret; int ret;
ret = register_pernet_subsys(&dccp_net_ops);
if (ret < 0)
goto out_pernet;
ret = nf_ct_l4proto_register(&dccp_proto4); ret = nf_ct_l4proto_register(&dccp_proto4);
if (ret < 0) if (ret < 0)
goto out_dccp4; goto out_dccp4;
...@@ -977,16 +981,12 @@ static int __init nf_conntrack_proto_dccp_init(void) ...@@ -977,16 +981,12 @@ static int __init nf_conntrack_proto_dccp_init(void)
if (ret < 0) if (ret < 0)
goto out_dccp6; goto out_dccp6;
ret = register_pernet_subsys(&dccp_net_ops);
if (ret < 0)
goto out_pernet;
return 0; return 0;
out_pernet:
nf_ct_l4proto_unregister(&dccp_proto6);
out_dccp6: out_dccp6:
nf_ct_l4proto_unregister(&dccp_proto4); nf_ct_l4proto_unregister(&dccp_proto4);
out_dccp4: out_dccp4:
unregister_pernet_subsys(&dccp_net_ops);
out_pernet:
return ret; return ret;
} }
......
...@@ -420,18 +420,18 @@ static int __init nf_ct_proto_gre_init(void) ...@@ -420,18 +420,18 @@ static int __init nf_ct_proto_gre_init(void)
{ {
int ret; int ret;
ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_gre4);
if (ret < 0)
goto out_gre4;
ret = register_pernet_subsys(&proto_gre_net_ops); ret = register_pernet_subsys(&proto_gre_net_ops);
if (ret < 0) if (ret < 0)
goto out_pernet; goto out_pernet;
ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_gre4);
if (ret < 0)
goto out_gre4;
return 0; return 0;
out_pernet:
nf_ct_l4proto_unregister(&nf_conntrack_l4proto_gre4);
out_gre4: out_gre4:
unregister_pernet_subsys(&proto_gre_net_ops);
out_pernet:
return ret; return ret;
} }
......
...@@ -888,6 +888,10 @@ static int __init nf_conntrack_proto_sctp_init(void) ...@@ -888,6 +888,10 @@ static int __init nf_conntrack_proto_sctp_init(void)
{ {
int ret; int ret;
ret = register_pernet_subsys(&sctp_net_ops);
if (ret < 0)
goto out_pernet;
ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_sctp4); ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_sctp4);
if (ret < 0) if (ret < 0)
goto out_sctp4; goto out_sctp4;
...@@ -896,16 +900,12 @@ static int __init nf_conntrack_proto_sctp_init(void) ...@@ -896,16 +900,12 @@ static int __init nf_conntrack_proto_sctp_init(void)
if (ret < 0) if (ret < 0)
goto out_sctp6; goto out_sctp6;
ret = register_pernet_subsys(&sctp_net_ops);
if (ret < 0)
goto out_pernet;
return 0; return 0;
out_pernet:
nf_ct_l4proto_unregister(&nf_conntrack_l4proto_sctp6);
out_sctp6: out_sctp6:
nf_ct_l4proto_unregister(&nf_conntrack_l4proto_sctp4); nf_ct_l4proto_unregister(&nf_conntrack_l4proto_sctp4);
out_sctp4: out_sctp4:
unregister_pernet_subsys(&sctp_net_ops);
out_pernet:
return ret; return ret;
} }
......
...@@ -371,6 +371,10 @@ static int __init nf_conntrack_proto_udplite_init(void) ...@@ -371,6 +371,10 @@ static int __init nf_conntrack_proto_udplite_init(void)
{ {
int ret; int ret;
ret = register_pernet_subsys(&udplite_net_ops);
if (ret < 0)
goto out_pernet;
ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_udplite4); ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_udplite4);
if (ret < 0) if (ret < 0)
goto out_udplite4; goto out_udplite4;
...@@ -379,16 +383,12 @@ static int __init nf_conntrack_proto_udplite_init(void) ...@@ -379,16 +383,12 @@ static int __init nf_conntrack_proto_udplite_init(void)
if (ret < 0) if (ret < 0)
goto out_udplite6; goto out_udplite6;
ret = register_pernet_subsys(&udplite_net_ops);
if (ret < 0)
goto out_pernet;
return 0; return 0;
out_pernet:
nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite6);
out_udplite6: out_udplite6:
nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite4); nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite4);
out_udplite4: out_udplite4:
unregister_pernet_subsys(&udplite_net_ops);
out_pernet:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment