aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-04-18 12:11:23 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-19 15:37:48 -0400
commit3adadc08cc1e2cbcc15a640d639297ef5fcb17f5 (patch)
tree20990c83f62157caf753736e63ea98548404a954
parent996f73937cd85031da8dbcd3222a710cb762d428 (diff)
net ax25: Reorder ax25_exit to remove races.
While reviewing the sysctl code in ax25 I spotted races in ax25_exit where it is possible to receive notifications and packets after already freeing up some of the data structures needed to process those notifications and updates. Call unregister_netdevice_notifier early so that the rest of the cleanup code does not need to deal with network devices. This takes advantage of my recent enhancement to unregister_netdevice_notifier to send unregister notifications of all network devices that are current registered. Move the unregistration for packet types, socket types and protocol types before we cleanup any of the ax25 data structures to remove the possibilities of other races. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ax25/af_ax25.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 0906c194a413..9d9a6a3edbd5 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -2011,16 +2011,17 @@ static void __exit ax25_exit(void)
2011 proc_net_remove(&init_net, "ax25_route"); 2011 proc_net_remove(&init_net, "ax25_route");
2012 proc_net_remove(&init_net, "ax25"); 2012 proc_net_remove(&init_net, "ax25");
2013 proc_net_remove(&init_net, "ax25_calls"); 2013 proc_net_remove(&init_net, "ax25_calls");
2014 ax25_rt_free();
2015 ax25_uid_free();
2016 ax25_dev_free();
2017 2014
2018 ax25_unregister_sysctl();
2019 unregister_netdevice_notifier(&ax25_dev_notifier); 2015 unregister_netdevice_notifier(&ax25_dev_notifier);
2016 ax25_unregister_sysctl();
2020 2017
2021 dev_remove_pack(&ax25_packet_type); 2018 dev_remove_pack(&ax25_packet_type);
2022 2019
2023 sock_unregister(PF_AX25); 2020 sock_unregister(PF_AX25);
2024 proto_unregister(&ax25_proto); 2021 proto_unregister(&ax25_proto);
2022
2023 ax25_rt_free();
2024 ax25_uid_free();
2025 ax25_dev_free();
2025} 2026}
2026module_exit(ax25_exit); 2027module_exit(ax25_exit);