* [PATCH] gre: fix netns vs proto registration ordering
@ 2010-02-16 17:57 Alexey Dobriyan
2010-02-16 23:14 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2010-02-16 17:57 UTC (permalink / raw)
To: davem; +Cc: netdev, security
GRE protocol receive hook can be called right after protocol addition is done.
If netns stuff is not yet initialized, we're going to oops in
net_generic().
This is remotely oopsable if ip_gre is compiled as module and packet
comes at unfortunate moment of module loading.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
net/ipv4/ip_gre.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1665,14 +1665,15 @@ static int __init ipgre_init(void)
printk(KERN_INFO "GRE over IPv4 tunneling driver\n");
- if (inet_add_protocol(&ipgre_protocol, IPPROTO_GRE) < 0) {
- printk(KERN_INFO "ipgre init: can't add protocol\n");
- return -EAGAIN;
- }
-
err = register_pernet_device(&ipgre_net_ops);
if (err < 0)
- goto gen_device_failed;
+ return err;
+
+ err = inet_add_protocol(&ipgre_protocol, IPPROTO_GRE);
+ if (err < 0) {
+ printk(KERN_INFO "ipgre init: can't add protocol\n");
+ goto add_proto_failed;
+ }
err = rtnl_link_register(&ipgre_link_ops);
if (err < 0)
@@ -1688,9 +1689,9 @@ out:
tap_ops_failed:
rtnl_link_unregister(&ipgre_link_ops);
rtnl_link_failed:
- unregister_pernet_device(&ipgre_net_ops);
-gen_device_failed:
inet_del_protocol(&ipgre_protocol, IPPROTO_GRE);
+add_proto_failed:
+ unregister_pernet_device(&ipgre_net_ops);
goto out;
}
@@ -1698,9 +1699,9 @@ static void __exit ipgre_fini(void)
{
rtnl_link_unregister(&ipgre_tap_ops);
rtnl_link_unregister(&ipgre_link_ops);
- unregister_pernet_device(&ipgre_net_ops);
if (inet_del_protocol(&ipgre_protocol, IPPROTO_GRE) < 0)
printk(KERN_INFO "ipgre close: can't remove protocol\n");
+ unregister_pernet_device(&ipgre_net_ops);
}
module_init(ipgre_init);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gre: fix netns vs proto registration ordering
2010-02-16 17:57 [PATCH] gre: fix netns vs proto registration ordering Alexey Dobriyan
@ 2010-02-16 23:14 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-02-16 23:14 UTC (permalink / raw)
To: adobriyan; +Cc: netdev, security
From: Alexey Dobriyan <adobriyan@gmail.com>
Date: Tue, 16 Feb 2010 19:57:44 +0200
> GRE protocol receive hook can be called right after protocol addition is done.
> If netns stuff is not yet initialized, we're going to oops in
> net_generic().
>
> This is remotely oopsable if ip_gre is compiled as module and packet
> comes at unfortunate moment of module loading.
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Applied to net-next-2.6
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-02-16 23:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-16 17:57 [PATCH] gre: fix netns vs proto registration ordering Alexey Dobriyan
2010-02-16 23:14 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).